Merge pull request #10 from fin-tic/master

merge latest master to dev branch
This commit is contained in:
Justin 2022-06-10 16:56:38 +08:00 committed by GitHub
commit b21741fd44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 27 deletions

View File

@ -23,7 +23,7 @@ import copy
import urllib.request
import sys
#stock_ticker = StockTicker()
import traceback
#open('log.txt', 'w').close() #wipe logs
@ -43,9 +43,12 @@ uploading = False
screensaver_p = None
ticker_stopped = False
f = open('csv/display_settings.json', 'r')
professional = json.load(f)[0] == "Professional"
f.close()
try:
f = open('csv/display_settings.json', 'r')
professional = json.load(f)[0] == "Professional"
f.close()
except:
professional = False
command = 300
tickerList = 0
@ -60,14 +63,15 @@ ALLOWED_EXTENSIONS = {'csv', 'png'}
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
time.sleep(2) # give the ticker time to initialise
f = open('csv/system_info.json', 'w')
try:
f = open('csv/system_info.json', 'r')
system_info = json.load(f)
except Exception as e:
system_info = {"update_available": False, "first_boot": False}
f = open('csv/system_info.json', 'w')
json.dump(system_info, f)
system_info = json.load(f)
f.close()
ticker.sendline('*') # run startup gif by default
@ -258,8 +262,7 @@ def save_displaying(input_settings):
s = "Professional" if professional else "Standard"
display_settings = [s] + [input_settings]
with open('csv/display_settings.json', 'w+') as f:
with open('csv/display_settings.json', 'w') as f:
json.dump(list(display_settings), f)
@ -328,14 +331,15 @@ def stop():
def update():
f = open('csv/system_info.json', 'w+')
try:
f = open('csv/system_info.json', 'r')
system_info = json.load(f)
except Exception as e:
system_info = {"update_available": False, "first_boot": False}
system_info['update_available'] = False
f = open('csv/system_info.json', 'w')
json.dump(system_info, f)
f.close()
@ -439,18 +443,17 @@ def remove_old_uploads():
@app.route("/brightness", methods=['PUT','POST'])
def brightness():
global brightness
data= request.data.decode('utf-8')
settings = json.loads(data)
brightness =settings['brightness']
ticker.sendline(str(int(brightness)-1))
brightness = max(min(int(brightness), 10), 1)
ticker.sendline(str(brightness-1))
f = open('csv/general_settings.json', 'r')
general_settings = json.load(f)
f.close()
general_settings['brightness'] = int(brightness)
f = open('csv/general_settings.json', 'w+')
f = open('csv/general_settings.json', 'w')
json.dump(general_settings, f)
f.close()
return index()
@ -484,7 +487,7 @@ def edit_wpa_sup(country, ssid, pwd):
wpa_string = ''.join(wpa_lines)
current_wpa = open('/etc/wpa_supplicant/wpa_supplicant.conf', 'w+')
current_wpa = open('/etc/wpa_supplicant/wpa_supplicant.conf', 'w')
current_wpa.write(wpa_string)
@ -503,7 +506,7 @@ def set_wifi():
general_settings = json.load(f)
f.close()
general_settings['country_code'] = country
f = open('csv/general_settings.json', 'w+')
f = open('csv/general_settings.json', 'w')
json.dump(general_settings, f)
f.close()
@ -561,7 +564,7 @@ def hostname():
f.close()
general_settings['hostname'] = hostname
f = open('csv/general_settings.json', 'w+')
f = open('csv/general_settings.json', 'w')
json.dump(general_settings, f)
f.close()
@ -665,7 +668,7 @@ def save_trade_settings(input_settings):
current_settings = combine_dict(current_settings, input_settings['symbols'], 'symbols')
f = open('csv/' + filename, 'w+')
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
f = open('csv/last_updates.json', 'r')
@ -677,7 +680,7 @@ def save_trade_settings(input_settings):
f = open('csv/last_updates.json', 'w+')
f = open('csv/last_updates.json', 'w')
json.dump(last_updates, f)
f.close()
@ -724,7 +727,7 @@ def save_weather_settings(input_settings):
last_updates['weather']['force'] = True
f = open('csv/last_updates.json', 'w+')
f = open('csv/last_updates.json', 'w')
json.dump(last_updates, f)
f.close()
@ -749,7 +752,7 @@ def save_news_settings(input_settings):
f = open('csv/' + filename, 'w+')
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
#api_caller.sendline('n')
@ -759,7 +762,7 @@ def save_news_settings(input_settings):
last_updates['news']['force'] = True
f = open('csv/last_updates.json', 'w+')
f = open('csv/last_updates.json', 'w')
json.dump(last_updates, f)
f.close()
@ -792,7 +795,7 @@ def save_sports_settings(input_settings):
current_settings = combine_dict(current_settings, input_settings['leagues'], 'leagues')
f = open('csv/' + filename, 'w+')
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
@ -805,7 +808,7 @@ def save_sports_settings(input_settings):
last_updates[update_key]['force'] = True
f = open('csv/last_updates.json', 'w+')
f = open('csv/last_updates.json', 'w')
json.dump(last_updates, f)
f.close()
@ -821,7 +824,7 @@ def save_image_settings(input_settings):
del current_settings['feature']
f = open('csv/' + filename, 'w+')
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
remove_old_uploads()
@ -843,7 +846,7 @@ def save_message_settings(input_settings):
break
f = open('csv/message_settings.json', 'w+')
f = open('csv/message_settings.json', 'w')
json.dump(new_settings, f)
f.close()

View File

@ -547,7 +547,7 @@
<li>Custom Messages</li>
<li>Cstom Gifs</li>
<li>Custom Gifs</li>
<li>Sports (Upcoming Games)</li>