Archive WSJ articles first, catch KeyboardInterrupt
This commit is contained in:
@@ -17,6 +17,8 @@ def api(route, ref=None):
|
||||
if r.status_code != 200:
|
||||
raise Exception('Bad response code ' + str(r.status_code))
|
||||
return r.json()
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except BaseException as e:
|
||||
logging.error('Problem hitting hackernews API: {}'.format(str(e)))
|
||||
return False
|
||||
|
@@ -24,6 +24,8 @@ reddit = praw.Reddit('bot')
|
||||
def feed():
|
||||
try:
|
||||
return [x.id for x in reddit.subreddit(SUBREDDITS).hot()]
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except PRAWException as e:
|
||||
logging.error('Problem hitting reddit API: {}'.format(str(e)))
|
||||
return []
|
||||
@@ -70,6 +72,8 @@ def story(ref):
|
||||
|
||||
return s
|
||||
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except PRAWException as e:
|
||||
logging.error('Problem hitting reddit API: {}'.format(str(e)))
|
||||
return False
|
||||
|
@@ -25,6 +25,8 @@ def api(route):
|
||||
if r.status_code != 200:
|
||||
raise Exception('Bad response code ' + str(r.status_code))
|
||||
return r.text
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except BaseException as e:
|
||||
logging.error('Problem hitting tildes website: {}'.format(str(e)))
|
||||
return False
|
||||
|
Reference in New Issue
Block a user