예제 #1
0
파일: main.py 프로젝트: daweiyang/itest
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))
예제 #2
0
파일: main.py 프로젝트: daweiyang/itest
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