Browse Source

use lists of strings, don't depend upon shell to parse them..

include stderr when reporting errors as well as stdin..
main
John-Mark Gurney 4 years ago
parent
commit
49d1623360
1 changed files with 11 additions and 8 deletions
  1. +11
    -8
      hyde/ext/publishers/ssh.py

+ 11
- 8
hyde/ext/publishers/ssh.py View File

@@ -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)

||||||
x
 
000:0
Loading…
Cancel
Save