Skip to content

Commit

Permalink
exception TesseractNotFoundError removed
Browse files Browse the repository at this point in the history
  • Loading branch information
amenezes committed Mar 24, 2022
1 parent cba3b1f commit 1dc2155
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
2 changes: 1 addition & 1 deletion aiopytesseract/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
tesseract_version,
)

__version__ = "0.5.0"
__version__ = "0.5.1"
__all__ = [
"__version__",
"confidence",
Expand Down
48 changes: 21 additions & 27 deletions aiopytesseract/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
OUTPUT_FILE_EXTENSIONS,
TESSERACT_CMD,
)
from .exceptions import TesseractNotFoundError, TesseractRuntimeError
from .exceptions import TesseractRuntimeError
from .returncode import ReturnCode
from .validators import file_exists, language_is_valid, oem_is_valid, psm_is_valid

Expand Down Expand Up @@ -98,19 +98,16 @@ async def _(
user_patterns=user_patterns,
lang=lang,
)
try:
proc = await asyncio.wait_for(
asyncio.create_subprocess_exec(
TESSERACT_CMD,
*cmd_args,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
),
timeout=timeout,
)
except OSError:
raise TesseractNotFoundError(f"{TESSERACT_CMD} not found.")
proc = await asyncio.wait_for(
asyncio.create_subprocess_exec(
TESSERACT_CMD,
*cmd_args,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
),
timeout=timeout,
)
stdout, stderr = await asyncio.wait_for(proc.communicate(image), timeout=timeout)
if proc.returncode != ReturnCode.SUCCESS:
raise TesseractRuntimeError(stderr.decode(encoding))
Expand Down Expand Up @@ -140,19 +137,16 @@ async def execute_multi_output_cmd(
lang=lang,
output=output_file,
)
try:
proc = await asyncio.wait_for(
asyncio.create_subprocess_exec(
TESSERACT_CMD,
*cmd_args,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
),
timeout=timeout,
)
except OSError:
raise TesseractNotFoundError(f"{TESSERACT_CMD} not found.")
proc = await asyncio.wait_for(
asyncio.create_subprocess_exec(
TESSERACT_CMD,
*cmd_args,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
),
timeout=timeout,
)
_, stderr = await asyncio.wait_for(proc.communicate(image), timeout=timeout)
if proc.returncode != ReturnCode.SUCCESS:
raise TesseractRuntimeError(stderr.decode(encoding))
Expand Down
4 changes: 0 additions & 4 deletions aiopytesseract/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
class TesseractNotFoundError(Exception):
pass


class TesseractRuntimeError(RuntimeError):
pass

Expand Down

0 comments on commit 1dc2155

Please sign in to comment.