Ejemplo n.º 1
0
def mkdir_in_remote(url):
    parts = url.split('@', 1)
    if len(parts) > 1:
        username, host_and_path = parts
    else:
        host_and_path = parts[0]
        username = ''
    host, path = host_and_path.split(':', 1)
    userhost = '%s@%s' % (username, host) if username else host

    cmd = "ssh '%s' mkdir -p '%s'" % (userhost, path)
    msger.debug(cmd)
    if os.system(cmd) != 0:
        msger.error("can't mkdir %s in remote server %s" % (path, userhost))
Ejemplo n.º 2
0
def rsync(local_path, remote_path):
    cmd = "rsync -a '%s/'* '%s'" % (local_path, remote_path)
    msger.debug(cmd)
    ret = os.system(cmd)
    if ret == 0:
        return 0

    msger.warning('sync to %s failed, time a few seconds and retry')
    time.sleep(5)
    ret = os.system(cmd)
    if ret == 0:
        return 0

    msger.warning('sync to %s failed, please check the network')
    return ret