From ee7227c278d6707cdc03e62d1734cb902353e508 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 15 Dec 2021 09:37:09 +0000 Subject: [PATCH] image bugfix --- log.txt | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ stockTicker.py | 69 +++++++++++++++++++++++----------- 2 files changed, 147 insertions(+), 22 deletions(-) diff --git a/log.txt b/log.txt index db43b1d..f7e7e2d 100755 --- a/log.txt +++ b/log.txt @@ -126,3 +126,103 @@ local variable 'temp' referenced before assignment. file: stockTicker.py. line: File "stockTicker.py", line 2239, in getDailyWeatherImage temp_img = self.textImage(str("{0:.0f}".format(temp)), large_font) UnboundLocalError: local variable 'temp' referenced before assignment +[Errno 2] No such file or directory: '/home/pi/Desktop/fintic/user_uploads/Screenshot 2020-04-07 at 09.48.46.png'. file: stockTicker.py. line: 2673. type: + Traceback (most recent call last): + File "stockTicker.py", line 2673, in + stock_ticker.process_msg(msg) + File "stockTicker.py", line 2632, in process_msg + self.scrollFunctionsAnimated(userSettings[1], animation = 'down') + File "stockTicker.py", line 349, in scrollFunctionsAnimated + images = self.getUserImages() + File "stockTicker.py", line 2471, in getUserImages + img = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image)) + File "stockTicker.py", line 87, in openImage + image = Image.open(image_file) + File "/home/pi/.local/lib/python3.7/site-packages/PIL/Image.py", line 2975, in open +FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/Desktop/fintic/user_uploads/Screenshot 2020-04-07 at 09.48.46.png' +[Errno 2] No such file or directory: '/home/pi/Desktop/fintic/user_uploads/Figure_1.png'. file: stockTicker.py. line: 2673. type: + Traceback (most recent call last): + File "stockTicker.py", line 2673, in + stock_ticker.process_msg(msg) + File "stockTicker.py", line 2632, in process_msg + self.scrollFunctionsAnimated(userSettings[1], animation = 'down') + File "stockTicker.py", line 349, in scrollFunctionsAnimated + images = self.getUserImages() + File "stockTicker.py", line 2471, in getUserImages + img = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image)) + File "stockTicker.py", line 87, in openImage + image = Image.open(image_file) + File "/home/pi/.local/lib/python3.7/site-packages/PIL/Image.py", line 2975, in open +FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/Desktop/fintic/user_uploads/Figure_1.png' +HTTPConnectionPool(host='api.geonames.org', port=80): Max retries exceeded with url: /searchJSON?q=New+York&username=fintic&maxRows=1 (Caused by ReadTimeoutError("HTTPConnectionPool(host='api.geonames.org', port=80): Read timed out. (read timeout=1)")). file: api_caller.py. line: 356. type: + Traceback (most recent call last): + File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 384, in _make_request + six.raise_from(e, None) + File "", line 3, in raise_from + File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 380, in _make_request + httplib_response = conn.getresponse() + File "/usr/lib/python3.7/http/client.py", line 1352, in getresponse + response.begin() + File "/usr/lib/python3.7/http/client.py", line 310, in begin + version, status, reason = self._read_status() + File "/usr/lib/python3.7/http/client.py", line 271, in _read_status + line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") + File "/usr/lib/python3.7/socket.py", line 589, in readinto + return self._sock.recv_into(b) +socket.timeout: timed out + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen + chunked=chunked) + File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 386, in _make_request + self._raise_timeout(err=e, url=url, timeout_value=read_timeout) + File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 306, in _raise_timeout + raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value) +urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='api.geonames.org', port=80): Read timed out. (read timeout=1) + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "/home/pi/.local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send + timeout=timeout + File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 667, in urlopen + **response_kw) + File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 667, in urlopen + **response_kw) + File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen + _stacktrace=sys.exc_info()[2]) + File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 398, in increment + raise MaxRetryError(_pool, url, error or ResponseError(cause)) +urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='api.geonames.org', port=80): Max retries exceeded with url: /searchJSON?q=New+York&username=fintic&maxRows=1 (Caused by ReadTimeoutError("HTTPConnectionPool(host='api.geonames.org', port=80): Read timed out. (read timeout=1)")) + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "/home/pi/.local/lib/python3.7/site-packages/geopy/adapters.py", line 448, in _request + resp = self.session.get(url, timeout=timeout, headers=headers) + File "/home/pi/.local/lib/python3.7/site-packages/requests/sessions.py", line 555, in get + return self.request('GET', url, **kwargs) + File "/home/pi/.local/lib/python3.7/site-packages/requests/sessions.py", line 542, in request + resp = self.send(prep, **send_kwargs) + File "/home/pi/.local/lib/python3.7/site-packages/requests/sessions.py", line 655, in send + r = adapter.send(request, **kwargs) + File "/home/pi/.local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send + raise ConnectionError(e, request=request) +requests.exceptions.ConnectionError: HTTPConnectionPool(host='api.geonames.org', port=80): Max retries exceeded with url: /searchJSON?q=New+York&username=fintic&maxRows=1 (Caused by ReadTimeoutError("HTTPConnectionPool(host='api.geonames.org', port=80): Read timed out. (read timeout=1)")) + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "api_caller.py", line 356, in updateWeather + loc = gn.geocode(location) + File "/home/pi/.local/lib/python3.7/site-packages/geopy/geocoders/geonames.py", line 157, in geocode + return self._call_geocoder(url, callback, timeout=timeout) + File "/home/pi/.local/lib/python3.7/site-packages/geopy/geocoders/base.py", line 368, in _call_geocoder + result = self.adapter.get_json(url, timeout=timeout, headers=req_headers) + File "/home/pi/.local/lib/python3.7/site-packages/geopy/adapters.py", line 438, in get_json + resp = self._request(url, timeout=timeout, headers=headers) + File "/home/pi/.local/lib/python3.7/site-packages/geopy/adapters.py", line 460, in _request + raise GeocoderUnavailable(message) +geopy.exc.GeocoderUnavailable: HTTPConnectionPool(host='api.geonames.org', port=80): Max retries exceeded with url: /searchJSON?q=New+York&username=fintic&maxRows=1 (Caused by ReadTimeoutError("HTTPConnectionPool(host='api.geonames.org', port=80): Read timed out. (read timeout=1)")) diff --git a/stockTicker.py b/stockTicker.py index 0de4ad3..4677f3f 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -2457,7 +2457,9 @@ class StockTicker(): pass time.sleep(self.delay*1.1) - + + + def getUserImages(self): @@ -2468,14 +2470,27 @@ class StockTicker(): imgs = [] for ind,image in enumerate(all_settings['images']): - img = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image)) - - if all_settings['title'] and ind == 0: - title_img = self.openImage('feature_titles/images.png') - imgs.append(self.stitchImage([title_img, img])) + + try: + img = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image)) + img.thumbnail((99999, 32)) + if all_settings['title'] and ind == 0: + title_img = self.openImage('feature_titles/images.png') + imgs.append(self.stitchImage([title_img, img])) - else: - imgs.append(img) + else: + imgs.append(img) + + except Exception as e: + exc_type, exc_obj, exc_tb = sys.exc_info() + fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] + self.logf.write(str(e)) + self.logf.write('. file: ' + fname) + self.logf.write('. line: ' + str(exc_tb.tb_lineno)) + self.logf.write('. type: ' + str(exc_type)) + self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))) + + return imgs @@ -2489,26 +2504,36 @@ class StockTicker(): for ind,fle in enumerate(all_settings['images']): + try: + GIF = Image.open(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), fle)) + if ind == 0 and all_settings['title']: + frames = [] + title_img = self.openImage('feature_titles/gifs.png') - GIF = Image.open(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), fle)) - if ind == 0 and all_settings['title']: - frames = [] - title_img = self.openImage('feature_titles/gifs.png') - - for i, frame in enumerate(ImageSequence.Iterator(GIF)): + for i, frame in enumerate(ImageSequence.Iterator(GIF)): - - f = self.stitchImage([title_img, frame]) - frames.append(f) + frame.thumbnail((99999, 32)) + f = self.stitchImage([title_img, frame]) + frames.append(f) - frames[0].save('./display_images/working_gif.gif', save_all=True, append_images=frames[1:], loop=0, optimize = False) - GIF = Image.open('./display_images/working_gif.gif') - GIFs.append(GIF) + frames[0].save('./display_images/working_gif.gif', save_all=True, append_images=frames[1:], loop=0, optimize = False) + GIF = Image.open('./display_images/working_gif.gif') + GIFs.append(GIF) - else: + else: - GIFs.append(GIF) + GIFs.append(GIF) + except Exception as e: + exc_type, exc_obj, exc_tb = sys.exc_info() + fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] + self.logf.write(str(e)) + self.logf.write('. file: ' + fname) + self.logf.write('. line: ' + str(exc_tb.tb_lineno)) + self.logf.write('. type: ' + str(exc_type)) + self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))) + + #below code stitches title and GIF together '''