mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 18:22:37 +02:00
qubes: Find out reason of interrupted conversions
If a conversion has been interrupted (usually due to an EOF), figure out why this happened by checking the exit code of the spawned process.
This commit is contained in:
parent
30196ff35b
commit
18b73d94b0
1 changed files with 15 additions and 8 deletions
|
@ -68,7 +68,7 @@ class Qubes(IsolationProvider):
|
||||||
def install(self) -> bool:
|
def install(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _convert(
|
def __convert(
|
||||||
self,
|
self,
|
||||||
document: Document,
|
document: Document,
|
||||||
ocr_lang: Optional[str] = None,
|
ocr_lang: Optional[str] = None,
|
||||||
|
@ -124,13 +124,7 @@ class Qubes(IsolationProvider):
|
||||||
assert self.proc.stdout is not None
|
assert self.proc.stdout is not None
|
||||||
os.set_blocking(self.proc.stdout.fileno(), False)
|
os.set_blocking(self.proc.stdout.fileno(), False)
|
||||||
|
|
||||||
try:
|
|
||||||
n_pages = read_int(self.proc.stdout, timeout)
|
n_pages = read_int(self.proc.stdout, timeout)
|
||||||
except errors.InterruptedConversion:
|
|
||||||
error_code = p.wait()
|
|
||||||
# XXX Reconstruct exception from error code
|
|
||||||
raise exception_from_error_code(error_code) # type: ignore [misc]
|
|
||||||
|
|
||||||
if n_pages == 0:
|
if n_pages == 0:
|
||||||
# FIXME: Fail loudly in that case
|
# FIXME: Fail loudly in that case
|
||||||
return False
|
return False
|
||||||
|
@ -194,6 +188,19 @@ class Qubes(IsolationProvider):
|
||||||
|
|
||||||
return success
|
return success
|
||||||
|
|
||||||
|
def _convert(
|
||||||
|
self,
|
||||||
|
document: Document,
|
||||||
|
ocr_lang: Optional[str] = None,
|
||||||
|
) -> bool:
|
||||||
|
try:
|
||||||
|
return self.__convert(document, ocr_lang)
|
||||||
|
except errors.InterruptedConversion:
|
||||||
|
assert self.proc is not None
|
||||||
|
error_code = self.proc.wait(3)
|
||||||
|
# XXX Reconstruct exception from error code
|
||||||
|
raise errors.exception_from_error_code(error_code) # type: ignore [misc]
|
||||||
|
|
||||||
def get_max_parallel_conversions(self) -> int:
|
def get_max_parallel_conversions(self) -> int:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue