Permalink
Browse files

Add SYNC_USER setting.

  • Loading branch information...
1 parent dce1f1f commit 70f82b5451334dacd23fe1aa02b4bfba99d1331e @ericholscher ericholscher committed Oct 24, 2012
Showing with 8 additions and 8 deletions.
  1. +8 −8 readthedocs/core/utils.py
View
@@ -5,20 +5,22 @@
log = logging.getLogger(__name__)
+SYNC_USER = getattr(settings, 'SYNC_USER', getpass.getuser())
+
def copy_to_app_servers(full_build_path, target, mkdir=True):
"""
A helper to copy a directory across app servers
"""
log.info("Copying %s to %s" % (full_build_path, target))
for server in settings.MULTIPLE_APP_SERVERS:
- mkdir_cmd = ("ssh %s@%s mkdir -p %s" % (getpass.getuser(), server, target))
+ mkdir_cmd = ("ssh %s@%s mkdir -p %s" % (SYNC_USER, server, target))
ret = os.system(mkdir_cmd)
if ret != 0:
log.error("COPY ERROR to app servers:")
log.error(mkdir_cmd)
sync_cmd = ("rsync -e 'ssh -T' -av --delete %s/ %s@%s:%s" %
- (full_build_path, getpass.getuser(), server, target))
+ (full_build_path, SYNC_USER, server, target))
ret = os.system(sync_cmd)
if ret != 0:
log.error("COPY ERROR to app servers.")
@@ -32,13 +34,13 @@ def copy_file_to_app_servers(from_file, to_file):
log.info("Copying %s to %s" % (from_file, to_file))
to_path = os.path.dirname(to_file)
for server in settings.MULTIPLE_APP_SERVERS:
- mkdir_cmd = ("ssh %s@%s mkdir -p %s" % (getpass.getuser(), server, to_path))
+ mkdir_cmd = ("ssh %s@%s mkdir -p %s" % (SYNC_USER, server, to_path))
ret = os.system(mkdir_cmd)
if ret != 0:
log.error("COPY ERROR to app servers.")
- log.error(sync_cmd)
+ log.error(mkdir_cmd)
- sync_cmd = ("rsync -e 'ssh -T' -av --delete %s %s@%s:%s" % (from_file, getpass.getuser(), server, to_file))
+ sync_cmd = ("rsync -e 'ssh -T' -av --delete %s %s@%s:%s" % (from_file, SYNC_USER, server, to_file))
ret = os.system(sync_cmd)
if ret != 0:
log.error("COPY ERROR to app servers.")
@@ -53,12 +55,10 @@ def run_on_app_servers(command):
ret_val = 0
if getattr(settings, "MULTIPLE_APP_SERVERS", None):
for server in settings.MULTIPLE_APP_SERVERS:
- ret = os.system("ssh %s@%s %s" % (getpass.getuser(), server, command))
+ ret = os.system("ssh %s@%s %s" % (SYNC_USER, server, command))
if ret != 0:
ret_val = ret
return ret_val
else:
ret = os.system(command)
return ret
-
-

0 comments on commit 70f82b5

Please sign in to comment.