Permalink
Browse files
Added exception catching for new user?
- Loading branch information...
Showing
with
10 additions
and
6 deletions.
-
+10
−6
User.py
|
|
@@ -61,12 +61,16 @@ def getUserHandle(self): |
|
|
Returns true if a user is currently "active", else false
|
|
|
'''
|
|
|
def isActive(self):
|
|
|
- params = {"token": USER_TOKEN_STRING, "user": self.id}
|
|
|
- response = requests.get("https://slack.com/api/users.getPresence",
|
|
|
- params=params)
|
|
|
- status = json.loads(response.text, encoding='utf-8')["presence"]
|
|
|
-
|
|
|
- return status == "active"
|
|
|
+ try:
|
|
|
+ params = {"token": USER_TOKEN_STRING, "user": self.id}
|
|
|
+ response = requests.get("https://slack.com/api/users.getPresence",
|
|
|
+ params=params)
|
|
|
+ status = json.loads(response.text, encoding='utf-8')["presence"]
|
|
|
+
|
|
|
+ return status == "active"
|
|
|
+ except requests.exceptions.ConnectionError:
|
|
|
+ print "Error fetching online status for " + self.getUserHandle()
|
|
|
+ return False
|
|
|
|
|
|
def addExercise(self, exercise, reps):
|
|
|
# Add to total counts
|
|
|
|
0 comments on commit
5acebc8