Beispiel #1
0
def syncToPcs(path,remotePath,rPath=""):
    print "here"
    if not os.path.isdir(path):
        return
    print "here"
    existFile = {}
    try:
        filelist = pcsSDK.getFileList(remotePath+rPath)
        for fileItem in filelist["list"]:
            existFile[fileItem["path"]] = fileItem
    except:
        pass
    for f in os.listdir(path):
        tf = os.path.join(path,f)
        if os.path.isfile(tf):
            print f
            tmpName = pcsSDK.gAppRoot+remotePath + rPath + f
            print tmpName
            if tmpName in existFile:
                print "exist:"+tf
            else:
                print "uploading:"+tf
                pcsSDK.uploadFile(remotePath+rPath,tf)
        elif os.path.isdir(tf):
            if len(rPath)==0:
                syncToPcs(tf,remotePath,f)
            else:
                syncToPcs(tf,remotePath,rPath+"/"+f)
Beispiel #2
0
def uploadWorker():
    global index
    while True:
        lock.acquire()
        if index < len(uploadList):
            filename = uploadList[index]
            index += 1
            lock.release()
        else:
            lock.release()
            return
        sys.stdout.write("uploading "+filename["localPath"]+"\n")
        i = 0
        while i<3:
            try:
                pcsSDK.uploadFile(filename["remotePath"],filename["localPath"],ondup="newcopy")
                sys.stdout.write("uploaded "+filename["localPath"]+"\n")
                break
            except:
                i += 1