From b2b66d134482f559922c072f2bddd7e0948207cc Mon Sep 17 00:00:00 2001 From: Shem Pasamba Date: Thu, 17 Dec 2015 11:20:20 +0800 Subject: [PATCH] Don't exit when qpdf repair was successful --- ocrmypdf/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ocrmypdf/main.py b/ocrmypdf/main.py index 7bc4d6ff..a93b7ae6 100755 --- a/ocrmypdf/main.py +++ b/ocrmypdf/main.py @@ -356,14 +356,20 @@ def repair_pdf( try: out = check_output(args_qpdf, stderr=STDOUT, universal_newlines=True) except CalledProcessError as e: + exit_with_error = 1 if e.returncode == 2: print("{0}: not a valid PDF, and could not repair it.".format( options.input_file)) print("Details:") print(e.output) + elif e.returncode == 3 and e.output.find("operation succeeded"): + exit_with_error = 0 + out = e.output + print(e.output) else: print(e.output) - sys.exit(ExitCode.input_file) + if exit_with_error == 1: + sys.exit(ExitCode.input_file) log.debug(out)