示例#1
0
    def testConfig(self):
        """
        Test that you can run tasks through a config file properly.
        """
        taskHolderLoader = Loader()
        taskHolderLoader.loadFromFile(self.__jsonConfig)
        crawlers = FsCrawler.createFromPath(
            BaseTestCase.dataTestsDirectory()).glob()

        createdCrawlers = []
        for taskHolder in taskHolderLoader.taskHolders():
            self.assertIn('testCustomVar', taskHolder.varNames())
            self.assertEqual(taskHolder.var('testCustomVar'), 'randomValue')
            self.assertRaises(TaskHolderInvalidVarNameError, taskHolder.var,
                              'badVar')
            createdCrawlers += taskHolder.run(crawlers)

        exrCrawlers = list(
            filter(lambda x: isinstance(x, ExrCrawler), createdCrawlers))
        self.assertEqual(len(exrCrawlers), 16)

        jpgCrawlers = list(
            filter(lambda x: isinstance(x, JpgCrawler), createdCrawlers))
        self.assertEqual(len(jpgCrawlers), 1)

        self.cleanup(exrCrawlers + jpgCrawlers)
示例#2
0
 def testConfigurations(self):
     """
     Test if the task holder loader can find the configurations under the directory.
     """
     loader = Loader()
     loader.loadFromDirectory(self.__exampleDirectory)
     self.assertListEqual(
         list(
             sorted(
                 map(lambda x: os.path.basename(x.var('contextConfig')),
                     loader.taskHolders()))),
         list(sorted(['ingestConfig.yaml', 'deliveryConfig.json'])))
示例#3
0
文件: App.py 项目: paulondc/kombi
    def updateConfiguration(self):
        """
        Update the configuration used by kombi.
        """
        taskHolders = []
        currentVisibleCrawlers = self.__visibleCrawlers()

        # choosing a directory picker dialog
        if not self.__configurationDirectory:
            self.__configurationDirectory = self.__configurationDirectoryChooser(
            )
            if not self.__configurationDirectory:
                return

        # collecting task holders from the directory
        taskHolderLoader = Loader()
        try:
            taskHolderLoader.loadFromDirectory(self.__configurationDirectory)
        except Exception as err:
            traceback.print_exc()

            QtWidgets.QMessageBox.critical(
                self.__main, "Kombi",
                "Failed to load the configuration ({0}):\n{1}".format(
                    self.__configurationDirectory,
                    str(err)), QtWidgets.QMessageBox.Ok)

            raise err

        taskHolders = taskHolderLoader.taskHolders()
        if not taskHolders:
            result = QtWidgets.QMessageBox.warning(
                self.__main,
                "Kombi",
                "Selected directory does not contain any configuration for kombi!",
                QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Ok,
            )

            self.__configurationDirectory = ""

            # cancelled
            if result != QtWidgets.QMessageBox.Ok:
                self.__main.deleteLater()
                return False

        self.__updateSourceColumns(taskHolders)

        self.__taskHolders = taskHolders
        self.__onRefreshSourceDir()
        self.__processSourceTreeCrawlersVisibility(currentVisibleCrawlers)

        return True
示例#4
0
    def test02Delivery(self):
        """
        Test the delivery configuration.
        """
        loader = Loader()
        loader.loadFromDirectory(self.__exampleDirectory)

        taskHolder = list(
            filter(
                lambda x: os.path.basename(x.var('contextConfig')) ==
                'deliveryConfig.json', loader.taskHolders()))
        self.assertEqual(len(taskHolder), 1)
        taskHolder = taskHolder[0]

        taskHolder.addVar("prefix", self.__exampleDeliveryPrefixDirectory,
                          True)

        # loading input data for the ingestion
        crawlerGroups = Crawler.group(
            FsCrawler.createFromPath(
                os.path.normpath(
                    os.path.join(
                        self.__exampleIngestionPrefixDirectory,
                        'jobs/foo/seq/abc/shot/def/plates/bla/v001/1920x1080_exr'
                    ))).glob())

        resultCrawlers = []
        for group in crawlerGroups:
            if isinstance(group[0], Crawler.registeredType('plateExr')):
                resultCrawlers += taskHolder.run(group)

        targetFilePaths = list(
            sorted(
                filter(
                    lambda x: len(x),
                    map(
                        lambda x: x.strip(),
                        self.__deliveryGeneratedData.replace(
                            '<date>',
                            datetime.today().strftime('%Y%m%d')).split(
                                '\n')))))
        createdFilePaths = list(
            sorted(
                map(
                    lambda x: x.var('fullPath')[len(
                        self.__exampleDeliveryPrefixDirectory) + 1:].replace(
                            '\\', '/'), resultCrawlers)))

        self.assertListEqual(targetFilePaths, createdFilePaths)
示例#5
0
    def test01Ingestion(self):
        """
        Test the ingestion configuration.
        """
        loader = Loader()
        loader.loadFromDirectory(self.__exampleDirectory)

        taskHolder = list(
            filter(
                lambda x: os.path.basename(x.var('contextConfig')) ==
                'ingestConfig.yaml', loader.taskHolders()))
        self.assertEqual(len(taskHolder), 1)
        taskHolder = taskHolder[0]

        taskHolder.addVar("prefix", self.__exampleIngestionPrefixDirectory,
                          True)

        # loading input data for the ingestion
        crawlerGroups = Crawler.group(
            FsCrawler.createFromPath(
                os.path.join(self.__exampleDirectory,
                             'plates')).globFromParent())

        resultCrawlers = []
        for group in crawlerGroups:
            if isinstance(group[0], Crawler.registeredType('png')):
                resultCrawlers += taskHolder.run(group)

        targetFilePaths = list(
            sorted(
                filter(
                    lambda x: len(x),
                    map(lambda x: x.strip(),
                        self.__ingestedGeneratedData.split('\n')))))
        createdFilePaths = list(
            sorted(
                map(
                    lambda x: x.var('fullPath')[len(
                        self.__exampleIngestionPrefixDirectory) + 1:].replace(
                            '\\', '/'), resultCrawlers)))

        self.assertListEqual(targetFilePaths, createdFilePaths)
示例#6
0
    def testRunConfiguration(self):
        """
        Test execution of the configuration.
        """
        loader = Loader()
        loader.loadFromDirectory(self.__exampleDirectory)

        self.assertEqual(len(loader.taskHolders()), 1)

        taskHolder = loader.taskHolders()[0]

        taskHolder.addVar(
            "prefix",
            self.__exampleTargetPrefixDirectory,
            True
        )

        # loading input data for the execution
        crawlerGroups = Crawler.group(
            FsCrawler.createFromPath(
                os.path.join(self.__exampleDirectory, 'imageSequence')
            ).globFromParent()
        )

        resultCrawlers = []
        for group in crawlerGroups:
            if isinstance(group[0], Crawler.registeredType('png')):
                resultCrawlers += taskHolder.run(group)

        targetFilePaths = list(sorted(filter(lambda x: len(x), map(lambda x: x.strip(), self.__generatedData.split('\n')))))
        createdFilePaths = list(sorted(map(lambda x: x.var('fullPath')[len(self.__exampleTargetPrefixDirectory) + 1:].replace('\\', '/'), resultCrawlers)))

        self.assertListEqual(targetFilePaths, createdFilePaths)
示例#7
0
    def testTaskTemplateOption(self):
        """
        Test that task template option are working properly.
        """
        class MyClawler(Crawler):
            pass

        taskHolderLoader = Loader()
        taskHolderLoader.loadFromFile(self.__jsonConfig)
        dummyCrawler = MyClawler('dummy')
        dummyCrawler.setVar('testCustomVar', 'testValue')

        taskHolders = taskHolderLoader.taskHolders()
        self.assertEqual(len(taskHolders), 1)

        # copy task holder
        extraVars = {'testCustomVar': taskHolders[0].var('testCustomVar')}
        copyTask = taskHolders[0].task()
        self.assertEqual(copyTask.type(), 'copy')

        self.assertEqual(
            copyTask.templateOption('testOption', crawler=dummyCrawler),
            'testValue')
        self.assertEqual(
            copyTask.templateOption('testOption', extraVars=extraVars),
            'randomValue')
        self.assertEqual(copyTask.templateOption('testExpr'), '2')

        # sequence thumbnail task holder
        self.assertEqual(len(taskHolders[0].subTaskHolders()), 1)
        sequenceThumbnailTask = taskHolders[0].subTaskHolders()[0].task()
        sequenceThumbnailTask.setOption('height', "{height}")
        dummyCrawler.setVar('height', 2000)
        self.assertEqual(sequenceThumbnailTask.type(), 'sequenceThumbnail')
        self.assertEqual(sequenceThumbnailTask.option('width'), 640)
        self.assertEqual(
            sequenceThumbnailTask.templateOption('height',
                                                 crawler=dummyCrawler), '2000')
示例#8
0
文件: App.py 项目: paulondc/kombi
    def __onTargetTreeContextMenu(self, point):
        """
        Slot triggered when the context menu in the target tree is triggered.
        """
        selectedIndexes = self.__targetTree.selectionModel().selectedIndexes()
        if selectedIndexes:
            value = selectedIndexes[0].data(0)

            if os.path.splitext(
                    str(value))[-1][1:] in Loader.registeredNames():
                menu = QtWidgets.QMenu(self.__main)
                action = menu.addAction('Show Config')
                action.triggered.connect(
                    functools.partial(self.__launchDefaultApp, value))

                menu.exec_(self.__sourceTree.mapToGlobal(point))
示例#9
0
    def testLoadConfiguration(self):
        """
        Test if the task holder loader can find the configurations under the directory.
        """
        loader = Loader()
        loader.loadFromDirectory(self.__exampleDirectory)

        self.assertEqual(len(loader.taskHolders()), 1)

        self.assertEqual(
            os.path.basename(loader.taskHolders()[0].var('contextConfig')),
            'config.hjson')