diff options
| author | jason | 2016-09-06 18:50:19 -0600 |
|---|---|---|
| committer | jason | 2016-09-06 18:50:19 -0600 |
| commit | 2497a398a916fdacf5540ca6a2c60fc3c8d29e7f (patch) | |
| tree | 9672b293723cd78b0c02c3d559d7beda2231f736 | |
| parent | 13bc4770fd7f314debd0e16b4ae52f68b6779330 (diff) | |
| download | warmachine-ng-2497a398a916fdacf5540ca6a2c60fc3c8d29e7f.tar.gz warmachine-ng-2497a398a916fdacf5540ca6a2c60fc3c8d29e7f.zip | |
Don't crash when getting an unknown error from Slack
- Slack takes their site down to do database migrations and returns an
api error while this is happening. This catches the error when
authenticating and returns so that it can (hopefully) continue to
reconnect.
| -rw-r--r-- | warmachine/connections/slack.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/warmachine/connections/slack.py b/warmachine/connections/slack.py index 26113b9..116a540 100644 --- a/warmachine/connections/slack.py +++ b/warmachine/connections/slack.py | |||
| @@ -4,6 +4,7 @@ import logging | |||
| 4 | from pprint import pformat | 4 | from pprint import pformat |
| 5 | from urllib.parse import urlencode | 5 | from urllib.parse import urlencode |
| 6 | import urllib.request | 6 | import urllib.request |
| 7 | import sys | ||
| 7 | 8 | ||
| 8 | import websockets | 9 | import websockets |
| 9 | 10 | ||
| @@ -46,7 +47,11 @@ class SlackWS(Connection): | |||
| 46 | return md5(self.token.encode()).hexdigest() | 47 | return md5(self.token.encode()).hexdigest() |
| 47 | 48 | ||
| 48 | async def connect(self): | 49 | async def connect(self): |
| 49 | self.host = self.authenticate() | 50 | try: |
| 51 | self.host = self.authenticate() | ||
| 52 | except Exception: | ||
| 53 | self.log.exception('Error authenticating to slack') | ||
| 54 | return | ||
| 50 | self.log.info('Connecting to {}'.format(self.host)) | 55 | self.log.info('Connecting to {}'.format(self.host)) |
| 51 | self.ws = await websockets.connect(self.host) | 56 | self.ws = await websockets.connect(self.host) |
| 52 | self.STATUS = CONNECTED | 57 | self.STATUS = CONNECTED |