dtaabase caller connected and bugfix

This commit is contained in:
Your Name
2022-01-24 18:40:06 +00:00
parent a25c82128c
commit 5d7ec03d41
5 changed files with 42 additions and 15 deletions

View File

@@ -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')