Skip to content

Commit

Permalink
chore: use sys.exit instead of raising SystemExit in CLI's modifi…
Browse files Browse the repository at this point in the history
…ed methods
  • Loading branch information
boukeas committed Apr 15, 2024
1 parent 7a71243 commit 5141e9d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions cli/testflinger_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,8 @@ def submit(self):
self.args.filename, encoding="utf-8", errors="ignore"
) as job_file:
data = job_file.read()
except FileNotFoundError as exc:
raise SystemExit(
"File not found: {}".format(self.args.filename)
) from exc
except FileNotFoundError:
sys.exit("File not found: {self.args.filename}")
job_dict = yaml.safe_load(data)

attachments_data = self.extract_attachment_data(job_dict)
Expand Down Expand Up @@ -410,21 +408,21 @@ def submit_job_data(self, data: dict):
job_id = self.client.submit_job(data)
except client.HTTPError as exc:
if exc.status == 400:
raise SystemExit(
sys.exit(
"The job you submitted contained bad data or "
"bad formatting, or did not specify a "
"job_queue."
) from exc
)
if exc.status == 404:
raise SystemExit(
sys.exit(
"Received 404 error from server. Are you "
"sure this is a testflinger server?"
) from exc
)
# This shouldn't happen, so let's get more information
raise SystemExit(
sys.exit(
"Unexpected error status from testflinger "
f"server: {exc.status}"
) from exc
)
return job_id

def submit_job_attachments(self, job_id: str, path: Path):
Expand Down

0 comments on commit 5141e9d

Please sign in to comment.