Skip to content

Commit

Permalink
better docker error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
carderne committed Feb 5, 2024
1 parent 826fef2 commit dcf0c24
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sigexport/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from sigexport import __version__, templates
from sigexport.models import Contacts, Convos


log = False

DATA_DELIM = "-----DATA-----"
Expand Down Expand Up @@ -563,20 +564,21 @@ def main(
cmd, # NoQA: S603
capture_output=True,
text=True,
check=True,
check=False,
encoding="utf-8",
)
docker_logs_1, data_raw, docker_logs_2 = p.stdout.split(DATA_DELIM)
except FileNotFoundError:
secho("Error: using Docker method, but is Docker installed?", fg=colors.RED)
secho("Try running this from the command line:\ndocker run hello-world")
raise Exit(1)
except subprocess.CalledProcessError as e:
secho(f"Docker process failed, see logs below:\n{e}", fg=colors.RED)
raise Exit(1)
except subprocess.TimeoutExpired:
secho("Docker process timed out.")
raise Exit(1)
try:
docker_logs_1, data_raw, docker_logs_2 = p.stdout.split(DATA_DELIM)
except ValueError:
secho(f"Docker process failed, see logs below:\n{p.stderr}", fg=colors.RED)
raise Exit(1)
try:
data = json.loads(data_raw)
if log:
Expand Down

0 comments on commit dcf0c24

Please sign in to comment.