dtaabase caller connected and bugfix
This commit is contained in:
parent
a25c82128c
commit
5d7ec03d41
@ -133,7 +133,7 @@ def updateCrypto():
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
print(data)
|
||||
sys.exit()
|
||||
|
||||
|
||||
|
||||
stock_info = {}
|
||||
@ -270,18 +270,23 @@ def updateNews():
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
|
||||
|
||||
#load user settings
|
||||
headlines = data
|
||||
headline_sources = [headline['source'] for headline in headlines]
|
||||
except Exception as e:
|
||||
|
||||
print('news ettings not used', e)
|
||||
#if no settings just get top headlines
|
||||
headlines = newsapi.get_top_headlines()
|
||||
headlines = newsapi.get_top_headlines()['articles']
|
||||
headline_sources = [headline['source']['name'] for headline in headlines]
|
||||
|
||||
headline_titles = [headline['title'] for headline in headlines['articles']]
|
||||
headline_sources = [headline['source']['name'] for headline in headlines['articles']]
|
||||
headline_times = [headline['publishedAt']for headline in headlines['articles']]
|
||||
headline_titles = [headline['title'] for headline in headlines]
|
||||
|
||||
headline_times = [headline['publishedAt'] for headline in headlines]
|
||||
|
||||
headlines = list(zip(headline_titles, headline_sources, headline_times))
|
||||
print(headlines)
|
||||
all_settings['headlines'] = headlines
|
||||
|
||||
json.dump(all_settings, open('csv/news_settings.json', 'w+'))
|
||||
@ -289,6 +294,7 @@ def updateNews():
|
||||
|
||||
|
||||
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))
|
||||
|
28
server.py
28
server.py
@ -16,16 +16,19 @@ import pexpect
|
||||
import time
|
||||
import json
|
||||
from multiprocessing import Process
|
||||
import subprocess
|
||||
from subprocess import Popen, PIPE
|
||||
import numpy as np
|
||||
import copy
|
||||
import urllib.request
|
||||
#stock_ticker = StockTicker()
|
||||
#print('API CALLER NOT STARTED')
|
||||
|
||||
#open('log.txt', 'w').close() #wipe logs
|
||||
|
||||
|
||||
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")
|
||||
api_caller.sendline('A')
|
||||
displaying_screensaver = False
|
||||
uploading = False
|
||||
@ -337,7 +340,7 @@ def edit_wpa_sup(country, ssid, pwd):
|
||||
|
||||
|
||||
@app.route("/wifi", methods = ['PUT', 'POST', 'GET'])
|
||||
def wifi():
|
||||
def set_wifi():
|
||||
|
||||
data= request.data.decode('utf-8')
|
||||
print(str(data))
|
||||
@ -357,6 +360,24 @@ def wifi():
|
||||
os.system('wpa_cli -i wlan0 reconfigure')
|
||||
return index()
|
||||
|
||||
def check_internet_connection(host='http://google.com'):
|
||||
|
||||
try:
|
||||
urllib.request.urlopen(host) #Python 3.x
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def check_network_connection():
|
||||
ps = subprocess.Popen(['iwconfig'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
try:
|
||||
output = subprocess.check_output(('grep', 'ESSID'), stdin=ps.stdout)
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
# grep did not match any lines
|
||||
print("No wireless networks connected")
|
||||
return False
|
||||
|
||||
def edit_hosts(hostname):
|
||||
current_hosts = open('/etc/hosts')
|
||||
|
||||
@ -510,6 +531,8 @@ def save_news_settings(input_settings):
|
||||
|
||||
current_settings = json.load(open('csv/' + filename, 'r'))
|
||||
|
||||
print(current_settings)
|
||||
|
||||
current_settings['speed'] = input_settings['speed'].lower()
|
||||
current_settings['animation'] = input_settings['animation'].lower()
|
||||
current_settings['title'] = input_settings['title']
|
||||
@ -518,6 +541,7 @@ def save_news_settings(input_settings):
|
||||
|
||||
|
||||
current_settings['sources'] = list(set(current_settings['sources'] + input_settings['sources']))
|
||||
print(current_settings)
|
||||
|
||||
json.dump(current_settings, open('csv/' + filename, 'w+'))
|
||||
api_caller.sendline('n')
|
||||
|
@ -962,10 +962,7 @@ function getFeatureSettings() {
|
||||
case 5:
|
||||
s = getWeatherSettings(page);
|
||||
break;
|
||||
case 6:fetch("/upload", {
|
||||
method: "POST",
|
||||
body: data,
|
||||
});
|
||||
case 6:
|
||||
s = getNewsSettings(page);
|
||||
break;
|
||||
case 7:
|
||||
|
@ -1089,7 +1089,7 @@ class StockTicker():
|
||||
current = '%.3f' % current
|
||||
|
||||
|
||||
midFrame = self.textToImage(symbol+ '(' + base + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT
|
||||
midFrame = self.textToImage(base+ '(' + symbol + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT
|
||||
|
||||
|
||||
if all_forex_settings['logos']:
|
||||
|
@ -1520,9 +1520,9 @@
|
||||
id="inputScrollSpeed62"
|
||||
class="form-select country-select"
|
||||
>
|
||||
<option>USA</option>
|
||||
<option>UK</option>
|
||||
<option>China</option>
|
||||
<option>US</option>
|
||||
<option>GB</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user