Permalink
Browse files

added alternate port support for ensure.git.rsync

  • Loading branch information...
1 parent 871b82b commit 1eb3fe9f5cca6502551481aab04ece2506fdf6c1 @dexterbt1 committed Jun 26, 2012
Showing with 20 additions and 1 deletion.
  1. +11 −1 src/cuisine_sweet/ensure/git.py
  2. +9 −0 src/cuisine_sweet/utils.py
@@ -9,6 +9,7 @@
from fabric.api import env, cd, lcd, local, run, put, abort
from fabric.utils import error
from fabric.auth import get_password
+from fabric.network import normalize
from cuisine_sweet import git
from cuisine_sweet.utils import completed_ok, local_run_expect
@@ -105,7 +106,16 @@ def rsync(repo_url, repo_dir, refspec='master', home='.', base_dir='git', local_
prompts = [ 'Are you sure you want to continue connecting', ".* password:" ]
answers = [ 'yes', get_password() ]
- rsync_cmd = '''/bin/bash -l -c "rsync --delete --exclude \".git/" -lpthrvz --rsh='ssh -p 22' %s %s:%s"''' % (clone_basepath_local + "/", env.host_string, clone_basepath_remote)
+
+ # resolve user,host,port for rsh string
+ user, host, port = normalize(env.host_string)
+ port_string = "-p %s" % port
+ rsh_parts = [port_string]
+ rsh_string = "--rsh='ssh %s'" % " ".join(rsh_parts)
+
+ user_at_host = "%s@%s" % (user, host)
+
+ rsync_cmd = '''/bin/bash -l -c "rsync --delete --exclude \".git/" -lpthrvz %s %s %s:%s"''' % (rsh_string, clone_basepath_local + "/", user_at_host, clone_basepath_remote)
local_run_expect(rsync_cmd, prompts, answers, logfile=sys.stdout)
@@ -4,6 +4,7 @@
from decorator import decorator
from fabric.api import puts
from fabric.colors import green
+from fabric.utils import error
def this_func(level=1):
frm = inspect.stack()[level]
@@ -23,6 +24,7 @@ def wrapped_f(func, *args, **kwargs):
def local_run_expect(cmd, prompts, answers, logfile=sys.stdout):
+ puts(cmd)
child = pexpect.spawn(
cmd,
timeout=1800,
@@ -36,3 +38,10 @@ def local_run_expect(cmd, prompts, answers, logfile=sys.stdout):
child.sendline(answers[i])
except pexpect.EOF:
break
+ child.close()
+ success = False
+ if child.exitstatus is not None:
+ if child.exitstatus == 0:
+ success = True
+ if not success:
+ error("Error in rsync subprocess: exit_code=%s; signal=%s" % (child.exitstatus, child.signalstatus))

0 comments on commit 1eb3fe9

Please sign in to comment.