tools: fixed problem with local test
authorFredrik Unger <fred@tree.se>
Wed, 6 Feb 2013 10:55:46 +0000 (11:55 +0100)
committerFredrik Unger <fred@tree.se>
Wed, 6 Feb 2013 10:55:46 +0000 (11:55 +0100)
The ssh_cmd needed a host to do the command, but for local tests
a host is not availible. Test for host and if not availible run locally.
rsync does not need that check.

treecutter/tools.py

index f294c61106d8cfa025d8d660163001c6e9c7ddf4..a9c94a0837b7cf523ff17d40d1e361a027b75706 100644 (file)
@@ -20,7 +20,10 @@ def publish(src,target):
 def ssh_cmd(target, command):
     t = target.split(":")
     c = command.split()
-    cmd = ["ssh",t[0],c[0],c[1],t[1]]
+    if len(t)==1:
+        cmd = [c[0],c[1],t[0]]
+    else:
+        cmd = ["ssh",t[0],c[0],c[1],t[1]]
     retcode = subprocess.call(cmd)
     if retcode:
         print 'Error: '+' '.join(cmd)+' Returncode ['+str(retcode)+']'