mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 10:12:38 +02:00
catch ValueError, simplify try/except on top-level job runs
See https://github.com/freedomofpress/dangerzone/pull/167#discussion_r915757189
This commit is contained in:
parent
6b44db9043
commit
9989ffea37
1 changed files with 10 additions and 19 deletions
|
@ -369,26 +369,17 @@ def main() -> int:
|
||||||
|
|
||||||
converter = DangerzoneConverter()
|
converter = DangerzoneConverter()
|
||||||
|
|
||||||
|
try:
|
||||||
if sys.argv[1] == "document-to-pixels":
|
if sys.argv[1] == "document-to-pixels":
|
||||||
try:
|
converter.document_to_pixels()
|
||||||
job.document_to_pixels()
|
|
||||||
except (RuntimeError, TimeoutError) as e:
|
|
||||||
job.update_progress(str(e), error=True)
|
|
||||||
return 1
|
|
||||||
else:
|
|
||||||
return 0 # Success!
|
|
||||||
|
|
||||||
elif sys.argv[1] == "pixels-to-pdf":
|
elif sys.argv[1] == "pixels-to-pdf":
|
||||||
try:
|
converter.pixels_to_pdf()
|
||||||
job.pixels_to_pdf()
|
except (RuntimeError, TimeoutError, ValueError) as e:
|
||||||
except (RuntimeError, TimeoutError) as e:
|
converter.update_progress(str(e), error=True)
|
||||||
job.update_progress(str(e), error=True)
|
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
return 0 # Success!
|
return 0 # Success!
|
||||||
|
|
||||||
return -1
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
Loading…
Reference in a new issue