mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 02:12:36 +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,25 +369,16 @@ def main() -> int:
|
|||
|
||||
converter = DangerzoneConverter()
|
||||
|
||||
if sys.argv[1] == "document-to-pixels":
|
||||
try:
|
||||
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":
|
||||
try:
|
||||
job.pixels_to_pdf()
|
||||
except (RuntimeError, TimeoutError) as e:
|
||||
job.update_progress(str(e), error=True)
|
||||
return 1
|
||||
else:
|
||||
return 0 # Success!
|
||||
|
||||
return -1
|
||||
try:
|
||||
if sys.argv[1] == "document-to-pixels":
|
||||
converter.document_to_pixels()
|
||||
elif sys.argv[1] == "pixels-to-pdf":
|
||||
converter.pixels_to_pdf()
|
||||
except (RuntimeError, TimeoutError, ValueError) as e:
|
||||
converter.update_progress(str(e), error=True)
|
||||
return 1
|
||||
else:
|
||||
return 0 # Success!
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue