image bugfix

This commit is contained in:
Your Name 2021-12-15 09:37:09 +00:00
parent 8002beaff9
commit ee7227c278
2 changed files with 147 additions and 22 deletions

100
log.txt
View File

@ -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: <class 'FileNotFoundError'>
Traceback (most recent call last):
File "stockTicker.py", line 2673, in <module>
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: <class 'FileNotFoundError'>
Traceback (most recent call last):
File "stockTicker.py", line 2673, in <module>
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: <class 'geopy.exc.GeocoderUnavailable'>
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 "<string>", 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)"))

View File

@ -2458,6 +2458,8 @@ class StockTicker():
time.sleep(self.delay*1.1)
def getUserImages(self):
@ -2468,8 +2470,10 @@ 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))
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]))
@ -2477,6 +2481,17 @@ class StockTicker():
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,7 +2504,7 @@ 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 = []
@ -2497,7 +2512,7 @@ class StockTicker():
for i, frame in enumerate(ImageSequence.Iterator(GIF)):
frame.thumbnail((99999, 32))
f = self.stitchImage([title_img, frame])
frames.append(f)
@ -2509,6 +2524,16 @@ class StockTicker():
else:
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
'''