diff --git a/hyde/ext/publishers/ssh.py b/hyde/ext/publishers/ssh.py index b22514a..8ea7c4c 100644 --- a/hyde/ext/publishers/ssh.py +++ b/hyde/ext/publishers/ssh.py @@ -35,6 +35,7 @@ from hyde.publisher import Publisher from subprocess import Popen, PIPE +import shlex class SSH(Publisher): @@ -45,17 +46,19 @@ class SSH(Publisher): self.target = settings.target self.command = getattr(settings, 'command', 'rsync') self.opts = getattr(settings, 'opts', '-r -e ssh') + if isinstance(self.opts, str): + self.opts = shlex.split(self.opts) def publish(self): - command = "{command} {opts} ./ {username}{server}:{target}".format( - command=self.command, - opts=self.opts, - username=self.username + '@' if self.username else '', - server=self.server, - target=self.target) + command = [ self.command, ] + self.opts + [ './', + '{username}{server}:{target}'.format( + username=self.username + '@' if self.username else '', + server=self.server, + target=self.target) ] + print('pubcmd:', repr(command)) deploy_path = self.site.config.deploy_root_path.path - cmd = Popen(command, cwd=str(deploy_path), stdout=PIPE, shell=True) - cmdresult = cmd.communicate()[0] + cmd = Popen(command, cwd=str(deploy_path), stdout=PIPE, stderr=PIPE) + cmdresult = cmd.communicate() if cmd.returncode: raise Exception(cmdresult)