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 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 _start_package_transfer_with_auto_approval(transfer, name, path, tmpdir, starting_point, processing_config): """Start a new transfer the new way. This method does not rely on the activeTransfer watched directory. It blocks until the process completes. It does not prompt the user to accept the transfer because we go directly into the next chain link. """ transfer_rel, filepath, path = _determine_transfer_paths( name, path, tmpdir) logger.debug( 'Package %s: determined vars' ' transfer_rel=%s, filepath=%s, path=%s', transfer.pk, transfer_rel, filepath, path) logger.debug( 'Package %s: copying chosen contents from transfer sources' ' (from=%s, to=%s)', transfer.pk, path, transfer_rel) _copy_from_transfer_sources([path], transfer_rel) _copy_processing_config(processing_config, transfer.pk, transfer_rel) logger.debug('Package %s: moving package to processing directory', transfer.pk) _move_to_internal_shared_dir(filepath, django_settings.PROCESSING_DIRECTORY, transfer) logger.debug('Package %s: starting workflow processing', transfer.pk) unit = unitTransfer(path, transfer.pk) jobChain(unit, starting_point.chain, starting_point.link)
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)
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