forked from tanner/qotnews
Alert on story update error
This commit is contained in:
parent
ab92bd5441
commit
249a616531
|
@ -68,6 +68,7 @@ def get_content_type(url):
|
||||||
def update_story(story, is_manual=False):
|
def update_story(story, is_manual=False):
|
||||||
res = {}
|
res = {}
|
||||||
|
|
||||||
|
try:
|
||||||
if story['source'] == 'hackernews':
|
if story['source'] == 'hackernews':
|
||||||
res = hackernews.story(story['ref'])
|
res = hackernews.story(story['ref'])
|
||||||
elif story['source'] == 'lobsters':
|
elif story['source'] == 'lobsters':
|
||||||
|
@ -78,6 +79,10 @@ def update_story(story, is_manual=False):
|
||||||
res = tildes.story(story['ref'])
|
res = tildes.story(story['ref'])
|
||||||
elif story['source'] == 'manual':
|
elif story['source'] == 'manual':
|
||||||
res = manual.story(story['ref'])
|
res = manual.story(story['ref'])
|
||||||
|
except BaseException as e:
|
||||||
|
utils.alert_tanner('Problem updating {} story, ref {}: {}'.format(story['source'], story['ref'], str(e)))
|
||||||
|
logging.exception(e)
|
||||||
|
return False
|
||||||
|
|
||||||
if res:
|
if res:
|
||||||
story.update(res) # join dicts
|
story.update(res) # join dicts
|
||||||
|
|
|
@ -87,7 +87,7 @@ def story(ref):
|
||||||
|
|
||||||
s = {}
|
s = {}
|
||||||
try:
|
try:
|
||||||
s['author'] = r['submitter_user']['username']
|
s['author'] = r['submitter_user']
|
||||||
s['author_link'] = SITE_AUTHOR_LINK(s['author'])
|
s['author_link'] = SITE_AUTHOR_LINK(s['author'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
s['author'] = ''
|
s['author'] = ''
|
||||||
|
|
|
@ -8,6 +8,14 @@ import string
|
||||||
|
|
||||||
from bleach.sanitizer import Cleaner
|
from bleach.sanitizer import Cleaner
|
||||||
|
|
||||||
|
def alert_tanner(message):
|
||||||
|
try:
|
||||||
|
logger.info('Alerting Tanner: ' + message)
|
||||||
|
params = dict(qotnews=message)
|
||||||
|
requests.get('https://tbot.tannercollin.com/message', params=params, timeout=4)
|
||||||
|
except BaseException as e:
|
||||||
|
logger.error('Problem alerting Tanner: ' + str(e))
|
||||||
|
|
||||||
def gen_rand_id():
|
def gen_rand_id():
|
||||||
return ''.join(random.choice(string.ascii_uppercase) for _ in range(4))
|
return ''.join(random.choice(string.ascii_uppercase) for _ in range(4))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user