bug fixes and slight layout changes
This commit is contained in:
@@ -85,38 +85,48 @@ def updateStocks():
|
|||||||
f.close()
|
f.close()
|
||||||
stock_info = all_stocks_settings['symbols']
|
stock_info = all_stocks_settings['symbols']
|
||||||
symbols = list(stock_info.keys())
|
symbols = list(stock_info.keys())
|
||||||
|
print(symbols)
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
valid_symbols = []
|
||||||
current_prices = []
|
current_prices = []
|
||||||
opening_prices = []
|
opening_prices = []
|
||||||
for symbol in symbols:
|
for symbol in symbols:
|
||||||
|
|
||||||
method = 'GET'
|
|
||||||
host = 'https://cloud.iexapis.com/stable'
|
|
||||||
|
|
||||||
intradayEndpoint = '/stock/'+ symbol+ '/intraday-prices'
|
try:
|
||||||
querystring = '?chartIEXOnly=true&token='+iexAPIkey
|
method = 'GET'
|
||||||
|
host = 'https://cloud.iexapis.com/stable'
|
||||||
|
|
||||||
intraday_request_url = host + intradayEndpoint + querystring
|
intradayEndpoint = '/stock/'+ symbol+ '/intraday-prices'
|
||||||
|
querystring = '?chartIEXOnly=true&token='+iexAPIkey
|
||||||
|
|
||||||
|
intraday_request_url = host + intradayEndpoint + querystring
|
||||||
|
|
||||||
|
|
||||||
intraday_response = requests.get(intraday_request_url)
|
intraday_response = requests.get(intraday_request_url)
|
||||||
|
|
||||||
|
|
||||||
for i in range(len(intraday_response.json())):
|
for i in range(len(intraday_response.json())):
|
||||||
opn = intraday_response.json()[i]['open']
|
opn = intraday_response.json()[i]['open']
|
||||||
if opn is not None:
|
if opn is not None:
|
||||||
break
|
break
|
||||||
for i in range(len(intraday_response.json())-1, 0, -1):
|
for i in range(len(intraday_response.json())-1, 0, -1):
|
||||||
|
|
||||||
current = intraday_response.json()[i]['close']
|
current = intraday_response.json()[i]['close']
|
||||||
if current is not None:
|
if current is not None:
|
||||||
break
|
break
|
||||||
|
valid_symbols.append(symbol)
|
||||||
opening_prices.append(opn)
|
opening_prices.append(opn)
|
||||||
current_prices.append(current)
|
current_prices.append(current)
|
||||||
|
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]
|
||||||
|
logf.write(str(e))
|
||||||
|
logf.write('. file: ' + fname)
|
||||||
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
|
logf.write('. type: ' + str(exc_type))
|
||||||
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
|
||||||
|
|
||||||
stock_info = {}
|
stock_info = {}
|
||||||
@@ -124,8 +134,8 @@ def updateStocks():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for i, symbol in enumerate(symbols):
|
for i, symbol in enumerate(valid_symbols):
|
||||||
|
print(symbol)
|
||||||
stock_info[symbol] = {'current': current_prices[i], 'opening': opening_prices[i]}
|
stock_info[symbol] = {'current': current_prices[i], 'opening': opening_prices[i]}
|
||||||
|
|
||||||
|
|
||||||
@@ -337,8 +347,9 @@ def updateWeather():
|
|||||||
all_locations = list(set(current_locations + daily_locations))
|
all_locations = list(set(current_locations + daily_locations))
|
||||||
|
|
||||||
|
|
||||||
current_weathers = {}
|
current_list = []
|
||||||
daily_weathers = {}
|
daily_list = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for location in all_locations:
|
for location in all_locations:
|
||||||
@@ -368,7 +379,7 @@ def updateWeather():
|
|||||||
|
|
||||||
|
|
||||||
if location in current_locations:
|
if location in current_locations:
|
||||||
current_weathers[location] = current_weather
|
current_list.append(current_weather)
|
||||||
|
|
||||||
daily_weather = []
|
daily_weather = []
|
||||||
daily = r.json()['daily']
|
daily = r.json()['daily']
|
||||||
@@ -393,9 +404,16 @@ def updateWeather():
|
|||||||
daily_weather[0]['visibility'] = current_weather['visibility']
|
daily_weather[0]['visibility'] = current_weather['visibility']
|
||||||
|
|
||||||
if location in daily_locations:
|
if location in daily_locations:
|
||||||
daily_weathers[location] = daily_weather
|
daily_list.append(daily_weather)
|
||||||
|
|
||||||
|
current_weathers = {}
|
||||||
|
daily_weathers = {}
|
||||||
|
|
||||||
|
for i,loc in enumerate(current_locations):
|
||||||
|
current_weathers[loc] = current_list[i]
|
||||||
|
|
||||||
|
for i,loc in enumerate(daily_locations):
|
||||||
|
daily_weathers[loc] = daily_list[i]
|
||||||
|
|
||||||
all_current_settings['locations'] = current_weathers
|
all_current_settings['locations'] = current_weathers
|
||||||
all_daily_settings['locations'] = daily_weathers
|
all_daily_settings['locations'] = daily_weathers
|
||||||
@@ -609,9 +627,17 @@ def checkStocks(last_update, update_frequency):
|
|||||||
return updated
|
return updated
|
||||||
|
|
||||||
|
|
||||||
|
def updateAll():
|
||||||
|
updateStocks()
|
||||||
|
updateCrypto()
|
||||||
|
updateForex()
|
||||||
|
updateNews()
|
||||||
|
updateSports()
|
||||||
|
updateWeather()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logf = open("log.txt", "w")
|
logf = open("log.txt", "a")
|
||||||
|
|
||||||
t = time.time()
|
t = time.time()
|
||||||
|
|
||||||
@@ -620,6 +646,8 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
newsapi = NewsApiClient(api_key='cf08652bd17647b89aaf469a1a8198a9')
|
newsapi = NewsApiClient(api_key='cf08652bd17647b89aaf469a1a8198a9')
|
||||||
|
|
||||||
|
|
||||||
@@ -651,9 +679,12 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
t = time.time()
|
t = time.time()
|
||||||
|
|
||||||
|
updateWeather()
|
||||||
|
sys.exit()
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
if msg == 'A':
|
||||||
|
updateAll()
|
||||||
|
|
||||||
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
|
|
||||||
|
128
log.txt
128
log.txt
@@ -0,0 +1,128 @@
|
|||||||
|
|
||||||
|
list indices must be integers or slices, not str. file: stockTicker.py. line: 2200. type: <class 'TypeError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "stockTicker.py", line 2200, in getDailyWeatherImage
|
||||||
|
main = daily_weather['description']
|
||||||
|
TypeError: list indices must be integers or slices, not str
|
||||||
|
list indices must be integers or slices, not str. file: stockTicker.py. line: 2200. type: <class 'TypeError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "stockTicker.py", line 2200, in getDailyWeatherImage
|
||||||
|
main = daily_weather['description']
|
||||||
|
TypeError: list indices must be integers or slices, not str
|
||||||
|
list indices must be integers or slices, not str. file: stockTicker.py. line: 2200. type: <class 'TypeError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "stockTicker.py", line 2200, in getDailyWeatherImage
|
||||||
|
main = daily_weather['description']
|
||||||
|
TypeError: list indices must be integers or slices, not str
|
||||||
|
list indices must be integers or slices, not str. file: stockTicker.py. line: 2200. type: <class 'TypeError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "stockTicker.py", line 2200, in getDailyWeatherImage
|
||||||
|
main = daily_weather['description']
|
||||||
|
TypeError: list indices must be integers or slices, not str
|
||||||
|
HTTPConnectionPool(host='api.geonames.org', port=80): Max retries exceeded with url: /searchJSON?q=London&username=fintic&maxRows=1 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xb5c72ed0>, 'Connection to api.geonames.org timed out. (connect 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/connection.py", line 159, in _new_conn
|
||||||
|
(self._dns_host, self.port), self.timeout, **extra_kw)
|
||||||
|
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 80, in create_connection
|
||||||
|
raise err
|
||||||
|
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 70, in create_connection
|
||||||
|
sock.connect(sa)
|
||||||
|
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 354, in _make_request
|
||||||
|
conn.request(method, url, **httplib_request_kw)
|
||||||
|
File "/usr/lib/python3.7/http/client.py", line 1260, in request
|
||||||
|
self._send_request(method, url, body, headers, encode_chunked)
|
||||||
|
File "/usr/lib/python3.7/http/client.py", line 1306, in _send_request
|
||||||
|
self.endheaders(body, encode_chunked=encode_chunked)
|
||||||
|
File "/usr/lib/python3.7/http/client.py", line 1255, in endheaders
|
||||||
|
self._send_output(message_body, encode_chunked=encode_chunked)
|
||||||
|
File "/usr/lib/python3.7/http/client.py", line 1030, in _send_output
|
||||||
|
self.send(msg)
|
||||||
|
File "/usr/lib/python3.7/http/client.py", line 970, in send
|
||||||
|
self.connect()
|
||||||
|
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 181, in connect
|
||||||
|
conn = self._new_conn()
|
||||||
|
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 164, in _new_conn
|
||||||
|
(self.host, self.timeout))
|
||||||
|
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0xb5c72ed0>, 'Connection to api.geonames.org timed out. (connect 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=London&username=fintic&maxRows=1 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xb5c72ed0>, 'Connection to api.geonames.org timed out. (connect 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 504, in send
|
||||||
|
raise ConnectTimeout(e, request=request)
|
||||||
|
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='api.geonames.org', port=80): Max retries exceeded with url: /searchJSON?q=London&username=fintic&maxRows=1 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xb5c72ed0>, 'Connection to api.geonames.org timed out. (connect 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=London&username=fintic&maxRows=1 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xb5c72ed0>, 'Connection to api.geonames.org timed out. (connect timeout=1)'))
|
||||||
|
local variable 'temp' referenced before assignment. file: stockTicker.py. line: 2239. type: <class 'UnboundLocalError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
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
|
||||||
|
local variable 'temp' referenced before assignment. file: stockTicker.py. line: 2239. type: <class 'UnboundLocalError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
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
|
||||||
|
local variable 'temp' referenced before assignment. file: stockTicker.py. line: 2239. type: <class 'UnboundLocalError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
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
|
||||||
|
local variable 'temp' referenced before assignment. file: stockTicker.py. line: 2239. type: <class 'UnboundLocalError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
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
|
||||||
|
local variable 'temp' referenced before assignment. file: stockTicker.py. line: 2239. type: <class 'UnboundLocalError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
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
|
||||||
|
local variable 'temp' referenced before assignment. file: stockTicker.py. line: 2239. type: <class 'UnboundLocalError'>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
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
|
||||||
|
11
server.py
11
server.py
@@ -22,6 +22,7 @@ import copy
|
|||||||
#stock_ticker = StockTicker()
|
#stock_ticker = StockTicker()
|
||||||
#print('API CALLER NOT STARTED')
|
#print('API CALLER NOT STARTED')
|
||||||
api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 api_caller.py")
|
api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 api_caller.py")
|
||||||
|
api_caller.sendline('A')
|
||||||
displaying_screensaver = False
|
displaying_screensaver = False
|
||||||
screensaver_p = None
|
screensaver_p = None
|
||||||
professional = json.load(open('csv/display_settings.json', 'r'))[0] == "Professional"
|
professional = json.load(open('csv/display_settings.json', 'r'))[0] == "Professional"
|
||||||
@@ -44,7 +45,7 @@ def allowed_file(filename):
|
|||||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||||
|
|
||||||
def process_file(path, filename):
|
def process_file(path, filename):
|
||||||
default_csv = csv.writer(open('csv/tickers.csv', 'w'))
|
default_csv = csv.writer(open('csv/tickers.csv', 'w+'))
|
||||||
new_csv = csv.reader(open((path), 'r'))
|
new_csv = csv.reader(open((path), 'r'))
|
||||||
|
|
||||||
for row in new_csv:
|
for row in new_csv:
|
||||||
@@ -187,6 +188,7 @@ def stop():
|
|||||||
@app.route("/update", methods=['PUT','POST'])
|
@app.route("/update", methods=['PUT','POST'])
|
||||||
def update():
|
def update():
|
||||||
os.system("./update.sh")
|
os.system("./update.sh")
|
||||||
|
os.system("sudo reboot now")
|
||||||
return index()
|
return index()
|
||||||
|
|
||||||
@app.route("/display_format", methods = ['PUT', 'POST', 'GET'])
|
@app.route("/display_format", methods = ['PUT', 'POST', 'GET'])
|
||||||
@@ -393,10 +395,6 @@ def combine_dict(current_settings, input_symbols, current_key):
|
|||||||
else:
|
else:
|
||||||
new_settings[current_key][IS] = current_settings[current_key][IS]
|
new_settings[current_key][IS] = current_settings[current_key][IS]
|
||||||
|
|
||||||
# remove stocks not in settings
|
|
||||||
for CS in current_symbols:
|
|
||||||
if CS not in input_symbols:
|
|
||||||
del new_settings[current_key][CS]
|
|
||||||
|
|
||||||
return new_settings
|
return new_settings
|
||||||
|
|
||||||
@@ -448,11 +446,14 @@ def save_weather_settings(input_settings):
|
|||||||
if input_settings['feature'] == 'Daily Forecast':
|
if input_settings['feature'] == 'Daily Forecast':
|
||||||
current_settings['current_weather'] = input_settings['current_weather']
|
current_settings['current_weather'] = input_settings['current_weather']
|
||||||
|
|
||||||
|
'''
|
||||||
locations = {}
|
locations = {}
|
||||||
for key in input_settings['locations']:
|
for key in input_settings['locations']:
|
||||||
locations[key] = []
|
locations[key] = []
|
||||||
current_settings['locations'] = locations
|
current_settings['locations'] = locations
|
||||||
|
'''
|
||||||
|
|
||||||
|
current_settings = combine_dict(current_settings, input_settings['locations'], 'locations')
|
||||||
json.dump(current_settings, open('csv/' + filename, 'w+'))
|
json.dump(current_settings, open('csv/' + filename, 'w+'))
|
||||||
|
|
||||||
api_caller.sendline('w')
|
api_caller.sendline('w')
|
||||||
|
1476
stockTicker.py
1476
stockTicker.py
File diff suppressed because it is too large
Load Diff
@@ -1226,8 +1226,8 @@
|
|||||||
id="inputTransition42"
|
id="inputTransition42"
|
||||||
class="form-select wind-speed-select"
|
class="form-select wind-speed-select"
|
||||||
>
|
>
|
||||||
<option>Miles/sec</option>
|
<option>Miles/hour</option>
|
||||||
<option>Kilometer/sec</option>
|
<option>Kilometers/hour</option>
|
||||||
<option></option>
|
<option></option>
|
||||||
<option></option>
|
<option></option>
|
||||||
<option></option>
|
<option></option>
|
||||||
@@ -1447,8 +1447,8 @@
|
|||||||
id="inputTransition52"
|
id="inputTransition52"
|
||||||
class="form-select wind-speed-select"
|
class="form-select wind-speed-select"
|
||||||
>
|
>
|
||||||
<option>Miles/sec</option>
|
<option>Miles/hour</option>
|
||||||
<option>Kilometer/sec</option>
|
<option>Kilometers/hour</option>
|
||||||
<option></option>
|
<option></option>
|
||||||
<option></option>
|
<option></option>
|
||||||
<option></option>
|
<option></option>
|
||||||
|
Reference in New Issue
Block a user