|
|
@ -25,6 +25,16 @@ def api(route, ref=None): |
|
|
|
return r.json() |
|
|
|
return r.json() |
|
|
|
except KeyboardInterrupt: |
|
|
|
except KeyboardInterrupt: |
|
|
|
raise |
|
|
|
raise |
|
|
|
|
|
|
|
except BaseException as e: |
|
|
|
|
|
|
|
logging.error('Problem hitting hackernews API: {}, trying again'.format(str(e))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
r = requests.get(route(ref), timeout=15) |
|
|
|
|
|
|
|
if r.status_code != 200: |
|
|
|
|
|
|
|
raise Exception('Bad response code ' + str(r.status_code)) |
|
|
|
|
|
|
|
return r.json() |
|
|
|
|
|
|
|
except KeyboardInterrupt: |
|
|
|
|
|
|
|
raise |
|
|
|
except BaseException as e: |
|
|
|
except BaseException as e: |
|
|
|
logging.error('Problem hitting hackernews API: {}'.format(str(e))) |
|
|
|
logging.error('Problem hitting hackernews API: {}'.format(str(e))) |
|
|
|
return False |
|
|
|
return False |
|
|
|