commit
a4f2ee1cfa
2
csv/system_info.json
Normal file → Executable file
2
csv/system_info.json
Normal file → Executable file
@ -1 +1 @@
|
||||
{"update_available": false, "first_boot": true}
|
||||
{"update_available": false, "first_boot": false}
|
@ -65,7 +65,8 @@ def updateStocks(api_key):
|
||||
url += '&apiKey=' + api_key
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
|
||||
print(response)
|
||||
print(data)
|
||||
|
||||
stock_info = {}
|
||||
|
||||
@ -80,7 +81,7 @@ def updateStocks(api_key):
|
||||
json.dump(all_stocks_settings, open('csv/stocks_settings.json', 'w+'))
|
||||
|
||||
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))
|
||||
@ -120,9 +121,13 @@ def updateCrypto(api_key):
|
||||
print(data)
|
||||
|
||||
|
||||
|
||||
coin_info = {}
|
||||
for i,d in enumerate(data): #TODO get base from the server
|
||||
coin_info[symbol_base[i]] = {'current': d['price'], '24hr_change': d['percent_over_24hr']}
|
||||
|
||||
symbol = d['symbol']
|
||||
base = d['currency']
|
||||
|
||||
coin_info[symbol.upper() + ',' + base.upper()] = {'current': d['price'], '24hr_change': d['percent_over_24hr']}
|
||||
|
||||
all_crypto_settings['symbols'] = coin_info
|
||||
|
||||
@ -532,7 +537,8 @@ def updateAll(api_key, weather_key):
|
||||
updateForex(api_key)
|
||||
updateNews(api_key)
|
||||
updateSports(api_key)
|
||||
updateWeather(weather_key)
|
||||
if weather_key:
|
||||
updateWeather(weather_key)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -544,7 +550,7 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
update_frequencies = {'stocks':1, 'crypto':5, 'forex':60, 'news':120, 'weather': 120, 'sports': 120} #minutes
|
||||
update_frequencies = {'stocks':1, 'crypto':5, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440} #minutes
|
||||
|
||||
NY_zone = pytz.timezone('America/New_York')
|
||||
CET_zone = pytz.timezone('Europe/Berlin')
|
||||
@ -569,7 +575,7 @@ if __name__ == '__main__':
|
||||
try:
|
||||
weather_key = api_keys[1].strip()
|
||||
except Exception as e:
|
||||
|
||||
weather_key = False
|
||||
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))
|
||||
|
27
server.py
27
server.py
@ -33,6 +33,7 @@ api_caller.sendline('A')
|
||||
displaying_screensaver = False
|
||||
uploading = False
|
||||
screensaver_p = None
|
||||
ticker_stopped = False
|
||||
professional = json.load(open('csv/display_settings.json', 'r'))[0] == "Professional"
|
||||
|
||||
command = 300
|
||||
@ -174,11 +175,18 @@ def start():
|
||||
global ticker
|
||||
global api_caller
|
||||
global professional
|
||||
global ticker_stopped
|
||||
if displaying_screensaver:
|
||||
screensaver_p.close()
|
||||
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||
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 = pexpect.spawn("sudo -E taskset -c 3 python3 database_caller.py")
|
||||
displaying_screensaver = False
|
||||
|
||||
if ticker_stopped:
|
||||
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||
ticker_stopped = False
|
||||
|
||||
api_caller.sendline('A')
|
||||
|
||||
ticker.sendline('K')
|
||||
@ -193,17 +201,30 @@ def stop():
|
||||
global ticker
|
||||
global api_caller
|
||||
global professional
|
||||
global ticker_stopped
|
||||
|
||||
ticker.sendline('K')
|
||||
|
||||
if not displaying_screensaver:
|
||||
ticker.sendline('K')
|
||||
time.sleep(1) # give time for leds to turn off
|
||||
ticker.close()
|
||||
else:
|
||||
screensaver_p.close()
|
||||
|
||||
if not ticker_stopped:
|
||||
|
||||
time.sleep(1) # give time for leds to turn off
|
||||
ticker.close()
|
||||
ticker_stopped = True
|
||||
|
||||
|
||||
if displaying_screensaver:
|
||||
screensaver_p.close()
|
||||
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||
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 = pexpect.spawn("sudo -E taskset -c 3 python3 database_caller.py")
|
||||
displaying_screensaver = False
|
||||
|
||||
return index()
|
||||
|
||||
@app.route("/update", methods=['PUT','POST'])
|
||||
|
File diff suppressed because one or more lines are too long
@ -57,7 +57,7 @@ class StockTicker():
|
||||
options.chain_length = 2
|
||||
options.parallel = 1
|
||||
options.hardware_mapping = 'adafruit-hat' # If you have an Adafruit HAT: 'adafruit-hat'
|
||||
options.gpio_slowdown = 1
|
||||
options.gpio_slowdown = 4
|
||||
options.brightness = self.brightness
|
||||
self.matrix = RGBMatrix(options = options)
|
||||
print(dir(self.matrix))
|
||||
@ -931,9 +931,6 @@ class StockTicker():
|
||||
current = float(coin_info[cb]["current"])
|
||||
change = float(coin_info[cb]["24hr_change"])
|
||||
|
||||
|
||||
|
||||
|
||||
percent_change = '%.2f' % abs(change) +'%'
|
||||
|
||||
|
||||
@ -1074,10 +1071,10 @@ class StockTicker():
|
||||
current = float(forex_settings[sb]['current'])
|
||||
change = float(forex_settings[sb]['24hr_change'])
|
||||
|
||||
percent_change = '%.2f' % abs(change) +'%'
|
||||
percent_change = str(abs(change)) +'%'
|
||||
|
||||
|
||||
point_change = '%.2f' % abs(change/100 * current)
|
||||
point_change = str(abs(change/100 * current))
|
||||
|
||||
if not all_forex_settings['percent']:
|
||||
percent_change = False
|
||||
@ -1167,10 +1164,10 @@ class StockTicker():
|
||||
# convert percent to points
|
||||
change = change/current * 100
|
||||
|
||||
change = '%.2f' % change + '%'
|
||||
change = str(change) + '%'
|
||||
else:
|
||||
change = '%.6f' % change
|
||||
current = '%.3f' % current
|
||||
change = str(change)
|
||||
current = str(current)
|
||||
midFrame = self.textToImageProf(symbol + '(' + base + ')', current, change, arrow, font = ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
|
||||
|
||||
if all_forex_settings['logos']:
|
||||
@ -1240,13 +1237,13 @@ class StockTicker():
|
||||
change = float(info['current'])-float(info['opening']) #TEXT
|
||||
ticker = symbol #TEXT
|
||||
|
||||
percent_change = '%.2f' % abs(float(change)/float(info['current'])*100) + '%'
|
||||
point_change = '%.2f' % abs(change)
|
||||
percent_change = str(abs(float(change)/float(info['current'])*100)) + '%'
|
||||
point_change = str(abs(change))
|
||||
arrow, change = self.getArrow(change)
|
||||
|
||||
print(percent_change, point_change)
|
||||
|
||||
current = '%.2f' % float(info['current']) #TEXT
|
||||
current = str(float(info['current'])) #TEXT
|
||||
|
||||
|
||||
|
||||
@ -1327,10 +1324,10 @@ class StockTicker():
|
||||
# convert percent to points
|
||||
change = change/float(info['current'])* 100
|
||||
|
||||
change = '%.2f' % change + '%'
|
||||
change = str(change) + '%'
|
||||
else:
|
||||
change = '%.2f' % change
|
||||
current = '%.2f' % float(info['current']) #TEXT
|
||||
change = str(change)
|
||||
current = str(float(info['current'])) #TEXT
|
||||
midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
|
||||
|
||||
if all_stocks_settings['logos']:
|
||||
|
Loading…
Reference in New Issue
Block a user