Showing 1 of 2 files from the diff.

@@ -9,7 +9,7 @@
Loading
9 9
import warnings
10 10
11 11
import requests
12 -
from requests.exceptions import RequestException
12 +
from json import JSONDecodeError
13 13
from twython import Twython, TwythonError
14 14
from logzero import logger
15 15
@@ -130,12 +130,16 @@
Loading
130 130
            'site': self.stackexchange['site'],
131 131
            'key': self.stackexchange.get('key', None),
132 132
        }
133 -
        try:
134 -
            r = requests.get(stack_url, params)
135 -
            return r.json()['items']
136 -
        except (KeyError, RequestException) as e:
137 -
            logger.error(f'{e.__class__.__name__}: {e}')
138 -
            return []
133 +
        r = requests.get(stack_url, params)
134 +
        if r.status_code == 200:
135 +
            try:
136 +
                return r.json()['items']
137 +
            except (JSONDecodeError, KeyError) as e:
138 +
                logger.error(f'{e.__class__.__name__}: {e}')
139 +
        else:
140 +
            logger.error(f'Unable to connect to imgflip: status code {r.status_code}')
141 +
        sleep(60)
142 +
        return []
139 143
140 144
    def choose_meme_template(self, text):
141 145
        """
@@ -229,26 +233,33 @@
Loading
229 233
            'text0': text0,
230 234
            'text1': text1,
231 235
        }
232 -
        try:
233 -
            r = requests.post(imgflip_url, data=data)
234 -
            img_url = r.json()['data']['url']
235 -
            return (img_url, meme)
236 -
        except (KeyError, RequestException) as e:
237 -
            logger.error(f'{e.__class__.__name__}: {e}')
238 -
            sleep(30)
239 -
            return self.make_meme(text)
236 +
        r = requests.post(imgflip_url, data=data)
237 +
        if r.status_code == 200:
238 +
            try:
239 +
                img_url = r.json()['data']['url']
240 +
                return (img_url, meme)
241 +
            except (JSONDecodeError, KeyError) as e:
242 +
                logger.error(f'{e.__class__.__name__}: {e}')
243 +
        else:
244 +
            logger.error(f'Unable to connect to imgflip: status code {r.status_code}')
245 +
        sleep(60)
246 +
        return self.make_meme(text)
240 247
241 248
    def tweet(self, status, img_url):
242 249
        "Tweet status with the image attached"
243 -
        try:
244 -
            r = requests.get(img_url)
250 +
        r = requests.get(img_url)
251 +
        if r.status_code == 200:
245 252
            img = BytesIO(r.content)
246 -
            response = self.twitter.upload_media(media=img)
247 -
            media_ids = [response['media_id']]
248 -
            self.twitter.update_status(status=status, media_ids=media_ids)
249 -
        except (RequestException, TwythonError) as e:
250 -
            logger.error(f'{e.__class__.__name__}: {e}')
251 -
            raise
253 +
            try:
254 +
                response = self.twitter.upload_media(media=img)
255 +
                media_ids = [response['media_id']]
256 +
                self.twitter.update_status(status=status, media_ids=media_ids)
257 +
            except TwythonError as e:
258 +
                logger.error(f'{e.__class__.__name__}: {e}')
259 +
                raise
260 +
        else:
261 +
            logger.error(f'Unable to connect to imgflip: status code {r.status_code}')
262 +
            sleep(60)
252 263
253 264
    def get_question_url(self, url):
254 265
        """
Files Coverage
memeoverflow 100.00%
Project Totals (5 files) 100.00%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.
22.2
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
22.1
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
22.3
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading