Example #1
0
    def process(self):
        # foo = processing.ListProgress2(self, self.data['package'])
        # foo.logger = lambda x: self.logger.log("Zipping : {}".format(x))
        # lambda l: self.logger.log("{}{}".format(datetime.datetime.now(), l)))

        if self.data['workflow'] == "DS":
            processing_workflow = workflow.Workflow(workflow.DSWorkflow())
        elif self.data['workflow'] == "BrittleBooks":
            processing_workflow = workflow.Workflow(
                workflow.BrittleBooksWorkflow())
        else:
            raise Exception("Unknown workflow, {}".format(
                self.data['workflow']))
        tasks = processing_workflow.zip(self.data['package'],
                                        self.data['export_destination'])
        processing_window = processing.ListCallableProgress(
            self, tasks=tasks, task_name="Zipping")
        processing_window.logger = self.logger.log
        try:
            self.logger.log("Zipping process started")
            processing_window.process()
            self.logger.log("Zipping completed.")
            self.logger.log("Files can be found at {}".format(
                self.data['export_destination']))
        except processing.ProcessCanceled:
            return False
        return True
Example #2
0
def test_ds_item_len(ds_collection_root):
    strategy = workflow.DSWorkflow()
    package_builder = workflow.Workflow(strategy)
    my_collection = package_builder.build_package(ds_collection_root)
    my_object = my_collection[0]
    my_item = my_object[0]
    assert len(my_item) == 1
Example #3
0
    def process(self):
        if self.data['workflow'] == "DS":
            processing_workflow = workflow.Workflow(workflow.DSWorkflow())
        elif self.data['workflow'] == "BrittleBooks":
            processing_workflow = workflow.Workflow(
                workflow.BrittleBooksWorkflow())
        else:
            raise Exception("Unknown workflow, {}".format(
                self.data['workflow']))
        tasks = processing_workflow.validate(self.data['package'])
        processing_window = processing.ListCallableProgress(
            self, tasks=tasks, task_name="Validating")

        processing_window.logger = self.logger.log
        try:
            self.logger.log("Validation started")
            processing_window.process()
            self.logger.log("Validation completed")

        except processing.ProcessCanceled:
            return False
        message = self.build_report(processing_window.results)

        self.logger.log(message)
        return True
Example #4
0
def test_ds_instantiations(ds_collection_root):
    strategy = workflow.DSWorkflow()
    package_builder = workflow.Workflow(strategy)
    my_package = package_builder.build_package(ds_collection_root)
    my_object = my_package[0]
    my_item = my_object[0]
    my_instantiation = my_item.instantiations["access"]
    assert my_instantiation.metadata['category'] == "access"
    pprint(dict(my_instantiation.metadata))
    print(my_instantiation)
    def __init__(self, parent=None):
        super().__init__(parent)
        self.data = {
            "workflow": "DS"
        }
        self.addPage(HathiWizardPages["PackageBrowser"].wizard_page(self))
        self.addPage(HathiWizardPages["EndPage"].wizard_page(self))
        self.data["root"] = ROOT
        workflow_strat = workflow.DSWorkflow()

        # package_builder = collection_builder.BuildPackage(workflow_strat)
        package_builder = workflow.Workflow(workflow_strat)
        self.data["package"] = package_builder.build_package(ROOT)
 def build_package(self, root):
     if self.data['workflow'] == "DS":
         workflow_strats = workflow.DSWorkflow()
     elif self.data['workflow'] == "BrittleBooks":
         workflow_strats = workflow.BrittleBooksWorkflow()
     else:
         raise Exception("Unknown workflow {}".format(
             self.data['workflow']))
     # package_builder = collection_builder.BuildPackage(workflow_strats)
     package_builder = workflow.Workflow(workflow_strats)
     print("Loading")
     package_locator = LocatingPackagesDialog(package_builder, root)
     package_locator.exec_()
     # self.data
     return package_locator.package
Example #7
0
    def process(self):
        self.logger.log("Processing")
        if self.data['workflow'] == "DS":
            processing_workflow = workflow.Workflow(workflow.DSWorkflow())
        else:
            raise Exception("invalid workflow, {}".format(
                self.data['workflow']))

        tasks = processing_workflow.prep(self.data['package'])
        processing_window = processing.ListCallableProgress(
            self, tasks=tasks, task_name="Prepping")
        processing_window.logger = self.logger.log
        try:

            self.logger.log("Prep started")
            processing_window.process()
            self.logger.log("Prep completed")
        except processing.ProcessCanceled:
            return False
        return True
Example #8
0
    def process(self):
        self.logger.log("Processing")
        if self.data['workflow'] == "DS":
            processing_workflow = workflow.Workflow(workflow.DSWorkflow())
        else:
            raise Exception("invalid workflow, {}".format(
                self.data['workflow']))
        tasks = processing_workflow.qc(self.data['package'])
        processing_window = processing.ListCallableProgress(
            self, tasks=tasks, task_name="Performing QC")
        try:
            self.logger.log("QC started")
            processing_window.process()
            report = self._create_report(processing_window.results)
            self.logger.log("QC ended")

            self.logger.log("{}\n".format(report))

        except processing.ProcessCanceled:
            return False
        return True
def test_prep(ds_collection):
    ds_workflow = workflow.Workflow(workflow.DSWorkflow())
    new_package = ds_workflow.build_package(ds_collection)

    new_package.children[0].component_metadata["title_page"] = "00000002.jp2"
    new_package.children[1].component_metadata["title_page"] = "00000002.jp2"
    new_package.children[2].component_metadata["title_page"] = "00000002.jp2"

    for task in ds_workflow.prep(new_package):
        task()
    prepped_package = ds_workflow.build_package(new_package.path)
    errors = []

    for package_object in prepped_package:
        path = package_object.metadata['path']
        meta = os.path.join(path, "meta.yml")
        assert os.path.exists(meta)
        with open(meta, "r") as f:
            yaml = f.read()
            if """    00000002.jp2:
        label: TITLE""" not in yaml:
                pytest.fail("missing title_page in {}".format(meta))

    tasks = ds_workflow.validate(prepped_package)
    for task in tasks:
        errors += task()

    for error in errors:
        print(error)
    assert len(errors) == 0
    with tempfile.TemporaryDirectory() as temp_destination:
        for task in ds_workflow.zip(prepped_package, temp_destination):
            task()
        assert os.path.exists(os.path.join(temp_destination, "1564651.zip"))
        assert os.path.exists(os.path.join(temp_destination, "4564654.zip"))
        assert os.path.exists(os.path.join(temp_destination, "7213538.zip"))
Example #10
0
def test_ds_object_id(ds_collection_root):
    strategy = workflow.DSWorkflow()
    package_builder = workflow.Workflow(strategy)
    my_collection = package_builder.build_package(ds_collection_root)
    my_object = my_collection[0]
    assert my_object.metadata['id'] == "1564651"
Example #11
0
def test_ds_package_len(ds_collection_root):
    strategy = workflow.DSWorkflow()
    package_builder = workflow.Workflow(strategy)
    my_collection = package_builder.build_package(ds_collection_root)
    assert len(my_collection) == 3
Example #12
0
def test_ds_collection_strategy(ds_collection_root):
    strategy = workflow.DSWorkflow()
    package_builder = workflow.Workflow(strategy)
    my_collection = package_builder.build_package(ds_collection_root)
    assert isinstance(my_collection, collection.Package)