Commit 865024f1 authored by Vasilis Tsiligiannis's avatar Vasilis Tsiligiannis

Handle HTTP error exceptions

Signed-off-by: Vasilis Tsiligiannis's avatarVasilis Tsiligiannis <acinonyx@openwrt.gr>
parent c0d2f404
Pipeline #83492639 passed with stages
in 7 minutes and 48 seconds
......@@ -189,10 +189,10 @@ class Observer(object):
except requests.exceptions.RequestException as err:
LOGGER.error('%s: Unexpected error: %s', url, err)
if resp.status_code == 200:
LOGGER.info('Success: status code 200')
else:
LOGGER.error('Bad status code: %s', resp.status_code)
try:
resp.raise_for_status()
except requests.exceptions.HTTPError as http_error:
LOGGER.error(http_error)
def run_rot(self):
self.tracker_rot = WorkerTrack(ip=self.rot_ip,
......
......@@ -164,8 +164,11 @@ def get_jobs():
verify=settings.SATNOGS_VERIFY_SSL,
timeout=45)
if not response.status_code == 200:
raise Exception('Status code: {0} on request: {1}'.format(response.status_code, url))
try:
response.raise_for_status()
except requests.exceptions.HTTPError as http_error:
LOGGER.error(http_error)
return
latest_jobs = [str(job['id']) for job in response.json()]
for job in SCHEDULER.get_jobs():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment