Esempio n. 1
0
    def testFilterTemplateCrawlers(self):
        """
        Test that filter template in task holder.
        """
        crawlers = [FsCrawler.createFromPath(self.__jsonConfig)]

        for filterOption in ['0', 'false', 'False']:
            dummyTask = Task.create('checksum')
            taskHolder = TaskHolder(dummyTask, Template(),
                                    Template(filterOption))
            result = taskHolder.run(crawlers)
            self.assertEqual(len(result), 0)
Esempio n. 2
0
    def testFilterTemplateNotApplied(self):
        """
        Test that filter template should not be applied.
        """
        crawlers = [FsCrawler.createFromPath(self.__jsonConfig)]

        for filterOption in ['randomStr', '']:
            dummyTask = Task.create('checksum')

            taskHolder = TaskHolder(dummyTask, Template("{filePath}"),
                                    Template('randomStr'))
            result = taskHolder.run(crawlers)
            self.assertEqual(len(result), len(crawlers))
Esempio n. 3
0
    def testExecuteStatus(self):
        """
        Test execute status in the task holder.
        """
        dummyTask = Task.create('checksum')
        crawlers = [FsCrawler.createFromPath(self.__jsonConfig)]

        taskHolder = TaskHolder(dummyTask, Template("{filePath}"))
        dummyTask2 = Task.create('checksum')
        taskHolder2 = TaskHolder(dummyTask2, Template("{filePath}"))
        taskHolder2.setStatus("execute")
        taskHolder.addSubTaskHolder(taskHolder2)
        self.assertEqual(len(taskHolder.run(crawlers)), len(crawlers) * 2)
Esempio n. 4
0
def __run(data):
    """
    Execute the taskHolder.
    """
    # loading task holder and running it
    with open(data) as f:
        taskHolder = TaskHolder.createFromJson(f.read())

        # executing run
        taskHolder.run()
Esempio n. 5
0
def __run(dataJsonFile, rangeStart=None, rangeEnd=None):
    """
    Execute the taskHolder.
    """
    data = {}
    with open(dataJsonFile) as jsonFile:
        data = json.load(jsonFile)

    # loading task holder
    taskHolder = TaskHolder.createFromJson(data['taskHolder'])

    if data['jobType'] == "collapsed":
        __runCollapsed(data, taskHolder, dataJsonFile)

    elif data['jobType'] == "expanded":
        __runExpanded(data, taskHolder, rangeStart, rangeEnd)

    else:
        raise Exception("Invalid execution type: {}".format(data['jobType']))