Post-review fixes
This commit is contained in:
parent
b2a3e5ac70
commit
23ba530ada
@ -1,6 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
albs.py contains ALBS class
|
albs.py contains ALBS class
|
||||||
"""
|
"""
|
||||||
|
from urllib.parse import urljoin
|
||||||
from typing import Union, Dict
|
from typing import Union, Dict
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@ -12,8 +13,6 @@ class ALBS:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, url: str, token: str, timeout: int):
|
def __init__(self, url: str, token: str, timeout: int):
|
||||||
if url.endswith('/'):
|
|
||||||
url = url[:-1]
|
|
||||||
self.url = url
|
self.url = url
|
||||||
self.token = token
|
self.token = token
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
@ -27,13 +26,12 @@ class ALBS:
|
|||||||
endpoint = '/api/v1/platforms/'
|
endpoint = '/api/v1/platforms/'
|
||||||
headers = {'accept': 'application/json',
|
headers = {'accept': 'application/json',
|
||||||
'Authorization': f'Bearer {self.token}'}
|
'Authorization': f'Bearer {self.token}'}
|
||||||
response = requests.get(url=self.url+endpoint,
|
response = requests.get(url=urljoin(self.url, endpoint),
|
||||||
headers=headers,
|
headers=headers,
|
||||||
timeout=self.timeout)
|
timeout=self.timeout)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
res = {}
|
res = {platform['name']: platform['id']
|
||||||
for platform in response.json():
|
for platform in response.json()}
|
||||||
res[platform['name']] = platform['id']
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_errata_status(self, errata_id: str, platform_name: str) -> Union[str, None]:
|
def get_errata_status(self, errata_id: str, platform_name: str) -> Union[str, None]:
|
||||||
@ -60,7 +58,7 @@ class ALBS:
|
|||||||
params = {'id': errata_id, 'platformId': platform_id}
|
params = {'id': errata_id, 'platformId': platform_id}
|
||||||
headers = {'accept': 'application/json',
|
headers = {'accept': 'application/json',
|
||||||
'Authorization': f'Bearer {self.token}'}
|
'Authorization': f'Bearer {self.token}'}
|
||||||
response = requests.get(url=self.url+endpoint,
|
response = requests.get(url=urljoin(self.url, endpoint),
|
||||||
params=params, headers=headers,
|
params=params, headers=headers,
|
||||||
timeout=self.timeout)
|
timeout=self.timeout)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
@ -68,5 +66,5 @@ class ALBS:
|
|||||||
|
|
||||||
# errata_id was not found
|
# errata_id was not found
|
||||||
if response_json['total_records'] == 0:
|
if response_json['total_records'] == 0:
|
||||||
return None
|
return
|
||||||
return response_json['records'][0]['release_status']
|
return response_json['records'][0]['release_status']
|
||||||
|
Loading…
Reference in New Issue
Block a user