From e8dbcb1d14ef80445ca8bae06cce245c26bad4a6 Mon Sep 17 00:00:00 2001 From: codl Date: Tue, 5 Sep 2017 00:08:23 +0200 Subject: [PATCH] oops!!!!! --- lib/twitter.py | 20 ++++++++------------ tasks.py | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/twitter.py b/lib/twitter.py index 55e6ade..53b791f 100644 --- a/lib/twitter.py +++ b/lib/twitter.py @@ -9,7 +9,6 @@ from zipfile import ZipFile from io import BytesIO from lib.exceptions import PermanentError, TemporaryError from urllib.error import URLError -import json def get_login_url(callback='oob', consumer_key=None, consumer_secret=None): @@ -213,15 +212,12 @@ def chunk_twitter_archive(archive_id): def handle_error(e): if isinstance(e, TwitterHTTPError): - try: - data = json.loads(e.read()) - if 'errors' in data.keys(): - for error in data['errors']: - if error.get('code') == 326: - # account locked lol rip - # although this is a temporary error in twitter terms - # it's best not to waste api calls on locked accounts - raise PermanentError(e) - except Exception: - pass + data = e.response_data + if isinstance(data, dict) and 'errors' in data.keys(): + for error in data['errors']: + if error.get('code',0) == 326: + # account locked lol rip + # although this is a temporary error in twitter terms + # it's best not to waste api calls on locked accounts + raise PermanentError(e) raise TemporaryError(e) diff --git a/tasks.py b/tasks.py index d70c77c..b43179a 100644 --- a/tasks.py +++ b/tasks.py @@ -56,7 +56,7 @@ def make_dormant(acc): it, you have reactivated your account, but be aware that some posts may be missing from Forget's database, and it may take some time to get back in sync. - '''.format(acc.service) + '''.format(service=acc.service) acc.dormant = True db.session.commit()