Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion commodore/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import namedtuple
from pathlib import Path as P

Component = namedtuple('Component', ['name', 'repo', 'version'])

Expand All @@ -7,7 +8,13 @@ class Config:
# pylint: disable=too-many-arguments
def __init__(self, api_url, api_token, global_git, customer_git, verbose):
self.api_url = api_url
self.api_token = api_token
self.api_token = None
if api_token is not None:
p = P(api_token)
Comment thread
srueg marked this conversation as resolved.
if p.is_file():
with open(p) as apitoken:
api_token = apitoken.read()
self.api_token = api_token.strip()
self.global_git_base = global_git
self.customer_git_base = customer_git
self._components = {}
Expand Down
4 changes: 2 additions & 2 deletions commodore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def lieutenant_query(api_url, api_token, api_endpoint, api_id):
try:
r.raise_for_status()
except HTTPError as e:
extra_msg = ''
extra_msg = '.'
if r.status_code >= 400:
extra_msg = f": {resp['reason']}"
raise ApiError(f"API returned {r.status_code}. Reason: {extra_msg}") from e
raise ApiError(f"API returned {r.status_code}{extra_msg}") from e
else:
return resp

Expand Down