]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/ssh.py
Use absolute_import from the __future__ everywhere
[bup.git] / lib / bup / ssh.py
index f91e16dcb34bc9ce1d755704b2c1a8f96db439b3..97ab3121a7177b9a0e0f24f4b39e795767e9fe8f 100644 (file)
@@ -1,20 +1,16 @@
 """SSH connection.
 Connect to a remote host via SSH and execute a command on the host.
 """
-import os
-import sys
-import re
-import subprocess
 
-from bup import helpers
+from __future__ import absolute_import
+import sys, os, re, subprocess
+from bup import helpers, path
 
 
-def connect(rhost, port, subcmd):
+def connect(rhost, port, subcmd, stderr=None):
     """Connect to 'rhost' and execute the bup subcommand 'subcmd' on it."""
     assert(not re.search(r'[^\w-]', subcmd))
-    main_exe = os.environ.get('BUP_MAIN_EXE') or sys.argv[0]
-    nicedir = os.path.split(os.path.abspath(main_exe))[0]
-    nicedir = re.sub(r':', "_", nicedir)
+    nicedir = re.sub(r':', "_", path.exedir())
     if rhost == '-':
         rhost = None
     if not rhost:
@@ -45,4 +41,5 @@ def connect(rhost, port, subcmd):
                                            os.environ.get('PATH', '')])
         os.setsid()
     return subprocess.Popen(argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+                            stderr=stderr,
                             preexec_fn=setup)