Exemple #1
0
    def taskGroupFinished(self, finishedTaskGroup):
        finishedTaskGroup.write_output()

        stdout = None
        tasks = finishedTaskGroup.tasks()
        try:
            stdout = tasks[0].results["stdout"]
        except KeyError:
            pass
        LOGGER.debug("stdout emitted by client: %s", stdout)

        try:
            choices = ChoicesDict.fromstring(stdout)
        except Exception:
            LOGGER.exception("Unable to create dic from output %s", stdout)
            choices = ChoicesDict({})
        if self.jobChainLink.passVar is not None:
            if isinstance(self.jobChainLink.passVar, list):
                for index, value in enumerate(self.jobChainLink.passVar):
                    if isinstance(value, ChoicesDict):
                        self.jobChainLink.passVar[index] = choices
                        break
                else:
                    self.jobChainLink.passVar.append(choices)
            else:
                self.jobChainLink.passVar = [
                    choices, self.jobChainLink.passVar
                ]
        else:
            self.jobChainLink.passVar = [choices]

        self.jobChainLink.linkProcessingComplete(
            finishedTaskGroup.calculateExitCode(), self.jobChainLink.passVar)
    def taskCompletedCallBackFunction(self, task):
        databaseFunctions.logTaskCompletedSQL(task)
        try:
            choices = ChoicesDict.fromstring(task.results["stdOut"])
        except Exception:
            LOGGER.exception('Unable to create dic from output %s',
                             task.results['stdOut'])
            choices = ChoicesDict({})
        if self.jobChainLink.passVar is not None:
            if isinstance(self.jobChainLink.passVar, list):
                for index, value in enumerate(self.jobChainLink.passVar):
                    if isinstance(value, ChoicesDict):
                        self.jobChainLink.passVar[index] = choices
                        break
                else:
                    self.jobChainLink.passVar.append(choices)
            else:
                self.jobChainLink.passVar = [
                    choices, self.jobChainLink.passVar
                ]
        else:
            self.jobChainLink.passVar = [choices]

        self.jobChainLink.linkProcessingComplete(task.results["exitCode"],
                                                 self.jobChainLink.passVar)
def test_alternate_choicesdict_constructor():
    d = {"foo": "bar"}
    assert ChoicesDict(d) == ChoicesDict.fromstring(str(d))