commit
0c8d1d6b18
@ -35,7 +35,9 @@ rm csv/system_info.json
|
|||||||
|
|
||||||
echo "$str" >> csv/system_info.json
|
echo "$str" >> csv/system_info.json
|
||||||
|
|
||||||
|
|
||||||
sudo chmod 777 csv/system_info.json
|
sudo chmod 777 csv/system_info.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ def updateUpdate(NY_time):
|
|||||||
|
|
||||||
def updateStocks(api_key, logf):
|
def updateStocks(api_key, logf):
|
||||||
|
|
||||||
print('STOCKS')
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ def updateStocks(api_key, logf):
|
|||||||
f.close()
|
f.close()
|
||||||
stock_info = all_stocks_settings['symbols']
|
stock_info = all_stocks_settings['symbols']
|
||||||
symbols = list(stock_info.keys())
|
symbols = list(stock_info.keys())
|
||||||
#print(symbols)
|
|
||||||
|
|
||||||
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/stocks?symbols='
|
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/stocks?symbols='
|
||||||
|
|
||||||
@ -66,9 +66,7 @@ def updateStocks(api_key, logf):
|
|||||||
url += '&apiKey=' + api_key
|
url += '&apiKey=' + api_key
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
#print(response)
|
|
||||||
#print(dir(response))
|
|
||||||
#print(len(data))
|
|
||||||
|
|
||||||
stock_info = {}
|
stock_info = {}
|
||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
@ -81,11 +79,13 @@ def updateStocks(api_key, logf):
|
|||||||
all_stocks_settings['symbols'] = stock_info
|
all_stocks_settings['symbols'] = stock_info
|
||||||
|
|
||||||
|
|
||||||
|
f = open('csv/stocks_settings.json', 'w+')
|
||||||
json.dump(all_stocks_settings, open('csv/stocks_settings.json', 'w+'))
|
json.dump(all_stocks_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
logf.write(str(e))
|
logf.write(str(e))
|
||||||
@ -93,12 +93,13 @@ def updateStocks(api_key, logf):
|
|||||||
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
def updateCrypto(api_key, logf):
|
def updateCrypto(api_key, logf):
|
||||||
|
|
||||||
print('CRYPTO')
|
|
||||||
#cypto_info['symbol, base'].keys() = ['current','24hr change']
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
|
||||||
@ -119,11 +120,10 @@ def updateCrypto(api_key, logf):
|
|||||||
url += bases[i] + '-' + s + ','
|
url += bases[i] + '-' + s + ','
|
||||||
url = url[:-1] #remove last comma
|
url = url[:-1] #remove last comma
|
||||||
url += '&apiKey=' + api_key
|
url += '&apiKey=' + api_key
|
||||||
#print(url)
|
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
#print(url)
|
|
||||||
#print(data)
|
|
||||||
|
|
||||||
|
|
||||||
coin_info = {}
|
coin_info = {}
|
||||||
@ -145,6 +145,7 @@ def updateCrypto(api_key, logf):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
logf.write(str(e))
|
logf.write(str(e))
|
||||||
@ -152,10 +153,11 @@ def updateCrypto(api_key, logf):
|
|||||||
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
def updateForex(api_key, logf):
|
def updateForex(api_key, logf):
|
||||||
|
|
||||||
print('FOREX')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open('csv/forex_settings.json', 'r')
|
f = open('csv/forex_settings.json', 'r')
|
||||||
@ -185,7 +187,7 @@ def updateForex(api_key, logf):
|
|||||||
|
|
||||||
|
|
||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
#print(data)
|
|
||||||
c_dict = {}
|
c_dict = {}
|
||||||
for sb in symbol_base:
|
for sb in symbol_base:
|
||||||
for d in data:
|
for d in data:
|
||||||
@ -196,9 +198,13 @@ def updateForex(api_key, logf):
|
|||||||
|
|
||||||
|
|
||||||
all_forex_settings['symbols'] = c_dict
|
all_forex_settings['symbols'] = c_dict
|
||||||
json.dump(all_forex_settings, open( "csv/forex_settings.json", 'w+' ))
|
|
||||||
|
f = open( "csv/forex_settings.json", 'w+' )
|
||||||
|
json.dump(all_forex_settings, f)
|
||||||
|
f.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
logf.write(str(e))
|
logf.write(str(e))
|
||||||
@ -206,6 +212,7 @@ def updateForex(api_key, logf):
|
|||||||
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
def updateNews(api_key, logf):
|
def updateNews(api_key, logf):
|
||||||
@ -214,10 +221,12 @@ def updateNews(api_key, logf):
|
|||||||
#'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?country=GB'
|
#'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?country=GB'
|
||||||
#'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?lang=en'
|
#'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?lang=en'
|
||||||
|
|
||||||
print('NEWS')
|
|
||||||
try:
|
try:
|
||||||
|
f = open('csv/news_settings.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
all_settings = json.load(open('csv/news_settings.json', 'r'))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +243,7 @@ def updateNews(api_key, logf):
|
|||||||
url += '&apiKey=' + api_key
|
url += '&apiKey=' + api_key
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
#print(data)
|
|
||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
max_headlines = int(all_settings['num_headlines'])
|
max_headlines = int(all_settings['num_headlines'])
|
||||||
#load user settings
|
#load user settings
|
||||||
@ -247,15 +256,18 @@ def updateNews(api_key, logf):
|
|||||||
headline_times = [headline['publishedAt'] for headline in headlines]
|
headline_times = [headline['publishedAt'] for headline in headlines]
|
||||||
|
|
||||||
headlines = list(zip(headline_titles, headline_sources, headline_times))
|
headlines = list(zip(headline_titles, headline_sources, headline_times))
|
||||||
#print(headlines)
|
|
||||||
all_settings['headlines'] = headlines
|
all_settings['headlines'] = headlines
|
||||||
|
|
||||||
json.dump(all_settings, open('csv/news_settings.json', 'w+'))
|
f = open('csv/news_settings.json', 'w+')
|
||||||
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
logf.write(str(e))
|
logf.write(str(e))
|
||||||
@ -263,10 +275,11 @@ def updateNews(api_key, logf):
|
|||||||
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
def updateWeather(api_key, logf):
|
def updateWeather(api_key, logf):
|
||||||
print('WEATHER')
|
|
||||||
max_cities = 30
|
max_cities = 30
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -346,17 +359,21 @@ def updateWeather(api_key, logf):
|
|||||||
|
|
||||||
if location in daily_locations:
|
if location in daily_locations:
|
||||||
daily_weathers[location] = daily_weather
|
daily_weathers[location] = daily_weather
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all_current_settings['locations'] = current_weathers
|
all_current_settings['locations'] = current_weathers
|
||||||
all_daily_settings['locations'] = daily_weathers
|
all_daily_settings['locations'] = daily_weathers
|
||||||
#print(all_current_settings, all_daily_settings)
|
f = open( "csv/current_weather.json", 'w+' )
|
||||||
json.dump( all_current_settings, open( "csv/current_weather.json", 'w+' ))
|
json.dump( all_current_settings, f)
|
||||||
json.dump( all_daily_settings, open( "csv/daily_weather.json", 'w+' ))
|
f.close()
|
||||||
|
|
||||||
|
f = open( "csv/daily_weather.json", 'w+' )
|
||||||
|
json.dump( all_daily_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
logf.write(str(e))
|
logf.write(str(e))
|
||||||
@ -364,14 +381,17 @@ def updateWeather(api_key, logf):
|
|||||||
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
def updateLeagueTables(api_key, logf):
|
def updateLeagueTables(api_key, logf):
|
||||||
print('LEAGUE TABLES')
|
|
||||||
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/sports?stats='
|
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/sports?stats='
|
||||||
try:
|
try:
|
||||||
f = open('csv/league_tables.json', 'r')
|
f = open('csv/league_tables.json', 'r')
|
||||||
all_settings = json.load(f)
|
all_settings = json.load(f)
|
||||||
#print(all_settings['leagues'].keys())
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
leagues = all_settings['leagues'].keys()
|
leagues = all_settings['leagues'].keys()
|
||||||
@ -390,12 +410,11 @@ def updateLeagueTables(api_key, logf):
|
|||||||
all_data = r.json()
|
all_data = r.json()
|
||||||
|
|
||||||
|
|
||||||
#print('key', [all_data[i].keys() for i in range(len(all_data))])
|
|
||||||
#print('key', all_data.keys())
|
|
||||||
for i,l in enumerate(all_data):
|
for i,l in enumerate(all_data):
|
||||||
#print(l)
|
|
||||||
league = list(l.keys())[0]
|
league = list(l.keys())[0]
|
||||||
#print('league', league, list(l.keys()))
|
|
||||||
|
|
||||||
teams = []
|
teams = []
|
||||||
|
|
||||||
@ -417,10 +436,13 @@ def updateLeagueTables(api_key, logf):
|
|||||||
leagues_info[league.upper()] = teams
|
leagues_info[league.upper()] = teams
|
||||||
|
|
||||||
all_settings['leagues'] = leagues_info
|
all_settings['leagues'] = leagues_info
|
||||||
#print(all_settings['leagues'].keys())
|
f = open( "csv/league_tables.json".format(league), 'w+' )
|
||||||
json.dump(all_settings, open( "csv/league_tables.json".format(league), 'w+' ))
|
json.dump(all_settings, f)
|
||||||
|
|
||||||
|
f.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
logf.write(str(e))
|
logf.write(str(e))
|
||||||
@ -428,10 +450,11 @@ def updateLeagueTables(api_key, logf):
|
|||||||
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
def updateLeagueEvents(api_key, time, logf):
|
def updateLeagueEvents(api_key, time, logf):
|
||||||
print('LEAGUE EVENTS', time)
|
|
||||||
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/sports?{}='.format(time)
|
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/sports?{}='.format(time)
|
||||||
|
|
||||||
if time == 'past':
|
if time == 'past':
|
||||||
@ -448,7 +471,7 @@ def updateLeagueEvents(api_key, time, logf):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
all_settings = json.load(f)
|
all_settings = json.load(f)
|
||||||
#print(all_settings['leagues'].keys())
|
|
||||||
f.close()
|
f.close()
|
||||||
leagues = all_settings['leagues'].keys()
|
leagues = all_settings['leagues'].keys()
|
||||||
leagues_info = {}
|
leagues_info = {}
|
||||||
@ -466,10 +489,6 @@ def updateLeagueEvents(api_key, time, logf):
|
|||||||
|
|
||||||
all_data = r.json()
|
all_data = r.json()
|
||||||
|
|
||||||
#print(all_data)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for league in all_data.keys():
|
for league in all_data.keys():
|
||||||
events = []
|
events = []
|
||||||
for d in all_data[league]:
|
for d in all_data[league]:
|
||||||
@ -495,11 +514,12 @@ def updateLeagueEvents(api_key, time, logf):
|
|||||||
events.append(event)
|
events.append(event)
|
||||||
leagues_info[league.upper()] = events
|
leagues_info[league.upper()] = events
|
||||||
all_settings['leagues'] = leagues_info
|
all_settings['leagues'] = leagues_info
|
||||||
#print(all_settings['leagues'].keys())
|
|
||||||
|
f = open( "csv/{}_games.json".format(time), 'w+' )
|
||||||
json.dump(all_settings, open( "csv/{}_games.json".format(time), 'w+' ))
|
json.dump(all_settings, f)
|
||||||
|
f.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
logf.write(str(e))
|
logf.write(str(e))
|
||||||
@ -507,6 +527,7 @@ def updateLeagueEvents(api_key, time, logf):
|
|||||||
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
def updateSports(api_key, logf):
|
def updateSports(api_key, logf):
|
||||||
@ -613,6 +634,7 @@ if __name__ == '__main__':
|
|||||||
weather_key = api_keys[1].strip()
|
weather_key = api_keys[1].strip()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
weather_key = False
|
weather_key = False
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
logf.write(str(e))
|
logf.write(str(e))
|
||||||
@ -620,6 +642,7 @@ if __name__ == '__main__':
|
|||||||
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -817,13 +840,14 @@ if __name__ == '__main__':
|
|||||||
process.join()
|
process.join()
|
||||||
process.terminate()
|
process.terminate()
|
||||||
update_processes.remove(process)
|
update_processes.remove(process)
|
||||||
print('Number active database caller processes', len(update_processes))
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
logf.write(str(e))
|
logf.write(str(e))
|
||||||
@ -831,7 +855,9 @@ if __name__ == '__main__':
|
|||||||
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 706 B |
269
server.py
269
server.py
@ -23,7 +23,7 @@ import copy
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
import sys
|
import sys
|
||||||
#stock_ticker = StockTicker()
|
#stock_ticker = StockTicker()
|
||||||
#print('API CALLER NOT STARTED')
|
|
||||||
|
|
||||||
#open('log.txt', 'w').close() #wipe logs
|
#open('log.txt', 'w').close() #wipe logs
|
||||||
|
|
||||||
@ -42,13 +42,16 @@ displaying_screensaver = False
|
|||||||
uploading = False
|
uploading = False
|
||||||
screensaver_p = None
|
screensaver_p = None
|
||||||
ticker_stopped = False
|
ticker_stopped = False
|
||||||
professional = json.load(open('csv/display_settings.json', 'r'))[0] == "Professional"
|
|
||||||
|
f = open('csv/display_settings.json', 'r')
|
||||||
|
professional = json.load(f)[0] == "Professional"
|
||||||
|
f.close()
|
||||||
|
|
||||||
command = 300
|
command = 300
|
||||||
tickerList = 0
|
tickerList = 0
|
||||||
DelayTime = 20
|
DelayTime = 20
|
||||||
LastCommand = ''
|
LastCommand = ''
|
||||||
speedTime = 25 #print('save')
|
speedTime = 25
|
||||||
|
|
||||||
LOGO_FOLDER = 'logos/'
|
LOGO_FOLDER = 'logos/'
|
||||||
CSV_FOLDER = 'csv/new/'
|
CSV_FOLDER = 'csv/new/'
|
||||||
@ -57,7 +60,15 @@ ALLOWED_EXTENSIONS = {'csv', 'png'}
|
|||||||
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||||
time.sleep(2) # give the ticker time to initialise
|
time.sleep(2) # give the ticker time to initialise
|
||||||
|
|
||||||
system_info = json.load(open('csv/system_info.json'))
|
f = open('csv/system_info.json', 'w')
|
||||||
|
|
||||||
|
try:
|
||||||
|
system_info = json.load(f)
|
||||||
|
except Exception as e:
|
||||||
|
system_info = {"update_available": False, "first_boot": False}
|
||||||
|
json.dump(system_info, f)
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
ticker.sendline('*') # run startup gif by default
|
ticker.sendline('*') # run startup gif by default
|
||||||
time.sleep(8)
|
time.sleep(8)
|
||||||
@ -65,7 +76,9 @@ if system_info['first_boot']: # let startup message display
|
|||||||
|
|
||||||
ticker.sendline('-')
|
ticker.sendline('-')
|
||||||
system_info['first_boot'] = False
|
system_info['first_boot'] = False
|
||||||
json.dump(system_info, open('csv/system_info.json', 'w'))
|
f = open('csv/system_info.json', 'w')
|
||||||
|
json.dump(system_info,f)
|
||||||
|
f.close()
|
||||||
else:
|
else:
|
||||||
ticker.sendline('A') # run by default
|
ticker.sendline('A') # run by default
|
||||||
|
|
||||||
@ -93,17 +106,23 @@ def index():
|
|||||||
'Sports (Team Stats)','Custom Images', 'Custom GIFs', 'Custom Messages', 'Stocks', 'Crypto', 'Forex']
|
'Sports (Team Stats)','Custom Images', 'Custom GIFs', 'Custom Messages', 'Stocks', 'Crypto', 'Forex']
|
||||||
|
|
||||||
global professional
|
global professional
|
||||||
|
|
||||||
feature_settings = json.load(open('csv/display_settings.json', 'r'))
|
|
||||||
|
|
||||||
print('professional',professional)
|
f = open('csv/display_settings.json', 'r')
|
||||||
|
feature_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not professional:
|
if not professional:
|
||||||
currently_displaying = json.load(open('csv/display_settings.json', 'r'))[1]
|
f = open('csv/display_settings.json', 'r')
|
||||||
|
currently_displaying = json.load(f)[1]
|
||||||
|
f.close()
|
||||||
not_displaying = [f for f in all_features if f not in currently_displaying[0]]
|
not_displaying = [f for f in all_features if f not in currently_displaying[0]]
|
||||||
|
|
||||||
elif professional:
|
elif professional:
|
||||||
currently_displaying = json.load(open('csv/display_settings.json', 'r'))[1]
|
f = open('csv/display_settings.json', 'r')
|
||||||
|
currently_displaying = json.load(f)[1]
|
||||||
|
f.close()
|
||||||
not_displaying = [f for f in all_features if f not in currently_displaying[0] and f not in currently_displaying[1]]
|
not_displaying = [f for f in all_features if f not in currently_displaying[0] and f not in currently_displaying[1]]
|
||||||
|
|
||||||
with open('api_keys.txt', 'r') as f:
|
with open('api_keys.txt', 'r') as f:
|
||||||
@ -117,21 +136,64 @@ def index():
|
|||||||
logos_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos')
|
logos_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos')
|
||||||
LogoList = os.listdir(logos_path)
|
LogoList = os.listdir(logos_path)
|
||||||
|
|
||||||
stocks_settings = json.load(open('csv/stocks_settings.json', 'r'))
|
f = open('csv/stocks_settings.json', 'r')
|
||||||
crypto_settings = json.load(open('csv/crypto_settings.json', 'r'))
|
stocks_settings = json.load(f)
|
||||||
forex_settings = json.load(open('csv/forex_settings.json', 'r'))
|
f.close()
|
||||||
current_weather= json.load(open('csv/current_weather.json', 'r'))
|
|
||||||
daily_weather = json.load(open('csv/daily_weather.json', 'r'))
|
f= open('csv/crypto_settings.json', 'r')
|
||||||
news_settings = json.load(open('csv/news_settings.json', 'r'))
|
crypto_settings = json.load(f)
|
||||||
upcoming_games = json.load(open('csv/upcoming_games.json', 'r'))
|
f.close()
|
||||||
live_games = json.load(open('csv/live_games.json', 'r'))
|
|
||||||
past_games = json.load(open('csv/past_games.json', 'r'))
|
f = open('csv/forex_settings.json', 'r')
|
||||||
team_stats = json.load(open('csv/league_tables.json', 'r'))
|
forex_settings = json.load(f)
|
||||||
image_settings = json.load(open('csv/image_settings.json', 'r'))
|
f.close()
|
||||||
GIF_settings = json.load(open('csv/GIF_settings.json', 'r'))
|
|
||||||
message_settings = json.load(open('csv/message_settings.json', 'r'))
|
f = open('csv/current_weather.json', 'r')
|
||||||
general_settings = json.load(open('csv/general_settings.json', 'r'))
|
current_weather= json.load(f)
|
||||||
system_info = json.load(open('csv/system_info.json', 'r'))
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/daily_weather.json', 'r')
|
||||||
|
daily_weather = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/news_settings.json', 'r')
|
||||||
|
news_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/upcoming_games.json', 'r')
|
||||||
|
upcoming_games = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/live_games.json', 'r')
|
||||||
|
live_games = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/past_games.json', 'r')
|
||||||
|
past_games = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/league_tables.json', 'r')
|
||||||
|
team_stats = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/image_settings.json', 'r')
|
||||||
|
image_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/GIF_settings.json', 'r')
|
||||||
|
GIF_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/message_settings.json', 'r')
|
||||||
|
message_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
f = open('csv/general_settings.json', 'r')
|
||||||
|
general_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try: # incase this doesnt exist
|
try: # incase this doesnt exist
|
||||||
api_keys = api_key2[1]
|
api_keys = api_key2[1]
|
||||||
except:
|
except:
|
||||||
@ -166,15 +228,15 @@ def index():
|
|||||||
'wifi_SSID':wifi_SSID
|
'wifi_SSID':wifi_SSID
|
||||||
}
|
}
|
||||||
|
|
||||||
#print('database caller:', api_caller.isalive())
|
|
||||||
return render_template('index.html', **templateData)
|
return render_template('index.html', **templateData)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def save_displaying(input_settings):
|
def save_displaying(input_settings):
|
||||||
#print('save')
|
|
||||||
global professional
|
global professional
|
||||||
print('save_displaying_input:', input_settings)
|
|
||||||
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)',
|
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)',
|
||||||
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages']
|
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages']
|
||||||
professional = len(input_settings) == 2
|
professional = len(input_settings) == 2
|
||||||
@ -196,7 +258,7 @@ def save_displaying(input_settings):
|
|||||||
|
|
||||||
s = "Professional" if professional else "Standard"
|
s = "Professional" if professional else "Standard"
|
||||||
display_settings = [s] + [input_settings]
|
display_settings = [s] + [input_settings]
|
||||||
print(display_settings)
|
|
||||||
with open('csv/display_settings.json', 'w+') as f:
|
with open('csv/display_settings.json', 'w+') as f:
|
||||||
json.dump(list(display_settings), f)
|
json.dump(list(display_settings), f)
|
||||||
|
|
||||||
@ -230,16 +292,17 @@ def start():
|
|||||||
|
|
||||||
@app.route("/stop")
|
@app.route("/stop")
|
||||||
def stop():
|
def stop():
|
||||||
print('stop')
|
|
||||||
global displaying_screensaver
|
global displaying_screensaver
|
||||||
global ticker
|
global ticker
|
||||||
#global api_caller
|
#global api_caller
|
||||||
global professional
|
global professional
|
||||||
global ticker_stopped
|
global ticker_stopped
|
||||||
|
|
||||||
ticker.sendline('K')
|
|
||||||
|
|
||||||
if not displaying_screensaver:
|
if not displaying_screensaver:
|
||||||
|
ticker.sendline('K')
|
||||||
time.sleep(0.1) # give time for leds to turn off
|
time.sleep(0.1) # give time for leds to turn off
|
||||||
ticker.close()
|
ticker.close()
|
||||||
else:
|
else:
|
||||||
@ -263,10 +326,20 @@ def stop():
|
|||||||
|
|
||||||
@app.route("/update", methods=['PUT','POST'])
|
@app.route("/update", methods=['PUT','POST'])
|
||||||
def update():
|
def update():
|
||||||
system_info = json.load(open('csv/system_info.json', 'r'))
|
|
||||||
system_info["update_available"] = False
|
|
||||||
|
|
||||||
json.dump(system_info, open('csv/system_info.json', 'w+'))
|
f = open('csv/system_info.json', 'w+')
|
||||||
|
try:
|
||||||
|
system_info = json.load(f)
|
||||||
|
except Exception as e:
|
||||||
|
system_info = {"update_available": False, "first_boot": False}
|
||||||
|
|
||||||
|
system_info['update_available'] = False
|
||||||
|
|
||||||
|
json.dump(system_info, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
os.system("./update.sh")
|
os.system("./update.sh")
|
||||||
os.system("sudo reboot now")
|
os.system("sudo reboot now")
|
||||||
return index()
|
return index()
|
||||||
@ -278,13 +351,13 @@ def restart():
|
|||||||
|
|
||||||
@app.route("/reset")
|
@app.route("/reset")
|
||||||
def reset():
|
def reset():
|
||||||
print('reset')
|
|
||||||
os.system("sudo ./setup_config_files.sh")
|
os.system("sudo ./setup_config_files.sh")
|
||||||
return index()
|
return index()
|
||||||
|
|
||||||
@app.route("/save", methods = ['PUT', 'POST', 'GET'])
|
@app.route("/save", methods = ['PUT', 'POST', 'GET'])
|
||||||
def save():
|
def save():
|
||||||
print('save')
|
|
||||||
global uploading
|
global uploading
|
||||||
|
|
||||||
|
|
||||||
@ -293,8 +366,7 @@ def save():
|
|||||||
|
|
||||||
input_settings = json.loads(data)
|
input_settings = json.loads(data)
|
||||||
|
|
||||||
|
|
||||||
print(input_settings)
|
|
||||||
|
|
||||||
save_displaying(input_settings['displaying'])
|
save_displaying(input_settings['displaying'])
|
||||||
|
|
||||||
@ -315,10 +387,9 @@ def save():
|
|||||||
|
|
||||||
images = request.files
|
images = request.files
|
||||||
names = list(request.files.keys())
|
names = list(request.files.keys())
|
||||||
print(names)
|
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
print(name)
|
|
||||||
images[name].save('user_uploads/' +name)
|
images[name].save('user_uploads/' +name)
|
||||||
|
|
||||||
|
|
||||||
@ -332,7 +403,7 @@ def save():
|
|||||||
# saves files uploaded to the webpage for images and GIFs
|
# saves files uploaded to the webpage for images and GIFs
|
||||||
@app.route("/upload", methods = ['PUT', 'POST', 'GET'])
|
@app.route("/upload", methods = ['PUT', 'POST', 'GET'])
|
||||||
def upload():
|
def upload():
|
||||||
print('upload')
|
|
||||||
global uploading
|
global uploading
|
||||||
uploading = True
|
uploading = True
|
||||||
try:
|
try:
|
||||||
@ -344,15 +415,21 @@ def upload():
|
|||||||
images[name].save('user_uploads/' +name)
|
images[name].save('user_uploads/' +name)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
#print(e)
|
|
||||||
uploading = False
|
uploading = False
|
||||||
return index()
|
return index()
|
||||||
|
|
||||||
def remove_old_uploads():
|
def remove_old_uploads():
|
||||||
#remove old files
|
#remove old files
|
||||||
|
|
||||||
image_settings = json.load(open('csv/image_settings.json', 'r'))
|
|
||||||
GIF_settings = json.load(open('csv/GIF_settings.json', 'r'))
|
|
||||||
|
f = open('csv/image_settings.json', 'r')
|
||||||
|
image_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
f = open('csv/GIF_settings.json', 'r')
|
||||||
|
GIF_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
for filename in os.listdir('user_uploads'):
|
for filename in os.listdir('user_uploads'):
|
||||||
if filename not in image_settings['images'] and filename not in GIF_settings['images']:
|
if filename not in image_settings['images'] and filename not in GIF_settings['images']:
|
||||||
os.remove('user_uploads/'+filename)
|
os.remove('user_uploads/'+filename)
|
||||||
@ -365,15 +442,17 @@ def brightness():
|
|||||||
|
|
||||||
data= request.data.decode('utf-8')
|
data= request.data.decode('utf-8')
|
||||||
settings = json.loads(data)
|
settings = json.loads(data)
|
||||||
print(settings)
|
|
||||||
brightness =settings['brightness']
|
brightness =settings['brightness']
|
||||||
|
|
||||||
ticker.sendline(str(int(brightness)-1))
|
ticker.sendline(str(int(brightness)-1))
|
||||||
|
f = open('csv/general_settings.json', 'r')
|
||||||
general_settings = json.load(open('csv/general_settings.json', 'r'))
|
general_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
general_settings['brightness'] = int(brightness)
|
general_settings['brightness'] = int(brightness)
|
||||||
json.dump(general_settings, open('csv/general_settings.json', 'w+'))
|
f = open('csv/general_settings.json', 'w+')
|
||||||
|
json.dump(general_settings, f)
|
||||||
|
f.close()
|
||||||
return index()
|
return index()
|
||||||
|
|
||||||
|
|
||||||
@ -388,7 +467,7 @@ def edit_wpa_sup(country, ssid, pwd):
|
|||||||
|
|
||||||
#remove this line to append to end instead of overwriting all networks
|
#remove this line to append to end instead of overwriting all networks
|
||||||
wpa_lines = wpa_lines[0:3]
|
wpa_lines = wpa_lines[0:3]
|
||||||
print(wpa_lines)
|
|
||||||
|
|
||||||
# create new file from scratch
|
# create new file from scratch
|
||||||
wpa_lines = []
|
wpa_lines = []
|
||||||
@ -404,7 +483,7 @@ def edit_wpa_sup(country, ssid, pwd):
|
|||||||
wpa_lines.append('}\n')
|
wpa_lines.append('}\n')
|
||||||
|
|
||||||
wpa_string = ''.join(wpa_lines)
|
wpa_string = ''.join(wpa_lines)
|
||||||
print(wpa_string)
|
|
||||||
current_wpa = open('/etc/wpa_supplicant/wpa_supplicant.conf', 'w+')
|
current_wpa = open('/etc/wpa_supplicant/wpa_supplicant.conf', 'w+')
|
||||||
current_wpa.write(wpa_string)
|
current_wpa.write(wpa_string)
|
||||||
|
|
||||||
@ -413,17 +492,20 @@ def edit_wpa_sup(country, ssid, pwd):
|
|||||||
def set_wifi():
|
def set_wifi():
|
||||||
|
|
||||||
data= request.data.decode('utf-8')
|
data= request.data.decode('utf-8')
|
||||||
print(str(data))
|
|
||||||
settings = json.loads(data)
|
settings = json.loads(data)
|
||||||
|
|
||||||
country = settings['country'].upper()
|
country = settings['country'].upper()
|
||||||
ssid = settings['ssid']
|
ssid = settings['ssid']
|
||||||
pwd = settings['pwd']
|
pwd = settings['pwd']
|
||||||
|
|
||||||
general_settings = json.load(open('csv/general_settings.json', 'r'))
|
f = open('csv/general_settings.json', 'r')
|
||||||
|
general_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
general_settings['country_code'] = country
|
general_settings['country_code'] = country
|
||||||
json.dump(general_settings, open('csv/general_settings.json', 'w+'))
|
f = open('csv/general_settings.json', 'w+')
|
||||||
|
json.dump(general_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
edit_wpa_sup(country, ssid, pwd)
|
edit_wpa_sup(country, ssid, pwd)
|
||||||
# resstart netoworking
|
# resstart netoworking
|
||||||
@ -445,14 +527,14 @@ def set_wifi():
|
|||||||
#return True
|
#return True
|
||||||
#except subprocess.CalledProcessError:
|
#except subprocess.CalledProcessError:
|
||||||
# grep did not match any lines
|
# grep did not match any lines
|
||||||
#print("No wireless networks connected")
|
|
||||||
#return False
|
#return False
|
||||||
|
|
||||||
def edit_hosts(hostname):
|
def edit_hosts(hostname):
|
||||||
current_hosts = open('/etc/hosts')
|
current_hosts = open('/etc/hosts')
|
||||||
|
|
||||||
hosts_lines = current_hosts.readlines()
|
hosts_lines = current_hosts.readlines()
|
||||||
print(hosts_lines[5])
|
|
||||||
|
|
||||||
hosts_lines[5] = '127.0.1.1 {}'.format(hostname)
|
hosts_lines[5] = '127.0.1.1 {}'.format(hostname)
|
||||||
|
|
||||||
@ -468,16 +550,20 @@ def hostname():
|
|||||||
data= request.data.decode('utf-8')
|
data= request.data.decode('utf-8')
|
||||||
settings = json.loads(data)
|
settings = json.loads(data)
|
||||||
hostname = settings['hostname']
|
hostname = settings['hostname']
|
||||||
print('hostname', hostname)
|
|
||||||
|
|
||||||
edit_hosts(hostname)
|
edit_hosts(hostname)
|
||||||
os.system("sudo hostnamectl set-hostname {}".format(hostname))
|
os.system("sudo hostnamectl set-hostname {}".format(hostname))
|
||||||
os.system("sudo systemctl restart avahi-daemon")
|
os.system("sudo systemctl restart avahi-daemon")
|
||||||
|
|
||||||
general_settings = json.load(open('csv/general_settings.json', 'r'))
|
f = open('csv/general_settings.json', 'r')
|
||||||
|
general_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
general_settings['hostname'] = hostname
|
general_settings['hostname'] = hostname
|
||||||
json.dump(general_settings, open('csv/general_settings.json', 'w+'))
|
f = open('csv/general_settings.json', 'w+')
|
||||||
|
json.dump(general_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
return index()
|
return index()
|
||||||
|
|
||||||
@ -489,14 +575,14 @@ def saveWeatherAPIKey():
|
|||||||
settings = json.loads(data)
|
settings = json.loads(data)
|
||||||
|
|
||||||
key = settings['api_key']
|
key = settings['api_key']
|
||||||
print(key)
|
|
||||||
with open('./api_keys.txt') as f:
|
with open('./api_keys.txt') as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
if len(lines) == 1:
|
if len(lines) == 1:
|
||||||
lines.append(str(key))
|
lines.append(str(key))
|
||||||
elif len(lines) == 2:
|
elif len(lines) == 2:
|
||||||
lines[1] = str(key)
|
lines[1] = str(key)
|
||||||
print(lines)
|
|
||||||
with open('./api_keys.txt', 'w') as f:
|
with open('./api_keys.txt', 'w') as f:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
@ -565,7 +651,7 @@ def save_trade_settings(input_settings):
|
|||||||
filename = input_settings['feature'].lower() + '_settings.json'
|
filename = input_settings['feature'].lower() + '_settings.json'
|
||||||
f = open('csv/' + filename, 'r')
|
f = open('csv/' + filename, 'r')
|
||||||
current_settings = json.load(f)
|
current_settings = json.load(f)
|
||||||
print(input_settings)
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
current_settings['speed'] = input_settings['speed'].lower()
|
current_settings['speed'] = input_settings['speed'].lower()
|
||||||
@ -598,13 +684,14 @@ def save_trade_settings(input_settings):
|
|||||||
|
|
||||||
def save_weather_settings(input_settings):
|
def save_weather_settings(input_settings):
|
||||||
|
|
||||||
print(input_settings)
|
|
||||||
|
|
||||||
|
|
||||||
filename = 'current_weather.json' if input_settings['feature'] == 'Current Weather' else 'daily_weather.json'
|
filename = 'current_weather.json' if input_settings['feature'] == 'Current Weather' else 'daily_weather.json'
|
||||||
print(filename)
|
|
||||||
|
f = open('csv/' + filename, 'r')
|
||||||
current_settings = json.load(open('csv/' + filename, 'r'))
|
current_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
current_settings['speed'] = input_settings['speed'].lower()
|
current_settings['speed'] = input_settings['speed'].lower()
|
||||||
current_settings['speed2'] = input_settings['speed2'].lower()
|
current_settings['speed2'] = input_settings['speed2'].lower()
|
||||||
@ -625,7 +712,9 @@ def save_weather_settings(input_settings):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
current_settings = combine_dict(current_settings, input_settings['locations'], 'locations')
|
current_settings = combine_dict(current_settings, input_settings['locations'], 'locations')
|
||||||
json.dump(current_settings, open('csv/' + filename, 'w+'))
|
f = open('csv/' + filename, 'w+')
|
||||||
|
json.dump(current_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
#api_caller.sendline('w')
|
#api_caller.sendline('w')
|
||||||
f = open('csv/last_updates.json', 'r')
|
f = open('csv/last_updates.json', 'r')
|
||||||
@ -641,10 +730,11 @@ def save_weather_settings(input_settings):
|
|||||||
|
|
||||||
def save_news_settings(input_settings):
|
def save_news_settings(input_settings):
|
||||||
filename = 'news_settings.json'
|
filename = 'news_settings.json'
|
||||||
|
f = open('csv/' + filename, 'r')
|
||||||
|
current_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
current_settings = json.load(open('csv/' + filename, 'r'))
|
|
||||||
|
|
||||||
print(current_settings)
|
|
||||||
|
|
||||||
current_settings['speed'] = input_settings['speed'].lower()
|
current_settings['speed'] = input_settings['speed'].lower()
|
||||||
current_settings['speed2'] = input_settings['speed2'].lower()
|
current_settings['speed2'] = input_settings['speed2'].lower()
|
||||||
@ -658,9 +748,10 @@ def save_news_settings(input_settings):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(current_settings)
|
|
||||||
|
f = open('csv/' + filename, 'w+')
|
||||||
json.dump(current_settings, open('csv/' + filename, 'w+'))
|
json.dump(current_settings, f)
|
||||||
|
f.close()
|
||||||
#api_caller.sendline('n')
|
#api_caller.sendline('n')
|
||||||
f = open('csv/last_updates.json', 'r')
|
f = open('csv/last_updates.json', 'r')
|
||||||
last_updates = json.load(f)
|
last_updates = json.load(f)
|
||||||
@ -688,8 +779,10 @@ def save_sports_settings(input_settings):
|
|||||||
elif feature == 'Sports (Team Stats)':
|
elif feature == 'Sports (Team Stats)':
|
||||||
filename = 'league_tables.json'
|
filename = 'league_tables.json'
|
||||||
update_key = 'sports_t'
|
update_key = 'sports_t'
|
||||||
|
|
||||||
current_settings = json.load(open('csv/' + filename, 'r'))
|
f = open('csv/' + filename, 'r')
|
||||||
|
current_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
current_settings['speed'] = input_settings['speed'].lower()
|
current_settings['speed'] = input_settings['speed'].lower()
|
||||||
current_settings['speed2'] = input_settings['speed2'].lower()
|
current_settings['speed2'] = input_settings['speed2'].lower()
|
||||||
@ -699,7 +792,9 @@ def save_sports_settings(input_settings):
|
|||||||
|
|
||||||
current_settings = combine_dict(current_settings, input_settings['leagues'], 'leagues')
|
current_settings = combine_dict(current_settings, input_settings['leagues'], 'leagues')
|
||||||
|
|
||||||
json.dump(current_settings, open('csv/' + filename, 'w+'))
|
f = open('csv/' + filename, 'w+')
|
||||||
|
json.dump(current_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
#api_caller.sendline('S')
|
#api_caller.sendline('S')
|
||||||
f = open('csv/last_updates.json', 'r')
|
f = open('csv/last_updates.json', 'r')
|
||||||
@ -726,29 +821,31 @@ def save_image_settings(input_settings):
|
|||||||
|
|
||||||
|
|
||||||
del current_settings['feature']
|
del current_settings['feature']
|
||||||
json.dump(current_settings, open('csv/' + filename, 'w+'))
|
f = open('csv/' + filename, 'w+')
|
||||||
|
json.dump(current_settings, f)
|
||||||
|
f.close()
|
||||||
remove_old_uploads()
|
remove_old_uploads()
|
||||||
|
|
||||||
|
|
||||||
def save_message_settings(input_settings):
|
def save_message_settings(input_settings):
|
||||||
|
|
||||||
current_settings = json.load(open('csv/message_settings.json', 'r'))
|
f = open('csv/message_settings.json', 'r')
|
||||||
|
current_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
new_settings = copy.deepcopy(input_settings)
|
new_settings = copy.deepcopy(input_settings)
|
||||||
print(current_settings)
|
|
||||||
print()
|
|
||||||
print(input_settings)
|
|
||||||
print()
|
|
||||||
for i,IS in enumerate(input_settings['messages']):
|
for i,IS in enumerate(input_settings['messages']):
|
||||||
|
|
||||||
# check if this is in current_settings
|
# check if this is in current_settings
|
||||||
for CS in current_settings['messages']:
|
for CS in current_settings['messages']:
|
||||||
if IS['name'] == CS['name']:
|
if IS['name'] == CS['name']:
|
||||||
new_settings['messages'][i] = CS
|
new_settings['messages'][i] = CS
|
||||||
print(CS)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
print(new_settings)
|
f = open('csv/message_settings.json', 'w+')
|
||||||
json.dump(new_settings, open('csv/message_settings.json', 'w+'))
|
json.dump(new_settings, f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
459
stockTicker.py
459
stockTicker.py
@ -57,10 +57,10 @@ class StockTicker():
|
|||||||
options.chain_length = 2
|
options.chain_length = 2
|
||||||
options.parallel = 1
|
options.parallel = 1
|
||||||
options.hardware_mapping = 'adafruit-hat' # If you have an Adafruit HAT: 'adafruit-hat'
|
options.hardware_mapping = 'adafruit-hat' # If you have an Adafruit HAT: 'adafruit-hat'
|
||||||
options.gpio_slowdown = 1
|
options.gpio_slowdown = 2
|
||||||
options.brightness = self.brightness
|
options.brightness = self.brightness
|
||||||
self.matrix = RGBMatrix(options = options)
|
self.matrix = RGBMatrix(options = options)
|
||||||
print(dir(self.matrix))
|
|
||||||
#sys.exit()
|
#sys.exit()
|
||||||
self.points = True # display crypto change in points or percent
|
self.points = True # display crypto change in points or percent
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ class StockTicker():
|
|||||||
return kill
|
return kill
|
||||||
|
|
||||||
def updateMultiple(self, options):
|
def updateMultiple(self, options):
|
||||||
print('options', options)
|
|
||||||
for option in options:
|
for option in options:
|
||||||
|
|
||||||
|
|
||||||
@ -344,7 +344,9 @@ class StockTicker():
|
|||||||
update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],))
|
update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],))
|
||||||
update_process.start()
|
update_process.start()
|
||||||
|
|
||||||
settings = json.load(open(self.JSONs[options[(i) % len(options)]]))
|
f = open(self.JSONs[options[(i) % len(options)]])
|
||||||
|
settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
self.set_delay(settings['speed'])
|
self.set_delay(settings['speed'])
|
||||||
animation = settings['animation'].lower()
|
animation = settings['animation'].lower()
|
||||||
@ -615,7 +617,7 @@ class StockTicker():
|
|||||||
kind, content, delay = row
|
kind, content, delay = row
|
||||||
delays.append(delay)
|
delays.append(delay)
|
||||||
kinds.append(kind)
|
kinds.append(kind)
|
||||||
print(kind, content, delay)
|
|
||||||
if kind == 'text':
|
if kind == 'text':
|
||||||
images.append(self.textImage(content, font, 255, 255, 0, True, w_buff = 50))
|
images.append(self.textImage(content, font, 255, 255, 0, True, w_buff = 50))
|
||||||
elif kind == 'image':
|
elif kind == 'image':
|
||||||
@ -970,15 +972,17 @@ class StockTicker():
|
|||||||
image_list.append(self.blank)
|
image_list.append(self.blank)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
finalDisplayImage = self.stitchImage(image_list)
|
finalDisplayImage = self.stitchImage(image_list)
|
||||||
|
|
||||||
@ -1042,13 +1046,15 @@ class StockTicker():
|
|||||||
image_list.append(self.blank)
|
image_list.append(self.blank)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
finalDisplayImage = self.stitchImage(image_list)
|
finalDisplayImage = self.stitchImage(image_list)
|
||||||
self.blank = Image.new('RGB', (10, 32))
|
self.blank = Image.new('RGB', (10, 32))
|
||||||
@ -1116,28 +1122,36 @@ class StockTicker():
|
|||||||
image_list.append(new_im)
|
image_list.append(new_im)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
logf = open('log.txt', "a")
|
||||||
|
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))
|
||||||
|
logf.write('. file: ' + fname)
|
||||||
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
|
logf.write('. type: ' + str(exc_type))
|
||||||
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
image_list.append(midFrame)
|
image_list.append(midFrame)
|
||||||
image_list.append(self.blank)
|
image_list.append(self.blank)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
finalDisplayImage = self.stitchImage(image_list)
|
finalDisplayImage = self.stitchImage(image_list)
|
||||||
|
|
||||||
return finalDisplayImage
|
return finalDisplayImage
|
||||||
|
|
||||||
def getForexProfessional(self):
|
def getForexProfessional(self):
|
||||||
print('forex prof')
|
|
||||||
self.blank = Image.new('RGB', (0, 16))
|
self.blank = Image.new('RGB', (0, 16))
|
||||||
f = open('csv/forex_settings.json', 'r')
|
f = open('csv/forex_settings.json', 'r')
|
||||||
all_forex_settings = json.load(f)
|
all_forex_settings = json.load(f)
|
||||||
@ -1163,9 +1177,6 @@ class StockTicker():
|
|||||||
current = float(forex_settings[sb]['current'])
|
current = float(forex_settings[sb]['current'])
|
||||||
change = float(forex_settings[sb]['24hr_change'])
|
change = float(forex_settings[sb]['24hr_change'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
arrow, change = self.getArrow(change, professional = True)
|
arrow, change = self.getArrow(change, professional = True)
|
||||||
|
|
||||||
|
|
||||||
@ -1201,23 +1212,30 @@ class StockTicker():
|
|||||||
image_list.append(new_im)
|
image_list.append(new_im)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
logf = open('log.txt', "a")
|
||||||
|
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))
|
||||||
|
logf.write('. file: ' + fname)
|
||||||
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
|
logf.write('. type: ' + str(exc_type))
|
||||||
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
image_list.append(midFrame)
|
image_list.append(midFrame)
|
||||||
|
|
||||||
image_list.append(self.blank)
|
image_list.append(self.blank)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
logf = open('log.txt', "a")
|
||||||
|
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
finalDisplayImage = self.stitchImage(image_list)
|
finalDisplayImage = self.stitchImage(image_list)
|
||||||
self.blank = Image.new('RGB', (10, 32))
|
self.blank = Image.new('RGB', (10, 32))
|
||||||
@ -1256,7 +1274,7 @@ class StockTicker():
|
|||||||
percent_change = '%.2f' % abs(float(info['percent_change'])) + '%'
|
percent_change = '%.2f' % abs(float(info['percent_change'])) + '%'
|
||||||
point_change = '%.2f' % abs(change)
|
point_change = '%.2f' % abs(change)
|
||||||
|
|
||||||
print(percent_change, point_change)
|
|
||||||
|
|
||||||
current = '%.2f' % float(info['current']) #TEXT
|
current = '%.2f' % float(info['current']) #TEXT
|
||||||
|
|
||||||
@ -1279,7 +1297,7 @@ class StockTicker():
|
|||||||
logo = self.openImage(os.path.join(logos_path, ticker + '.png'))
|
logo = self.openImage(os.path.join(logos_path, ticker + '.png'))
|
||||||
stitchedStock = self.stitchImage([logo,midFrame])
|
stitchedStock = self.stitchImage([logo,midFrame])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
|
||||||
stitchedStock = midFrame
|
stitchedStock = midFrame
|
||||||
else:
|
else:
|
||||||
stitchedStock = midFrame
|
stitchedStock = midFrame
|
||||||
@ -1289,14 +1307,17 @@ class StockTicker():
|
|||||||
|
|
||||||
image_list.append(self.blank)
|
image_list.append(self.blank)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
finalDisplayImage = self.stitchImage(image_list)
|
finalDisplayImage = self.stitchImage(image_list)
|
||||||
@ -1373,14 +1394,15 @@ class StockTicker():
|
|||||||
image_list.append(self.blank)
|
image_list.append(self.blank)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
finalDisplayImage = self.stitchImage(image_list)
|
finalDisplayImage = self.stitchImage(image_list)
|
||||||
|
|
||||||
@ -1390,7 +1412,10 @@ class StockTicker():
|
|||||||
|
|
||||||
def getNewsImage(self):
|
def getNewsImage(self):
|
||||||
|
|
||||||
all_settings = json.load(open('csv/news_settings.json', 'r'))
|
|
||||||
|
f = open('csv/news_settings.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
if all_settings['title']:
|
if all_settings['title']:
|
||||||
title_img = self.openImage('feature_titles/news.png')
|
title_img = self.openImage('feature_titles/news.png')
|
||||||
@ -1455,21 +1480,24 @@ class StockTicker():
|
|||||||
image_list.append(img)
|
image_list.append(img)
|
||||||
image_list.append(self.blank)
|
image_list.append(self.blank)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
news_image = self.stitchImage(image_list)
|
news_image = self.stitchImage(image_list)
|
||||||
|
|
||||||
return news_image
|
return news_image
|
||||||
|
|
||||||
def getNewsProfessional(self):
|
def getNewsProfessional(self):
|
||||||
|
|
||||||
all_settings = json.load(open('csv/news_settings.json', 'r'))
|
f = open('csv/news_settings.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
if all_settings['title']:
|
if all_settings['title']:
|
||||||
title_img = self.openImage('feature_titles/small_feature_titles/news.png')
|
title_img = self.openImage('feature_titles/small_feature_titles/news.png')
|
||||||
@ -1541,13 +1569,15 @@ class StockTicker():
|
|||||||
image_list.append(img)
|
image_list.append(img)
|
||||||
image_list.append(blank)
|
image_list.append(blank)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
news_image = self.stitchImage(image_list)
|
news_image = self.stitchImage(image_list)
|
||||||
|
|
||||||
return news_image
|
return news_image
|
||||||
@ -1558,11 +1588,16 @@ class StockTicker():
|
|||||||
filepath = 'csv/{}_games.json'.format(time)
|
filepath = 'csv/{}_games.json'.format(time)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(time)
|
|
||||||
filepath = 'csv/upcoming_games.json'
|
filepath = 'csv/upcoming_games.json'
|
||||||
|
|
||||||
|
|
||||||
all_settings = json.load(open(filepath, 'r'))
|
|
||||||
|
|
||||||
|
f = open(filepath, 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
title_img = self.openImage('feature_titles/sports_'+ time + '.png')
|
title_img = self.openImage('feature_titles/sports_'+ time + '.png')
|
||||||
if all_settings['title']:
|
if all_settings['title']:
|
||||||
title_img = self.openImage('feature_titles/sports_{}.png'.format(time))
|
title_img = self.openImage('feature_titles/sports_{}.png'.format(time))
|
||||||
@ -1578,8 +1613,6 @@ class StockTicker():
|
|||||||
|
|
||||||
for league in leagues:
|
for league in leagues:
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
|
||||||
x_offset = 0
|
x_offset = 0
|
||||||
img = Image.new('RGB', (10000, 32))
|
img = Image.new('RGB', (10000, 32))
|
||||||
league_info = leagues_info[league]
|
league_info = leagues_info[league]
|
||||||
@ -1597,7 +1630,6 @@ class StockTicker():
|
|||||||
large_font = ImageFont.load("./fonts/9x18B.pil")
|
large_font = ImageFont.load("./fonts/9x18B.pil")
|
||||||
|
|
||||||
sports_info = self.readSportsCSV(league)
|
sports_info = self.readSportsCSV(league)
|
||||||
print(sports_info)
|
|
||||||
|
|
||||||
buff_size = 25
|
buff_size = 25
|
||||||
|
|
||||||
@ -1611,8 +1643,6 @@ class StockTicker():
|
|||||||
|
|
||||||
dateEvent = match['date'].replace('-', '.')
|
dateEvent = match['date'].replace('-', '.')
|
||||||
|
|
||||||
#rond = match['round']
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@ -1700,14 +1730,15 @@ class StockTicker():
|
|||||||
imgs.append(img)
|
imgs.append(img)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1715,8 +1746,10 @@ class StockTicker():
|
|||||||
|
|
||||||
def getLeagueTableImage(self, league = False):
|
def getLeagueTableImage(self, league = False):
|
||||||
|
|
||||||
|
f = open('csv/league_tables.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
all_settings = json.load(open('csv/league_tables.json', 'r'))
|
|
||||||
|
|
||||||
leagues_info = all_settings['leagues']
|
leagues_info = all_settings['leagues']
|
||||||
|
|
||||||
@ -1766,7 +1799,15 @@ class StockTicker():
|
|||||||
x_offset += logo.size[0] + 2
|
x_offset += logo.size[0] + 2
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
print('no logo for:', team['name'])
|
logf = open('log.txt', "a")
|
||||||
|
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))
|
||||||
|
logf.write('. file: ' + fname)
|
||||||
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
|
logf.write('. type: ' + str(exc_type))
|
||||||
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
name_timage = self.textImage(team['name'], med_font, r = 255, g = 255, b = 0)
|
name_timage = self.textImage(team['name'], med_font, r = 255, g = 255, b = 0)
|
||||||
@ -1799,18 +1840,31 @@ class StockTicker():
|
|||||||
imgs.append(img)
|
imgs.append(img)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
return self.stitchImage(imgs)
|
return self.stitchImage(imgs)
|
||||||
|
def convertTemp(self,temp, setting):
|
||||||
|
if setting == 'kelvin':
|
||||||
|
temp = temp+ 273.15
|
||||||
|
elif setting == 'fahrenheit':
|
||||||
|
|
||||||
|
temp = temp*9/5 + 32
|
||||||
|
return temp
|
||||||
|
|
||||||
def getTodayWeatherImage(self):
|
def getTodayWeatherImage(self):
|
||||||
all_settings = json.load(open('csv/current_weather.json', 'r'))
|
|
||||||
|
|
||||||
|
f = open('csv/current_weather.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
if all_settings['title']:
|
if all_settings['title']:
|
||||||
title_img = self.openImage('feature_titles/weather.png')
|
title_img = self.openImage('feature_titles/weather.png')
|
||||||
@ -1840,21 +1894,21 @@ class StockTicker():
|
|||||||
|
|
||||||
weather_dir = './logos/weather_icons'
|
weather_dir = './logos/weather_icons'
|
||||||
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
|
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
|
||||||
temp = current_weather['temp']
|
temp = self.convertTemp(current_weather['temp'], all_settings['temp'])
|
||||||
feels_temp = current_weather['feels_like']
|
feels_temp = self.convertTemp(current_weather['feels_like'], all_settings['temp'])
|
||||||
if all_settings['temp'] == 'kelvin':
|
|
||||||
temp = current_weather['temp'] + 273.15
|
|
||||||
elif all_settings['temp'] == 'fahrenheit':
|
|
||||||
feels_temp = current_weather['feels_like']*9/5 + 32
|
|
||||||
temp = current_weather['temp']*9/5 + 32
|
|
||||||
|
|
||||||
temp_img = self.textImage(str("{0:.0f}".format(temp)), large_font)
|
temp_img = self.textImage(str("{0:.0f}".format(temp)), large_font)
|
||||||
deg_img = self.textImage('o', small_font)
|
deg_img = self.textImage('o', small_font)
|
||||||
main = current_weather['main_weather']
|
main = current_weather['main_weather']
|
||||||
main_img = self.textImage(main.upper(), small_font)
|
main_img = self.textImage(main.upper(), small_font)
|
||||||
feels_img = self.textImage('Feels like:'.upper() + str("{0:.0f}".format(feels_temp)), small_font)
|
feels_img = self.textImage('Feels like:'.upper() + str("{0:.0f}".format(feels_temp)), small_font)
|
||||||
min_img = self.textImage( "{0:.0f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255)
|
|
||||||
max_img = self.textImage( "{0:.0f}".format(current_weather['max_temp']), small_font, r=255, g=0, b=0)
|
min_img = self.textImage( "{0:.0f}".format(self.convertTemp(current_weather['min_temp'], all_settings['temp'])), small_font, r=0, g=0, b=255)
|
||||||
|
max_img = self.textImage( "{0:.0f}".format(self.convertTemp(current_weather['max_temp'], all_settings['temp'])), small_font, r=255, g=0, b=0)
|
||||||
|
|
||||||
|
|
||||||
hum_img = Image.open(weather_dir + '/humidity.png')
|
hum_img = Image.open(weather_dir + '/humidity.png')
|
||||||
htext_img = self.textImage(str(current_weather['humidity']) + '%', small_font)
|
htext_img = self.textImage(str(current_weather['humidity']) + '%', small_font)
|
||||||
uv_img = Image.open(weather_dir + '/uv.png')
|
uv_img = Image.open(weather_dir + '/uv.png')
|
||||||
@ -1935,19 +1989,24 @@ class StockTicker():
|
|||||||
imgs.append(img)
|
imgs.append(img)
|
||||||
imgs.append(self.blank)
|
imgs.append(self.blank)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
return self.stitchImage(imgs)
|
return self.stitchImage(imgs)
|
||||||
|
|
||||||
def getTodayWeatherProfessional(self):
|
def getTodayWeatherProfessional(self):
|
||||||
all_settings = json.load(open('csv/current_weather.json', 'r'))
|
|
||||||
|
|
||||||
|
f = open('csv/current_weather.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
if all_settings['title']:
|
if all_settings['title']:
|
||||||
title_img = self.openImage('feature_titles/small_feature_titles/weather.png')
|
title_img = self.openImage('feature_titles/small_feature_titles/weather.png')
|
||||||
@ -2016,11 +2075,8 @@ class StockTicker():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
temp = current_weather['temp']
|
temp = self.convertTemp(current_weather['temp'], all_settings['temp'])
|
||||||
if all_settings['temp'] == 'kelvin':
|
|
||||||
temp = current_weather['temp'] + 273.15
|
|
||||||
elif all_settings['temp'] == 'fahrenheit':
|
|
||||||
temp = current_weather['temp']*9/5 + 32
|
|
||||||
|
|
||||||
temp_img = self.textImage(str("{0:.0f}".format(temp)), font)
|
temp_img = self.textImage(str("{0:.0f}".format(temp)), font)
|
||||||
img.paste(temp_img, (x_offset,3))
|
img.paste(temp_img, (x_offset,3))
|
||||||
@ -2032,10 +2088,10 @@ class StockTicker():
|
|||||||
|
|
||||||
x_offset += deg_img.size[0] -2
|
x_offset += deg_img.size[0] -2
|
||||||
|
|
||||||
min_img = self.textImage( "{0:.0f}".format(current_weather['min_temp']), small_font, r=0, g=0, b=255)
|
min_img = self.textImage( "{0:.0f}".format(self.convertTemp(current_weather['min_temp'], all_settings['temp'])), small_font, r=0, g=0, b=255)
|
||||||
img.paste(min_img, (x_offset+2, 2))
|
img.paste(min_img, (x_offset+2, 2))
|
||||||
|
|
||||||
max_img = self.textImage( "{0:.0f}".format(current_weather['max_temp']), small_font, r=255, g=0, b=0)
|
max_img = self.textImage( "{0:.0f}".format(self.convertTemp(current_weather['max_temp'], all_settings['temp'])), small_font, r=255, g=0, b=0)
|
||||||
img.paste(max_img, (x_offset+2, 8))
|
img.paste(max_img, (x_offset+2, 8))
|
||||||
|
|
||||||
x_offset += max_img.size[0] + 2
|
x_offset += max_img.size[0] + 2
|
||||||
@ -2077,13 +2133,15 @@ class StockTicker():
|
|||||||
image_list.append(img)
|
image_list.append(img)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
return self.stitchImage(image_list)
|
return self.stitchImage(image_list)
|
||||||
|
|
||||||
def getDailyWeatherImageAlt(self):
|
def getDailyWeatherImageAlt(self):
|
||||||
@ -2230,8 +2288,10 @@ class StockTicker():
|
|||||||
|
|
||||||
def getDailyWeatherImage(self):
|
def getDailyWeatherImage(self):
|
||||||
|
|
||||||
|
f = open('csv/daily_weather.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
all_settings = json.load(open('csv/daily_weather.json', 'r'))
|
|
||||||
|
|
||||||
if all_settings['title']:
|
if all_settings['title']:
|
||||||
title_img = self.openImage('feature_titles/forecast.png')
|
title_img = self.openImage('feature_titles/forecast.png')
|
||||||
@ -2240,13 +2300,12 @@ class StockTicker():
|
|||||||
imgs = []
|
imgs = []
|
||||||
|
|
||||||
|
|
||||||
|
f = open('csv/daily_weather.json', 'r')
|
||||||
daily_weathers = json.load(open('csv/daily_weather.json', 'r'))
|
daily_weathers = json.load(f)
|
||||||
|
f.close()
|
||||||
locations = list(daily_weathers['locations'].keys())
|
locations = list(daily_weathers['locations'].keys())
|
||||||
|
|
||||||
for i, location in enumerate(locations):
|
for i, location in enumerate(locations):
|
||||||
print(location)
|
|
||||||
try:
|
try:
|
||||||
img = Image.new('RGB', (1000, 32))
|
img = Image.new('RGB', (1000, 32))
|
||||||
|
|
||||||
@ -2271,25 +2330,18 @@ class StockTicker():
|
|||||||
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
|
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
|
||||||
|
|
||||||
|
|
||||||
temp = daily_weather[0]['temp']
|
temp = self.convertTemp(daily_weather[0]['temp'], daily_weathers['temp'])
|
||||||
min_temp = daily_weather[0]['min_temp']
|
min_temp = self.convertTemp(daily_weather[0]['min_temp'], daily_weathers['temp'])
|
||||||
max_temp = daily_weather[0]['max_temp']
|
max_temp = self.convertTemp(daily_weather[0]['max_temp'], daily_weathers['temp'])
|
||||||
|
|
||||||
if daily_weathers['temp'] == 'kelvin':
|
|
||||||
temp = daily_weather[0]['temp'] + 273.15
|
|
||||||
min_temp = daily_weather[0]['min_temp'] + 273.15
|
|
||||||
max_temp = daily_weather[0]['max_temp'] + 273.15
|
|
||||||
elif daily_weathers['temp'] == 'fahrenheit':
|
|
||||||
temp = daily_weather[0]['temp']*9/5 + 32
|
|
||||||
min_temp = daily_weather[0]['min_temp']*9/5 + 32
|
|
||||||
max_temp = daily_weather[0]['max_temp']*9/5 + 32
|
|
||||||
|
|
||||||
|
|
||||||
temp_img = self.textImage(str("{0:.0f}".format(temp)), large_font)
|
temp_img = self.textImage(str("{0:.0f}".format(temp)), large_font)
|
||||||
deg_img = self.textImage('o', small_font)
|
deg_img = self.textImage('o', small_font)
|
||||||
|
|
||||||
min_img = self.textImage( "{0:.0f}".format(min_temp), small_font, r=0, g=0, b=255)
|
min_img = self.textImage( "{0:.0f}".format(min_temp, daily_weathers['temp']), small_font, r=0, g=0, b=255)
|
||||||
max_img = self.textImage( "{0:.0f}".format(max_temp), small_font, r=255, g=0, b=0)
|
max_img = self.textImage( "{0:.0f}".format(max_temp, daily_weathers['temp']), small_font, r=255, g=0, b=0)
|
||||||
main = daily_weather[0]['main_weather']
|
main = daily_weather[0]['main_weather']
|
||||||
main_img = self.textImage(main.upper(), small_font)
|
main_img = self.textImage(main.upper(), small_font)
|
||||||
|
|
||||||
@ -2390,7 +2442,7 @@ class StockTicker():
|
|||||||
#img.paste(wind_img, (96,0))
|
#img.paste(wind_img, (96,0))
|
||||||
#img.paste(wtext_img, (109,0))
|
#img.paste(wtext_img, (109,0))
|
||||||
#img.paste(date_img, (70, 0))
|
#img.paste(date_img, (70, 0))
|
||||||
x_offset = 70
|
x_offset = 77
|
||||||
|
|
||||||
for i in range(1,len(daily_weather)-1):
|
for i in range(1,len(daily_weather)-1):
|
||||||
weekday = weekdays[(datetime.today().weekday() + i)%7]
|
weekday = weekdays[(datetime.today().weekday() + i)%7]
|
||||||
@ -2405,17 +2457,10 @@ class StockTicker():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
min_temp = weather['min_temp']
|
min_temp = self.convertTemp(weather['min_temp'], daily_weathers['temp'])
|
||||||
max_temp = weather['max_temp']
|
max_temp = self.convertTemp(weather['max_temp'], daily_weathers['temp'])
|
||||||
|
|
||||||
|
|
||||||
if daily_weathers['temp'] == 'kelvin':
|
|
||||||
|
|
||||||
min_temp = weather['min_temp'] + 273.15
|
|
||||||
max_temp = weather['max_temp'] + 273.15
|
|
||||||
elif daily_weathers['temp'] == 'fahrenheit':
|
|
||||||
|
|
||||||
min_temp = weather['min_temp']*9/5 + 32
|
|
||||||
max_temp = weather['max_temp']*9/5 + 32
|
|
||||||
|
|
||||||
weather_img = Image.open(weather_dir + '/small_icons/' + weather_ids[main] + '.png')
|
weather_img = Image.open(weather_dir + '/small_icons/' + weather_ids[main] + '.png')
|
||||||
min_img = self.textImage( "{0:.0f}".format(min_temp), small_font, r=0, g=0, b=255)
|
min_img = self.textImage( "{0:.0f}".format(min_temp), small_font, r=0, g=0, b=255)
|
||||||
@ -2435,16 +2480,15 @@ class StockTicker():
|
|||||||
imgs.append(self.blank)
|
imgs.append(self.blank)
|
||||||
# add the image text
|
# add the image text
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
return self.stitchImage(imgs)
|
return self.stitchImage(imgs)
|
||||||
|
|
||||||
@ -2467,8 +2511,6 @@ class StockTicker():
|
|||||||
|
|
||||||
def displayDailyWeatherAlt(self):
|
def displayDailyWeatherAlt(self):
|
||||||
img0, img1 = self.getDailyWeatherImageAlt()
|
img0, img1 = self.getDailyWeatherImageAlt()
|
||||||
#img = stock_ticker.getTodayWeatherImage()
|
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
@ -2483,14 +2525,10 @@ class StockTicker():
|
|||||||
while offset_x > 64-img_width:
|
while offset_x > 64-img_width:
|
||||||
offset_x -= 1
|
offset_x -= 1
|
||||||
|
|
||||||
|
|
||||||
self.setImage(image, offset_x = offset_x, offset_y = offset_y, min_x = 64, min_y = 9)
|
self.setImage(image, offset_x = offset_x, offset_y = offset_y, min_x = 64, min_y = 9)
|
||||||
if offset_x + img_width < self.matrix.width: # if the image is ending
|
if offset_x + img_width < self.matrix.width: # if the image is ending
|
||||||
self.setImage(image, offset_x = offset_x + img_width, offset_y = offset_y, min_x = 64, min_y = 9)
|
self.setImage(image, offset_x = offset_x + img_width, offset_y = offset_y, min_x = 64, min_y = 9)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
msg = getInput()
|
msg = getInput()
|
||||||
if msg == 'K':
|
if msg == 'K':
|
||||||
@ -2509,8 +2547,6 @@ class StockTicker():
|
|||||||
|
|
||||||
def getUserImages(self):
|
def getUserImages(self):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
f = open('csv/image_settings.json', 'r')
|
f = open('csv/image_settings.json', 'r')
|
||||||
all_settings = json.load(f)
|
all_settings = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
@ -2520,9 +2556,9 @@ class StockTicker():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
img = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image))
|
img = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image))
|
||||||
print(img)
|
|
||||||
img.thumbnail((99999, 32))
|
img.thumbnail((99999, 32))
|
||||||
print(img)
|
|
||||||
if all_settings['title'] and ind == 0:
|
if all_settings['title'] and ind == 0:
|
||||||
title_img = self.openImage('feature_titles/images.png')
|
title_img = self.openImage('feature_titles/images.png')
|
||||||
imgs.append(self.stitchImage([title_img, img]))
|
imgs.append(self.stitchImage([title_img, img]))
|
||||||
@ -2531,16 +2567,15 @@ class StockTicker():
|
|||||||
imgs.append(img)
|
imgs.append(img)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return imgs
|
return imgs
|
||||||
|
|
||||||
@ -2586,15 +2621,15 @@ class StockTicker():
|
|||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
logf = open('log.txt', "a")
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
logf.write(str(e))
|
||||||
self.logf.write('. file: ' + fname)
|
logf.write('. file: ' + fname)
|
||||||
self.logf.write('. line: ' + str(exc_tb.tb_lineno))
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
self.logf.write('. type: ' + str(exc_type))
|
logf.write('. type: ' + str(exc_type))
|
||||||
self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
|
logf.close()
|
||||||
|
|
||||||
|
|
||||||
#below code stitches title and GIF together
|
#below code stitches title and GIF together
|
||||||
@ -2712,11 +2747,15 @@ class StockTicker():
|
|||||||
#userSettings = [ 'daily_weather']
|
#userSettings = [ 'daily_weather']
|
||||||
#userSettings = ['crypto', 'stocks'] # these wil be read from csv, just for demo
|
#userSettings = ['crypto', 'stocks'] # these wil be read from csv, just for demo
|
||||||
#userSettings = [ 'display_image', 'news'] # these wil be read from csv, just for demo
|
#userSettings = [ 'display_image', 'news'] # these wil be read from csv, just for demo
|
||||||
userSettings = json.load(open('csv/display_settings.json'))
|
|
||||||
if 'Professional'==userSettings[0] and len(userSettings[1][0])>0 and len(userSettings[1][1])>0: #if professional display
|
|
||||||
self.scrollProfessionalAnimated(userSettings[1])
|
f = open('csv/display_settings.json', 'r')
|
||||||
elif len(userSettings[1][0])>0 and 'Standard'==userSettings[0]:
|
user_settings = json.load(f)
|
||||||
self.scrollFunctionsAnimated(userSettings[1][0], animation = 'down')
|
f.close()
|
||||||
|
if 'Professional'==user_settings[0] and len(user_settings[1][0])>0 and len(user_settings[1][1])>0: #if professional display
|
||||||
|
self.scrollProfessionalAnimated(user_settings[1])
|
||||||
|
elif len(user_settings[1][0])>0 and 'Standard'==user_settings[0]:
|
||||||
|
self.scrollFunctionsAnimated(user_settings[1][0], animation = 'down')
|
||||||
|
|
||||||
elif msg == 'b':
|
elif msg == 'b':
|
||||||
userSettings = json.load(open('csv/display_settings.json'))
|
userSettings = json.load(open('csv/display_settings.json'))
|
||||||
@ -2751,41 +2790,27 @@ class StockTicker():
|
|||||||
self.scrollFunctionsAnimated(['Custom Messages'], repeat = True)
|
self.scrollFunctionsAnimated(['Custom Messages'], repeat = True)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
with open('log.txt', "a") as log:
|
try:
|
||||||
try:
|
stock_ticker = StockTicker()
|
||||||
stock_ticker = StockTicker()
|
|
||||||
stock_ticker.logf = log
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#stock_ticker.getLeagueImage('NHL', 'future')
|
|
||||||
#stock_ticker.getCryptoImage()
|
|
||||||
|
|
||||||
#
|
while True:
|
||||||
|
msg = getInput()
|
||||||
#stock_ticker.process_msg('*')
|
stock_ticker.process_msg(msg)
|
||||||
#time.sleep(8)
|
except Exception as e:
|
||||||
|
logf = open('log.txt', "a")
|
||||||
#stock_ticker.process_msg('-')
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
#stock_ticker.process_msg('W')
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
#stock_ticker.process_msg('A')
|
logf.write(str(e))
|
||||||
|
logf.write('. file: ' + fname)
|
||||||
|
logf.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
|
logf.write('. type: ' + str(exc_type))
|
||||||
while True:
|
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
msg = getInput()
|
logf.close()
|
||||||
stock_ticker.process_msg(msg)
|
|
||||||
except Exception as e:
|
|
||||||
print(str(e))
|
|
||||||
|
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
|
||||||
log.write(str(e))
|
|
||||||
log.write('. file: ' + fname)
|
|
||||||
log.write('. line: ' + str(exc_tb.tb_lineno))
|
|
||||||
log.write('. type: ' + str(exc_type))
|
|
||||||
log.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
<a class="navbar-brand" href="#">
|
<a class="navbar-brand" href="#">
|
||||||
|
|
||||||
<img src="{{ url_for('static', filename='images/logo_white.png') }}" class="logo" alt="logo" /><p class="text-white">Version 1.0</p>
|
<img src="{{ url_for('static', filename='images/logo_white.png') }}" class="logo" alt="logo" /><p class="text-white">Version 1.0.1</p>
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user