database caller new method

This commit is contained in:
Neythen Treloar
2022-03-06 09:29:42 +00:00
parent b6646f60cb
commit 37f6c097f3
5 changed files with 130 additions and 84 deletions

View File

@@ -29,7 +29,7 @@ import sys
#api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 api_caller.py")
api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 database_caller2.py")
api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 database_caller.py")
time.sleep(3)
@@ -573,14 +573,21 @@ def save_trade_settings(input_settings):
f = open('csv/' + filename, 'w+')
json.dump(current_settings, f)
f.close()
f = open('csv/last_updates.json', 'r')
last_updates = json.load(f)
f.close()
if input_settings['feature'].lower() == 'stocks':
api_caller.sendline('s')
last_updates['stocks']['force'] = True
elif input_settings['feature'].lower() == 'crypto':
api_caller.sendline('c')
last_updates['crypto']['force'] = True
elif input_settings['feature'].lower() == 'forex':
api_caller.sendline('f')
last_updates['forex']['force'] = True
f = open('csv/last_updates.json', 'w+')
json.dump(last_updates, f)
f.close()
def save_weather_settings(input_settings):
@@ -613,7 +620,16 @@ def save_weather_settings(input_settings):
current_settings = combine_dict(current_settings, input_settings['locations'], 'locations')
json.dump(current_settings, open('csv/' + filename, 'w+'))
api_caller.sendline('w')
#api_caller.sendline('w')
f = open('csv/last_updates.json', 'r')
last_updates = json.load(f)
f.close()
last_updates['weather']['force'] = True
f = open('csv/last_updates.json', 'w+')
json.dump(last_updates, f)
f.close()
def save_news_settings(input_settings):
filename = 'news_settings.json'
@@ -636,7 +652,16 @@ def save_news_settings(input_settings):
print(current_settings)
json.dump(current_settings, open('csv/' + filename, 'w+'))
api_caller.sendline('n')
#api_caller.sendline('n')
f = open('csv/last_updates.json', 'r')
last_updates = json.load(f)
f.close()
last_updates['news']['force'] = True
f = open('csv/last_updates.json', 'w+')
json.dump(last_updates, f)
f.close()
def save_sports_settings(input_settings):
@@ -662,7 +687,16 @@ def save_sports_settings(input_settings):
json.dump(current_settings, open('csv/' + filename, 'w+'))
api_caller.sendline('S')
#api_caller.sendline('S')
f = open('csv/last_updates.json', 'r')
last_updates = json.load(f)
f.close()
last_updates['sports']['force'] = True
f = open('csv/last_updates.json', 'w+')
json.dump(last_updates, f)
f.close()
# for images and GIFs
def save_image_settings(input_settings):