error handling and deployment
parent
9a7eeef600
commit
1293861b0a
|
@ -28,11 +28,19 @@ class MastodonBot(Bot):
|
|||
except mastodon.MastodonNetworkError:
|
||||
logger.error("Mastodon Network Error.")
|
||||
return mentions
|
||||
except mastodon.MastodonAPIError:
|
||||
try:
|
||||
logger.error("Mastodon API Error: " + m.instance()['urls']['streaming_api'] + ", city: " + str(user.uid))
|
||||
except mastodon.MastodonServerError:
|
||||
logger.error("Mastodon Server Error 500, can't get instance.")
|
||||
return mentions
|
||||
except mastodon.MastodonInternalServerError:
|
||||
try:
|
||||
logger.error("Mastodon Error: 500. Server: " + m.instance()['urls']['streaming_api'])
|
||||
except mastodon.MastodonServerError:
|
||||
logger.error("Mastodon Server Error 500, can't get instance.")
|
||||
except mastodon.MastodonVersionError:
|
||||
logger.error("Mastodon Server Error 500, server version too low.")
|
||||
return mentions
|
||||
except mastodon.MastodonBadGatewayError:
|
||||
try:
|
||||
|
@ -59,6 +67,7 @@ class MastodonBot(Bot):
|
|||
logger.error("Unknown Mastodon Server Error.", exc_info=True)
|
||||
return mentions
|
||||
for status in notifications:
|
||||
try:
|
||||
if (status['type'] == 'mention' and
|
||||
not user.toot_is_seen(status['status']['uri'])):
|
||||
# save state
|
||||
|
@ -80,6 +89,8 @@ class MastodonBot(Bot):
|
|||
text,
|
||||
status['status']['id'],
|
||||
status['status']['created_at']))
|
||||
except TypeError:
|
||||
pass
|
||||
return mentions
|
||||
|
||||
def post(self, user, report):
|
||||
|
|
|
@ -67,7 +67,7 @@ class TwitterBot(Bot):
|
|||
except requests.exceptions.ConnectionError:
|
||||
logger.error("Twitter API Error: Bad Connection", exc_info=True)
|
||||
except tweepy.TweepError:
|
||||
logger.error("Twitter API Error: General Error", exc_info=True)
|
||||
logger.error("Twitter API Error: General Error. User: " + str(user.uid), exc_info=True)
|
||||
return []
|
||||
|
||||
def post(self, user, report):
|
||||
|
|
|
@ -12,6 +12,8 @@ KillSignal=SIGQUIT
|
|||
Type=notify
|
||||
StandardError=syslog
|
||||
NotifyAccess=all
|
||||
User=tech
|
||||
Group=www-data
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
Loading…
Reference in New Issue