Merge branch 'py3' into 'master'
Py3 - Format exceptions properly Exceptions need to be explicitly cast as strings before being fed to format() now See merge request !4
This commit is contained in:
commit
3718db5086
@ -82,7 +82,7 @@ class DispatchMessage(generics.GenericAPIView):
|
|||||||
bot.privmsg(action.destination, text)
|
bot.privmsg(action.destination, text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
new_data = copy.deepcopy(message.data)
|
new_data = copy.deepcopy(message.data)
|
||||||
new_data['status'] = "FAILED - {0:s}".format(e)
|
new_data['status'] = "FAILED - {0:s}".format(str(e))
|
||||||
new_message = self.serializer_class(data=new_data)
|
new_message = self.serializer_class(data=new_data)
|
||||||
return Response(new_message.initial_data)
|
return Response(new_message.initial_data)
|
||||||
elif action.type == DispatcherAction.FILE_TYPE:
|
elif action.type == DispatcherAction.FILE_TYPE:
|
||||||
|
@ -95,8 +95,10 @@ class Twitter(Plugin):
|
|||||||
try:
|
try:
|
||||||
tweet = self.twit.show_status(id=status)
|
tweet = self.twit.show_status(id=status)
|
||||||
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source, print_id=print_id)
|
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source, print_id=print_id)
|
||||||
except twython.exceptions.TwythonError as e:
|
except Exception as e:
|
||||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(e))
|
log.error("couldn't obtain status")
|
||||||
|
log.exception(e)
|
||||||
|
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(str(e)))
|
||||||
|
|
||||||
def handle_getuserstatus(self, connection, event, match):
|
def handle_getuserstatus(self, connection, event, match):
|
||||||
"""Get a status for a user. Allows for getting one other than the most recent."""
|
"""Get a status for a user. Allows for getting one other than the most recent."""
|
||||||
@ -130,12 +132,10 @@ class Twitter(Plugin):
|
|||||||
tweet = tweets[-1*index]
|
tweet = tweets[-1*index]
|
||||||
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source,
|
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source,
|
||||||
print_id=print_id)
|
print_id=print_id)
|
||||||
except requests.exceptions.SSLError as ssle:
|
except Exception as e:
|
||||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}, you can maybe try again".format(ssle))
|
log.error("couldn't obtain status")
|
||||||
except twython.exceptions.TwythonError as e:
|
log.exception(e)
|
||||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(e))
|
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(str(e)))
|
||||||
except ValueError as e:
|
|
||||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(e))
|
|
||||||
|
|
||||||
def handle_tweet(self, connection, event, match):
|
def handle_tweet(self, connection, event, match):
|
||||||
"""Tweet. Needs authentication."""
|
"""Tweet. Needs authentication."""
|
||||||
@ -151,8 +151,10 @@ class Twitter(Plugin):
|
|||||||
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
||||||
else:
|
else:
|
||||||
return self.bot.reply(event, "Unknown error sending tweet(s).")
|
return self.bot.reply(event, "Unknown error sending tweet(s).")
|
||||||
except twython.exceptions.TwythonError as e:
|
except Exception as e:
|
||||||
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(e))
|
log.error("couldn't tweet")
|
||||||
|
log.exception(e)
|
||||||
|
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(str(e)))
|
||||||
|
|
||||||
def handle_replyto(self, connection, event, match):
|
def handle_replyto(self, connection, event, match):
|
||||||
"""Reply to a tweet, in the twitter in_reply_to_status_id sense. Needs authentication."""
|
"""Reply to a tweet, in the twitter in_reply_to_status_id sense. Needs authentication."""
|
||||||
@ -174,8 +176,10 @@ class Twitter(Plugin):
|
|||||||
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
||||||
else:
|
else:
|
||||||
return self.bot.reply(event, "Unknown error sending tweet.")
|
return self.bot.reply(event, "Unknown error sending tweet.")
|
||||||
except twython.exceptions.TwythonError as e:
|
except Exception as e:
|
||||||
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(e))
|
log.error("couldn't tweet")
|
||||||
|
log.exception(e)
|
||||||
|
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(str(e)))
|
||||||
|
|
||||||
def handle_gettoken(self, connection, event, match):
|
def handle_gettoken(self, connection, event, match):
|
||||||
"""Get an oauth token, so that the user may authenticate the bot."""
|
"""Get an oauth token, so that the user may authenticate the bot."""
|
||||||
|
Loading…
Reference in New Issue
Block a user