コード例 #1
0
ファイル: locksstool.py プロジェクト: MetaArchive/educopia
def makeSizeList(lockssURL, name, password, limit, collectionFilter=None):
    rawAuidList = getAUIDList(lockssURL, name, password)
    auidList = []
    if collectionFilter:
        regObject = re.compile(collectionFilter)
        for auid in rawAuidList:
            if regObject.match(auid):
                auidList.append(auid)
    else:
        auidList = rawAuidList
        
    totalSize = 0L
    collectedAuids = []
    for auid in auidList:
        auidTotal = 0L
        fileString = getFileString(lockssURL, auid, name, password)
        fileDictList = makeFileDictList(fileString, "")
        for fileDict in fileDictList:
            auidTotal = auidTotal + fileDict["size"]
        if totalSize + auidTotal > limit:
            break
        totalSize = totalSize + auidTotal
        collectedAuids.append(auid)
    
    return collectedAuids
コード例 #2
0
ファイル: locksstool.py プロジェクト: MetaArchive/educopia
def setupState(lockssURL, name, password, remoteDir, workingDir, stateFile, logFile, filter=None):
    """
    Build our initial state for running a transfer
    """
    state = {}
    rawAuidList = getAUIDList(lockssURL, name, password)
    filteredAuidList = []
    if filter:
        regObject = re.compile(filter)
        for auid in rawAuidList:
            #if auid.startswith(filter):
            if regObject.match(auid):
                filteredAuidList.append(auid)
        state["auidList"] = filteredAuidList
    else:
       state["auidList"] = rawAuidList
    state["failList"] = []
    state["completedList"] = []
    state["workingDir"] = workingDir
    state["logFile"] = logFile
    state["remoteDir"] = remoteDir
    state["filter"] = filter
    
    fileOb = open(stateFile, "w") 
    pickle.dump(state, fileOb)
    fileOb.close()
コード例 #3
0
ファイル: locksstool.py プロジェクト: MetaArchive/educopia
def calculateSize(lockssURL, name, password, collectionFilter):
    rawAuidList = getAUIDList(lockssURL, name, password)
    print("Total number of AUIDs in LOCKSS cache is %s" % len(rawAuidList))
    auidList = []
    for auid in rawAuidList:
        if auid.startswith(collectionFilter):
            auidList.append(auid)
    print("Number of AUIDs that begin with '%s'is %s" % (collectionFilter, len(auidList)))
    totalSize = 0L
    for auid in auidList:
        auidTotal = 0L
        fileString = getFileString(lockssURL, auid, name, password)
        fileDictList = makeFileDictList(fileString, "")
        for fileDict in fileDictList:
            auidTotal = auidTotal + fileDict["size"]
        print("Size of files in auid %s is %s" % (auid, auidTotal))
        totalSize = totalSize + auidTotal
            
    return totalSize