Skip to content

Commit

Permalink
[app][fix] dont send sys exit
Browse files Browse the repository at this point in the history
  • Loading branch information
M3ssman committed Aug 28, 2024
1 parent d0e3d0b commit ff75621
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "digiflow"
version = "5.1.2"
version = "5.1.3"
description = "Father's Little Digitization Workflow Helper"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
6 changes: 5 additions & 1 deletion src/digiflow/record/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
State,
Datetime,
)
from .record_service import Client, HandlerInformation, RecordsExhaustedException, run_server
from .record_service import (
Client, HandlerInformation,
RecordsExhaustedException, RecordsServiceException,
run_server
)
10 changes: 6 additions & 4 deletions src/digiflow/record/record_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class RecordsExhaustedException(df_rc.RecordDataException):
achieved anymore"""


class RecordsServiceException(df_rc.RecordDataException):
"""Mark generic exception state"""


class RecordRequestHandler(http.server.SimpleHTTPRequestHandler,
df.FallbackLogger):
"""Simple handler for POST and GET requests
Expand Down Expand Up @@ -234,18 +238,16 @@ def get_record(self, get_record_state, set_record_state):
result = response.content
if status == 404:
# probably nothing to do?
if DATA_EXHAUSTED_MARK in str(result):
if DATA_EXHAUSTED_PREFIX in str(result):
if self.logger is not None:
self.logger.info(result)
raise RecordsExhaustedException(result.decode(encoding='utf-8'))
# otherwise exit anyway
sys.exit(1)

if status != 200:
if self.logger is not None:
self.logger.error(
"server connection status: %s -> %s", status, result)
sys.exit(1)
raise RecordsServiceException(f"Record service error {status} - {result}")

# otherwise response ok
self.record = df_r.Record.parse(response.json())
Expand Down

0 comments on commit ff75621

Please sign in to comment.