Example #1
0
 def run(job: Job):
     # TODO add a regex matching for paths and if it's a path, check if the path exists
     if job.status is not Status.VALID:
         return
     job.step = StepType.VALIDATE_DATA
     required_data = getattr(Layouts, job.layout).value.get_required_frame_data()
     for index, frame in enumerate(job.project.storyboard.frames):
         for data in required_data:
             if not frame.get(data, False):
                 job.status = Status.INVALID_DATA
                 if not job.status_data.get("missing_data", False):
                     job.status_data["missing_data"] = dict()
                 job.status_data["missing_data"][str(index)] = missing_data.format(
                     str(index), data
                 )
             else:
                 type_a = type(frame.get(data))
                 type_b = required_data.get(data)
                 if type_a is not type_b:
                     job.status = Status.INVALID_DATA
                     if not job.status_data.get("wrong_data_type", False):
                         job.status_data["wrong_data_type"] = dict()
                     job.status_data["wrong_data_type"][
                         # the structure with a number as string in the dict is dirty
                         # todo Change number as string inside the dict!
                         str(index)
                     ] = wrong_type.format(
                         index, data, type_a.__name__, type_b.__name__
                     )
    def run(job: Job):
        if job.status is not Status.VALID:
            return
        job.step = StepType.COMPILE_TEX
        if not os.path.exists(job.tex_file_path):
            job.status = Status.COMPILE_PDF_ERROR
            job.status_data = dict(
                message=f"The .tex file: {job.tex_file_path} cannot found!")
            return

        base_file_path = f"{job.tex_file_path.replace('.tex', '')}"
        log_file_path = base_file_path + ".log"
        pdf_file_path = base_file_path + ".pdf"
        cmd = [
            f"{latex_compiler}",
            f"-output-directory={job.project.output_directory}",
            "-interaction=nonstopmode",
            f"{job.tex_file_path}",
        ]
        subprocess.run(cmd, stdout=subprocess.PIPE)

        if os.path.exists(pdf_file_path):
            job.pdf_file_path = pdf_file_path
        else:
            job.status = Status.COMPILE_PDF_ERROR
            with open(log_file_path, "r") as log_file:
                log_file_content = log_file.read()
            job.status_data = dict(
                message=f"The .pdf file cannot compiled with the tex file.",
                log_file=log_file_content,
            )
Example #3
0
 def run(job: Job):
     if job.status is not Status.VALID:
         return
     job.step = StepType.VALIDATE_LAYOUT
     if hasattr(LayoutNameReverse, job.layout):
         return hasattr(LayoutName,
                        getattr(LayoutNameReverse, job.layout).value)
     return False
Example #4
0
    def run_job(job: Job, steps: List[Step] = None):
        if not steps:
            job.status_data[
                "job_worker_error"] = "The specified list of steps, is empty or None. The default list will used instead!"
            steps = JobWorker.steps
        for step in steps:
            if job.status is Status.VALID:
                step.run(job)

        if job.status is Status.VALID:
            job.step = StepType.FINISHED