def createUnitAndJobChain(path, config, terminate=False): path = unicodeToStr(path) if os.path.isdir(path): path = path + "/" logger.debug('Creating unit and job chain for %s with %s', path, config) unit = None if os.path.isdir(path): if config[3] == "SIP": UUID = findOrCreateSipInDB(path) unit = unitSIP(path, UUID) elif config[3] == "DIP": UUID = findOrCreateSipInDB(path, unit_type='DIP') unit = unitDIP(path, UUID) elif config[3] == "Transfer": unit = unitTransfer(path) elif os.path.isfile(path): if config[3] == "Transfer": unit = unitTransfer(path) else: return UUID = uuid.uuid4() unit = unitFile(path, UUID) else: return jobChain(unit, config[1]) if terminate: exit(0)
def loadExistingFiles(): #Transfers directory = completedTransfersDirectory if not os.path.isdir(directory): os.makedirs(directory) for item in os.listdir(directory): if item == ".svn": continue path = os.path.join(directory, item) if os.path.isdir(path): path = path + "/" unit = unitTransfer(path) addWatchForTransfer(path, unit) #SIPS directory = sipCreationDirectory if not os.path.isdir(directory): os.makedirs(directory) for item in os.listdir(directory): if item == ".svn": continue path = os.path.join(directory, item) if os.path.isdir(path): path = path + "/" UUID = archivematicaMCP.findOrCreateSipInDB(path) unit = unitSIP(path, UUID) addWatchForSIP(path, unit)
def createUnitAndJobChain(path, config, terminate=False): path = unicodeToStr(path) if os.path.isdir(path): path = path + "/" print "createUnitAndJobChain", path, config unit = None if os.path.isdir(path): if config[3] == "SIP": UUID = findOrCreateSipInDB(path) unit = unitSIP(path, UUID) elif config[3] == "DIP": UUID = findOrCreateSipInDB(path) unit = unitDIP(path, UUID) elif config[3] == "Transfer": #UUID = findOrCreateSipInDB(path) unit = unitTransfer(path) elif os.path.isfile(path): if config[3] == "Transfer": unit = unitTransfer(path) else: return UUID = uuid.uuid4() unit = unitFile(path, UUID) else: return jobChain(unit, config[1]) if terminate: exit(0)
def process_IN_MOVED_TO(self, event): #time.sleep(archivematicaMCP.dbWaitSleep) #let db be updated by the microservice that moved it. #print event #print "process_IN_MOVED_TO SIPCreationWatch" path = os.path.join(event.path, event.name) if not os.path.isdir(path): print >>sys.stderr, "Bad path for watching - not a directory: ", path return if os.path.abspath(event.path) == os.path.abspath(completedTransfersDirectory): path = path + "/" unit = unitTransfer(path) addWatchForTransfer(path, unit) elif os.path.abspath(event.path) == os.path.abspath(sipCreationDirectory): path = path + "/" UUID = archivematicaMCP.findOrCreateSipInDB(path, waitSleep=0) unit = unitSIP(path.replace(archivematicaMCP.config.get('MCPServer', "sharedDirectory"), "%sharedPath%", 1), UUID) notifier = addWatchForSIP(path, unit) self.sips[path[:-1]] = notifier else: print >>sys.stderr, "Bad path for watching: ", event.path
def createUnitAndJobChain(path, watched_dir, workflow): path = unicodeToStr(path) if os.path.isdir(path): path = path + "/" logger.debug('Starting chain for %s', path) if not os.path.exists(path): return unit = None unit_type = watched_dir["unit_type"] if os.path.isdir(path): if unit_type == "SIP": UUID = findOrCreateSipInDB(path) unit = unitSIP(path, UUID) elif unit_type == "DIP": UUID = findOrCreateSipInDB(path, unit_type='DIP') unit = unitDIP(path, UUID) elif unit_type == "Transfer": unit = unitTransfer(path) elif os.path.isfile(path): if unit_type == "Transfer": unit = unitTransfer(path) else: return jobChain(unit, watched_dir.chain, workflow)