Exemple #1
0
    def __init__(self, currentPath, UUID=""):
        self.unitType = "Transfer"
        # Just use the end of the directory name
        self.pathString = "%transferDirectory%"
        currentPath2 = currentPath.replace(django_settings.SHARED_DIRECTORY, "%sharedPath%", 1)

        if not UUID:
            try:
                transfer = Transfer.objects.get(currentlocation=currentPath2)
                UUID = transfer.uuid
                LOGGER.info('Using existing Transfer %s at %s', UUID, currentPath2)
            except Transfer.DoesNotExist:
                pass

        if not UUID:
            uuidLen = -36
            if isUUID(currentPath[uuidLen - 1:-1]):
                UUID = currentPath[uuidLen - 1:-1]
            else:
                UUID = str(uuid.uuid4())
                self.UUID = UUID
                Transfer.objects.create(uuid=UUID, currentlocation=currentPath2)

        self.currentPath = currentPath2
        self.UUID = UUID
        self.fileList = {}
Exemple #2
0
def decodeMetaDataValue(value, refNode):
    """
    Parse string formatted meta data and return the
    resulting python object.

    Args:
        data: A str representing encoded meta data
    """
    if isinstance(value, dict):
        result = {}
        for k, v in value.iteritems():
            result[k] = decodeMetaDataValue(v, refNode)
        return result
    elif isinstance(value, (list, tuple)):
        return value.__class__(
            [decodeMetaDataValue(v, refNode) for v in value])
    elif utils.isUUID(value):
        return utils.findNodeByUUID(value, refNode)
    else:
        return value
def fetchUUIDFromPath(path):
    # find UUID on end of SIP path
    uuidLen = -36
    if isUUID(path[uuidLen - 1:-1]):
        return path[uuidLen - 1:-1]