diff options
author | jaseg <git@jaseg.de> | 2022-07-03 22:50:42 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-07-03 22:50:42 +0200 |
commit | 9632509060520a8caa038da3a7c017bcb38130c0 (patch) | |
tree | f8f910d279eaffa0045c00ebf254620dee43fea5 /gerboweb/job_processor.py | |
parent | 58eabf59fe4fb96f02ab5e3e594f86e1b0a817a7 (diff) | |
download | gerbolyze-9632509060520a8caa038da3a7c017bcb38130c0.tar.gz gerbolyze-9632509060520a8caa038da3a7c017bcb38130c0.tar.bz2 gerbolyze-9632509060520a8caa038da3a7c017bcb38130c0.zip |
Bring gerboweb roughly back into shape
Diffstat (limited to 'gerboweb/job_processor.py')
-rw-r--r-- | gerboweb/job_processor.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/gerboweb/job_processor.py b/gerboweb/job_processor.py index c138bf4..a916fd3 100644 --- a/gerboweb/job_processor.py +++ b/gerboweb/job_processor.py @@ -3,6 +3,7 @@ import signal import subprocess import logging import itertools +import tempfile from job_queue import JobQueue @@ -28,13 +29,30 @@ if __name__ == '__main__': for job in job_queue.job_iter('render'): logging.info(f'Processing {job.type} job {job.id} session {job["session_id"]} from {job.client} submitted {job.created}') with job: - job.result = subprocess.call(['sudo', '/usr/local/sbin/gerbolyze_render.sh', job['session_id']]) - logging.info(f'Finishied processing {job.type} job {job.id}') + try: + with tempfile.NamedTemporaryFile(suffix='.svg') as svg: + subprocess.run(['python3', '-m', 'gerbonara', '--top', job['infile'], svg.name], check=True) + subprocess.run(['resvg', '--dpi', '300', svg.name, job['preview_top_out']], check=True) + with tempfile.NamedTemporaryFile(suffix='.svg') as svg: + subprocess.run(['python3', '-m', 'gerbonara', '--bottom', job['infile'], svg.name], check=True) + subprocess.run(['resvg', '--dpi', '300', svg.name, job['preview_bottom_out']], check=True) + subprocess.run(['python3', '-m', 'gerbolyze', 'template', '--top', job['infile'], job['template_top_out']], check=True) + subprocess.run(['python3', '-m', 'gerbolyze', 'template', '--bottom', job['infile'], job['template_bottom_out']], check=True) + logging.info(f'Finishied processing {job.type} job {job.id}') + job.result = True + except: + logging.exception('Error during job processing') + job.result = False for job in job_queue.job_iter('vector'): logging.info(f'Processing {job.type} job {job.id} session {job["session_id"]} from {job.client} submitted {job.created}') with job: - job.result = subprocess.call(['sudo', '/usr/local/sbin/gerbolyze_vector.sh', job['session_id'], job['side']]) - logging.info(f'Finishied processing {job.type} job {job.id}') + try: + subprocess.run(['python3', '-m', 'gerbolyze', 'paste', job['gerber_in'], job['overlay'], job['gerber_out']], check=True) + logging.info(f'Finishied processing {job.type} job {job.id}') + job.result = True + except: + logging.exception('Error during job processing') + job.result = False logging.info('Caught SIGINT. Exiting.') |