ddtabase caller bugfix

This commit is contained in:
Neythen Treloar 2022-02-28 16:38:24 +00:00
parent 6ceb2e3645
commit 8a535249b4
2 changed files with 57 additions and 49 deletions

View File

@ -66,10 +66,11 @@ def updateStocks(api_key):
response = requests.get(url)
data = response.json()
print(response)
print(data)
print(dir(response))
print(len(data))
stock_info = {}
if len(data) > 0:
for stock in data:
stock_info[stock['symbol']] = {'current': stock['price'], 'change': stock['change_since'], 'percent_change':stock['percent']}
@ -122,7 +123,8 @@ def updateCrypto(api_key):
coin_info = {}
for i,d in enumerate(data): #TODO get base from the server
if len(data) > 0:
for i,d in enumerate(data):
symbol = d['symbol']
base = d['currency']
@ -174,7 +176,7 @@ def updateForex(api_key):
data = response.json()
if len(data) > 0:
print(data)
c_dict = {}
@ -225,7 +227,7 @@ def updateNews(api_key):
response = requests.get(url)
data = response.json()
print(data)
if len(data) > 0:
max_headlines = int(all_settings['num_headlines'])
#load user settings
headlines = data[:max_headlines]

View File

@ -21,15 +21,21 @@ from subprocess import Popen, PIPE
import numpy as np
import copy
import urllib.request
import sys
#stock_ticker = StockTicker()
#print('API CALLER NOT STARTED')
#open('log.txt', 'w').close() #wipe logs
os.system("sudo ./check_update.sh")
#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")
api_caller.sendline('A')
time.sleep(3)
api_caller.sendline('s')
#api_caller.sendline('A')
sys.exit()
os.system("sudo ./check_update.sh")
displaying_screensaver = False
uploading = False
screensaver_p = None