diff options
author | daniel-Jones <daniel@danieljon.es> | 2017-07-14 10:56:15 +0930 |
---|---|---|
committer | daniel-Jones <daniel@danieljon.es> | 2017-07-14 10:56:15 +0930 |
commit | 3f848ce2c5af2c61b16d6f225820e5c2298e7af4 (patch) | |
tree | 6f6e158b6a5aa09f63df520f3d4522382a42140b | |
parent | 0b06ff3475a454d92a0d0a009a5ebdb9ece05051 (diff) | |
download | slacklog-3f848ce2c5af2c61b16d6f225820e5c2298e7af4.tar.gz slacklog-3f848ce2c5af2c61b16d6f225820e5c2298e7af4.zip |
no longer commiting utf8 encoded string
-rw-r--r-- | main.py | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -21,9 +21,13 @@ def getjson(url): args: url = url to request data from ''' - f = urllib.request.urlopen(url); - content = f.read(); - f.close(); + try: + f = urllib.request.urlopen(url); + content = f.read(); + f.close(); + except urllib.error.URLError: + print("error getting json, api down probably, try later"); + raise SystemExit; return content; def dbconnect(): @@ -163,7 +167,7 @@ def collectbants(): print("message not logged, logging"); query = {"author": author, "channel": j['channels'][x]['name'], - "message": str(data['messages'][i]['text'].encode('utf8')), + "message": str(data['messages'][i]['text']), "timestamp": data['messages'][i]['ts']}; message_id = messagedb.insert_one(query).inserted_id; else: |