From d02d22204f9445ad3634b150ac5dc8a360b05c95 2014-02-01 04:42:59 From: MinRK Date: 2014-02-01 04:42:59 Subject: [PATCH] ensure scp destination directories exist (with mkdir -p) in SSH launchers. As described in #3411 closes #3411 --- diff --git a/IPython/parallel/apps/launcher.py b/IPython/parallel/apps/launcher.py index 368d787..d0a1802 100644 --- a/IPython/parallel/apps/launcher.py +++ b/IPython/parallel/apps/launcher.py @@ -600,6 +600,11 @@ class SSHLauncher(LocalProcessLauncher): time.sleep(1) else: break + remote_dir = os.path.dirname(remote) + self.log.info("ensuring remote %s:%s/ exists", self.location, remote_dir) + check_output(self.ssh_cmd + self.ssh_args + \ + [self.location, 'mkdir', '-p', '--', remote_dir] + ) self.log.info("sending %s to %s", local, remote) check_output(self.scp_cmd + [local, remote]) @@ -623,6 +628,9 @@ class SSHLauncher(LocalProcessLauncher): time.sleep(1) elif check == u'yes': break + local_dir = os.path.dirname(local) + if not os.path.exists(local_dir): + os.makedirs(local_dir) check_output(self.scp_cmd + [full_remote, local]) def fetch_files(self):