From 0589cbfd8784239ff26b6afbc8fc47c99eff85ca Mon Sep 17 00:00:00 2001 From: Claus Juhl Knudsen Date: Wed, 8 Feb 2023 09:12:19 +0100 Subject: [PATCH] Using sys.exit() instead of just exit() --- pyproject.toml | 2 +- smart_client/main.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3213cd3..942e560 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "smart-client" -version = "0.1.6" +version = "0.1.7" description = "Klient til Smartarkivering.dk-submissions" authors = ["Claus Juhl Knudsen "] include = ["pyproject.toml"] diff --git a/smart_client/main.py b/smart_client/main.py index 663d312..7adcd37 100644 --- a/smart_client/main.py +++ b/smart_client/main.py @@ -1,5 +1,6 @@ from http.client import HTTPException import os +import sys import locale import hashlib import json @@ -264,7 +265,7 @@ def main() -> None: try: config.load_configuration() except (FileNotFoundError, ValueError) as e: - exit(e) + sys.exit(e) # Setup parser cli: GooeyParser = GooeyParser(description="Smartarkivering") @@ -274,35 +275,35 @@ def main() -> None: try: uuid.UUID(args.uuid) except ValueError as e: - exit("FEJL. Det indtastede uuid har ikke det korrekte format.") + sys.exit("FEJL. Det indtastede uuid har ikke det korrekte format.") if not Path(args.destination).is_dir(): - exit("FEJL. Destinationen skal være en eksisterende mappe.") + sys.exit("FEJL. Destinationen skal være en eksisterende mappe.") out_dir = Path(args.destination, args.uuid) try: out_dir.mkdir(parents=True, exist_ok=True) except Exception as e: - exit(f"FEJl. Kan ikke oprette destinationsmappen: {e}") + sys.exit(f"FEJl. Kan ikke oprette destinationsmappen: {e}") # Fetch submission info try: # get_submission_info prints any errors with http or json-parsing submission: dict = get_submission_info(args.uuid) except (Exception) as e: - exit(e) + sys.exit(e) # extract info on uploaded files try: fileinfo: list[dict] = extract_filelist(submission) except ValueError: - exit("FEJL. Afleveringen indeholder ingen filreferencer") + sys.exit("FEJL. Afleveringen indeholder ingen filreferencer") # download attached files try: download_files(fileinfo, out_dir) except (Exception) as e: - exit(e) + sys.exit(e) # update fileinfo hash = "md5" if args.md5 else "sha256"