コード例 #1
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)
コード例 #2
0
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)
コード例 #3
0
ファイル: package.py プロジェクト: IISH/archivematica
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)
コード例 #4
0
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)
コード例 #5
0
    def __init__(self, jobChainLink, pk, unit):
        super(linkTaskManagerChoice, self).__init__(jobChainLink, pk, unit)
        self.choices = []
        self.delayTimerLock = threading.Lock()
        self.delayTimer = None

        choices = MicroServiceChainChoice.objects.filter(
            choiceavailableatlink_id=str(jobChainLink.pk))
        for choice in choices:
            self.choices.append(
                (choice.chainavailable_id, choice.chainavailable.description))

        preConfiguredChain = self.checkForPreconfiguredXML()
        if preConfiguredChain != None:
            time.sleep(
                archivematicaMCP.config.getint('MCPServer',
                                               "waitOnAutoApprove"))
            self.jobChainLink.setExitMessage("Completed successfully")
            jobChain.jobChain(self.unit, preConfiguredChain)

        else:
            choicesAvailableForUnitsLock.acquire()
            if self.delayTimer == None:
                self.jobChainLink.setExitMessage('Awaiting decision')
            choicesAvailableForUnits[self.jobChainLink.UUID] = self
            choicesAvailableForUnitsLock.release()
コード例 #6
0
    def __init__(self, jobChainLink, pk, unit):
        """Used to get a selection, from a list of chains, to process"""
        self.choices = []
        self.pk = pk
        self.jobChainLink = jobChainLink
        self.UUID = uuid.uuid4().__str__()
        self.unit = unit
        self.delayTimerLock = threading.Lock()
        self.delayTimer = None
        sql = """SELECT chainAvailable, description FROM MicroServiceChainChoice JOIN MicroServiceChains on chainAvailable = MicroServiceChains.pk WHERE choiceAvailableAtLink = '%s' ORDER BY MicroServiceChainChoice.pk;""" % (jobChainLink.pk.__str__())
        c, sqlLock = databaseInterface.querySQL(sql)
        row = c.fetchone()
        while row != None:
            print row
            chainAvailable = row[0]
            description = row[1]
            self.choices.append((chainAvailable, description,))
            row = c.fetchone()
        sqlLock.release()

        preConfiguredChain = self.checkForPreconfiguredXML()
        if preConfiguredChain != None:
            time.sleep(archivematicaMCP.config.getint('MCPServer', "waitOnAutoApprove"))
            self.jobChainLink.setExitMessage("Completed successfully")
            jobChain.jobChain(self.unit, preConfiguredChain)

        else:
            choicesAvailableForUnitsLock.acquire()
            if self.delayTimer == None:
                self.jobChainLink.setExitMessage('Awaiting decision')
            choicesAvailableForUnits[self.jobChainLink.UUID] = self
            choicesAvailableForUnitsLock.release()
コード例 #7
0
 def proceedWithChoice(self, chain, delayTimerStart=False):
     choicesAvailableForUnitsLock.acquire()
     del choicesAvailableForUnits[self.jobChainLink.UUID]
     self.delayTimerLock.acquire()
     if self.delayTimer != None and not delayTimerStart:
         self.delayTimer.cancel()
         self.delayTimer = None
     self.delayTimerLock.release()
     choicesAvailableForUnitsLock.release()
     self.jobChainLink.setExitMessage("Completed successfully")
     jobChain.jobChain(self.unit, chain)
コード例 #8
0
 def proceedWithChoice(self, chain, agent, delayTimerStart=False):
     if agent:
         self.unit.setVariable("activeAgent", agent, None)
     choicesAvailableForUnitsLock.acquire()
     del choicesAvailableForUnits[self.jobChainLink.UUID]
     self.delayTimerLock.acquire()
     if self.delayTimer != None and not delayTimerStart:
         self.delayTimer.cancel()
         self.delayTimer = None
     self.delayTimerLock.release()
     choicesAvailableForUnitsLock.release()
     self.jobChainLink.setExitMessage("Completed successfully")
     jobChain.jobChain(self.unit, chain)
コード例 #9
0
    def proceedWithChoice(self, chain, user_id, delayTimerStart=False):
        if user_id is not None:
            agent_id = UserProfile.objects.get(user_id=int(user_id)).agent_id
            agent_id = str(agent_id)
            self.unit.setVariable("activeAgent", agent_id, None)

        choicesAvailableForUnitsLock.acquire()
        del choicesAvailableForUnits[self.jobChainLink.UUID]
        self.delayTimerLock.acquire()
        if self.delayTimer is not None and not delayTimerStart:
            self.delayTimer.cancel()
            self.delayTimer = None
        self.delayTimerLock.release()
        choicesAvailableForUnitsLock.release()
        self.jobChainLink.setExitMessage(Job.STATUS_COMPLETED_SUCCESSFULLY)
        LOGGER.info('Using user selected chain %s', chain)
        jobChain.jobChain(self.unit, chain)
コード例 #10
0
    def __init__(self, jobChainLink, unit):
        super(linkTaskManagerChoice, self).__init__(jobChainLink, unit)

        self.delayTimerLock = threading.Lock()
        self.delayTimer = None

        self._populate_choices()

        preConfiguredChain = self.checkForPreconfiguredXML()
        if preConfiguredChain is not None:
            time.sleep(django_settings.WAIT_ON_AUTO_APPROVE)
            self.jobChainLink.setExitMessage(Job.STATUS_COMPLETED_SUCCESSFULLY)
            chain = self.jobChainLink.workflow.get_chain(preConfiguredChain)
            jobChain.jobChain(self.unit, chain, jobChainLink.workflow)
        else:
            choicesAvailableForUnitsLock.acquire()
            if self.delayTimer is None:
                self.jobChainLink.setExitMessage(Job.STATUS_AWAITING_DECISION)
            choicesAvailableForUnits[self.jobChainLink.UUID] = self
            choicesAvailableForUnitsLock.release()
コード例 #11
0
    def __init__(self, jobChainLink, pk, unit):
        """Used to get a selection, from a list of chains, to process"""
        self.choices = []
        self.pk = pk
        self.jobChainLink = jobChainLink
        self.UUID = uuid.uuid4().__str__()
        self.unit = unit
        self.delayTimerLock = threading.Lock()
        self.delayTimer = None
        sql = """SELECT chainAvailable, description FROM MicroServiceChainChoice JOIN MicroServiceChains on chainAvailable = MicroServiceChains.pk WHERE choiceAvailableAtLink = '%s' ORDER BY MicroServiceChainChoice.pk;""" % (
            jobChainLink.pk.__str__())
        c, sqlLock = databaseInterface.querySQL(sql)
        row = c.fetchone()
        while row != None:
            print row
            chainAvailable = row[0]
            description = row[1]
            self.choices.append((
                chainAvailable,
                description,
            ))
            row = c.fetchone()
        sqlLock.release()

        preConfiguredChain = self.checkForPreconfiguredXML()
        if preConfiguredChain != None:
            time.sleep(
                archivematicaMCP.config.getint('MCPServer',
                                               "waitOnAutoApprove"))
            self.jobChainLink.setExitMessage("Completed successfully")
            jobChain.jobChain(self.unit, preConfiguredChain)

        else:
            choicesAvailableForUnitsLock.acquire()
            if self.delayTimer == None:
                self.jobChainLink.setExitMessage('Awaiting decision')
            choicesAvailableForUnits[self.jobChainLink.UUID] = self
            choicesAvailableForUnitsLock.release()
コード例 #12
0
    def __init__(self, jobChainLink, pk, unit):
        super(linkTaskManagerChoice, self).__init__(jobChainLink, pk, unit)
        self.choices = []
        self.delayTimerLock = threading.Lock()
        self.delayTimer = None
        choices = MicroServiceChainChoice.objects.filter(
            choiceavailableatlink_id=str(jobChainLink.pk))
        for choice in choices:
            if choice_is_available(choice, django_settings):
                self.choices.append((choice.chainavailable_id,
                                     choice.chainavailable.description))
        preConfiguredChain = self.checkForPreconfiguredXML()
        if preConfiguredChain is not None:
            time.sleep(django_settings.WAIT_ON_AUTO_APPROVE)
            self.jobChainLink.setExitMessage(Job.STATUS_COMPLETED_SUCCESSFULLY)
            jobChain.jobChain(self.unit, preConfiguredChain)

        else:
            choicesAvailableForUnitsLock.acquire()
            if self.delayTimer is None:
                self.jobChainLink.setExitMessage(Job.STATUS_AWAITING_DECISION)
            choicesAvailableForUnits[self.jobChainLink.UUID] = self
            choicesAvailableForUnitsLock.release()
コード例 #13
0
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)