From e95c854b7920613d7452bf635bfcb8cd5ff231b9 Mon Sep 17 00:00:00 2001 From: Neythen Treloar <33317183+zcqsntr@users.noreply.github.com> Date: Mon, 4 Apr 2022 18:19:23 +0100 Subject: [PATCH 01/13] Update stockTicker.py black screen bug test --- stockTicker.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/stockTicker.py b/stockTicker.py index b4e3520..c05b122 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -286,7 +286,7 @@ class StockTicker(): return kill def updateMultiple(self, options): - print('options', 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.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']) animation = settings['animation'].lower() @@ -970,14 +972,14 @@ class StockTicker(): image_list.append(self.blank) 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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]))) + pass + #exc_type, exc_obj, exc_tb = sys.exc_info() + #fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] + #self.logf.write(str(e)) + #self.logf.write('. file: ' + fname) + #self.logf.write('. line: ' + str(exc_tb.tb_lineno)) + #self.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]))) finalDisplayImage = self.stitchImage(image_list) @@ -1256,7 +1258,7 @@ class StockTicker(): percent_change = '%.2f' % abs(float(info['percent_change'])) + '%' point_change = '%.2f' % abs(change) - print(percent_change, point_change) + current = '%.2f' % float(info['current']) #TEXT @@ -1279,7 +1281,7 @@ class StockTicker(): logo = self.openImage(os.path.join(logos_path, ticker + '.png')) stitchedStock = self.stitchImage([logo,midFrame]) except Exception as e: - print(str(e)) + stitchedStock = midFrame else: stitchedStock = midFrame @@ -1289,13 +1291,14 @@ class StockTicker(): image_list.append(self.blank) 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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]))) + pass + #exc_type, exc_obj, exc_tb = sys.exc_info() + #fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] + #self.logf.write(str(e)) + #self.logf.write('. file: ' + fname) + #self.logf.write('. line: ' + str(exc_tb.tb_lineno)) + #self.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]))) @@ -2777,7 +2780,7 @@ if __name__ == '__main__': msg = getInput() stock_ticker.process_msg(msg) except Exception as e: - print(str(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] From 3eaf0fb3caf48377c85213b828698d5271712972 Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Thu, 7 Apr 2022 18:35:38 +0100 Subject: [PATCH 02/13] black screen fix --- database_caller.py | 150 +++++++++--------- server.py | 241 +++++++++++++++++++---------- stockTicker.py | 377 ++++++++++++++++++++++++--------------------- 3 files changed, 441 insertions(+), 327 deletions(-) diff --git a/database_caller.py b/database_caller.py index 194dd35..d9f5817 100755 --- a/database_caller.py +++ b/database_caller.py @@ -45,7 +45,7 @@ def updateUpdate(NY_time): def updateStocks(api_key, logf): - print('STOCKS') + try: @@ -56,7 +56,7 @@ def updateStocks(api_key, logf): f.close() stock_info = all_stocks_settings['symbols'] symbols = list(stock_info.keys()) - #print(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 response = requests.get(url) data = response.json() - #print(response) - #print(dir(response)) - #print(len(data)) + stock_info = {} if len(data) > 0: @@ -81,11 +79,13 @@ def updateStocks(api_key, logf): all_stocks_settings['symbols'] = stock_info - - json.dump(all_stocks_settings, open('csv/stocks_settings.json', 'w+')) + f = open('csv/stocks_settings.json', 'w+') + json.dump(all_stocks_settings, f) + f.close() except Exception as 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)) @@ -93,12 +93,13 @@ def updateStocks(api_key, logf): 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() def updateCrypto(api_key, logf): - print('CRYPTO') - #cypto_info['symbol, base'].keys() = ['current','24hr change'] + + try: @@ -119,11 +120,10 @@ def updateCrypto(api_key, logf): url += bases[i] + '-' + s + ',' url = url[:-1] #remove last comma url += '&apiKey=' + api_key - #print(url) + response = requests.get(url) data = response.json() - #print(url) - #print(data) + coin_info = {} @@ -145,6 +145,7 @@ def updateCrypto(api_key, logf): except Exception as 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)) @@ -152,10 +153,11 @@ def updateCrypto(api_key, logf): 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() def updateForex(api_key, logf): - print('FOREX') + try: f = open('csv/forex_settings.json', 'r') @@ -185,7 +187,7 @@ def updateForex(api_key, logf): if len(data) > 0: - #print(data) + c_dict = {} for sb in symbol_base: for d in data: @@ -196,9 +198,13 @@ def updateForex(api_key, logf): 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: + 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)) @@ -206,6 +212,7 @@ def updateForex(api_key, logf): 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() 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?lang=en' - print('NEWS') + 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 response = requests.get(url) data = response.json() - #print(data) + if len(data) > 0: max_headlines = int(all_settings['num_headlines']) #load user settings @@ -247,15 +256,18 @@ def updateNews(api_key, logf): 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+')) + f = open('csv/news_settings.json', 'w+') + json.dump(all_settings, f) + f.close() except Exception as 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)) @@ -263,10 +275,11 @@ def updateNews(api_key, logf): 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() def updateWeather(api_key, logf): - print('WEATHER') + max_cities = 30 try: @@ -283,15 +296,14 @@ def updateWeather(api_key, logf): current_locations = list(all_current_settings['locations'].keys()) daily_locations = list(all_daily_settings['locations'].keys()) - print(current_locations, daily_locations) all_locations = list(set(current_locations + daily_locations)) - print(all_locations) + + current_weathers = {} + daily_weathers = {} - currents = [] - dailys = [] for location in all_locations: @@ -320,7 +332,8 @@ def updateWeather(api_key, logf): current_weather['rain_chance'] = r.json()['hourly'][0]['pop'] - currents.append(current_weather) + if location in current_locations: + current_weathers[location] = current_weather daily_weather = [] daily = r.json()['daily'] @@ -344,35 +357,24 @@ def updateWeather(api_key, logf): daily_weather[0]['wind_direction'] = current_weather['wind_direction'] daily_weather[0]['visibility'] = current_weather['visibility'] - dailys.append(daily_weather) + if location in daily_locations: + daily_weathers[location] = daily_weather - current_weathers = {} - daily_weathers = {} - - - - for l in current_locations: - for i,loc in enumerate(all_locations): - if l == loc: - current_weathers[location] = currents[i] - - for l in daily_locations: - for i,loc in enumerate(all_locations): - if l == loc: - daily_weathers[location] = dailys[i] - - - all_current_settings['locations'] = current_weathers all_daily_settings['locations'] = daily_weathers - #print(all_current_settings, all_daily_settings) - json.dump( all_current_settings, open( "csv/current_weather.json", 'w+' )) - json.dump( all_daily_settings, open( "csv/daily_weather.json", 'w+' )) + f = open( "csv/current_weather.json", 'w+' ) + json.dump( all_current_settings, f) + f.close() + + f = open( "csv/daily_weather.json", 'w+' ) + json.dump( all_daily_settings, f) + f.close() except Exception as 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)) @@ -380,15 +382,15 @@ def updateWeather(api_key, logf): 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() def updateLeagueTables(api_key, logf): - print('LEAGUE TABLES') + url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/sports?stats=' try: f = open('csv/league_tables.json', 'r') all_settings = json.load(f) - #print(all_settings['leagues'].keys()) + f.close() leagues = all_settings['leagues'].keys() @@ -407,12 +409,11 @@ def updateLeagueTables(api_key, logf): 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): - #print(l) + league = list(l.keys())[0] - #print('league', league, list(l.keys())) + teams = [] @@ -434,10 +435,13 @@ def updateLeagueTables(api_key, logf): leagues_info[league.upper()] = teams all_settings['leagues'] = leagues_info - #print(all_settings['leagues'].keys()) - json.dump(all_settings, open( "csv/league_tables.json".format(league), 'w+' )) + f = open( "csv/league_tables.json".format(league), 'w+' ) + json.dump(all_settings, f) + + f.close() except Exception as 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)) @@ -445,10 +449,11 @@ def updateLeagueTables(api_key, logf): 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() 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) if time == 'past': @@ -465,7 +470,7 @@ def updateLeagueEvents(api_key, time, logf): try: all_settings = json.load(f) - #print(all_settings['leagues'].keys()) + f.close() leagues = all_settings['leagues'].keys() leagues_info = {} @@ -483,10 +488,6 @@ def updateLeagueEvents(api_key, time, logf): all_data = r.json() - #print(all_data) - - - for league in all_data.keys(): events = [] for d in all_data[league]: @@ -512,11 +513,12 @@ def updateLeagueEvents(api_key, time, logf): events.append(event) leagues_info[league.upper()] = events all_settings['leagues'] = leagues_info - #print(all_settings['leagues'].keys()) - - json.dump(all_settings, open( "csv/{}_games.json".format(time), 'w+' )) + + f = open( "csv/{}_games.json".format(time), 'w+' ) + json.dump(all_settings, f) + f.close() except Exception as 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)) @@ -524,6 +526,7 @@ def updateLeagueEvents(api_key, time, logf): 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() def updateSports(api_key, logf): @@ -541,7 +544,7 @@ def updateSports(api_key, logf): def checkStocks(last_update, update_frequency): NY_time = datetime.now(NY_zone).replace(tzinfo=None) opening = NY_time.replace(hour=9, minute=30, second=0, microsecond=0).replace(tzinfo=None) - closing = NY_time.replace(hour=16, minute=0, second=0, microsecond=0).replace(tzinfo=None) + closing = NY_time.replace(hour=16, minute=5, second=0, microsecond=0).replace(tzinfo=None) f = open('csv/stocks_settings.json', 'r') @@ -603,7 +606,7 @@ if __name__ == '__main__': - update_frequencies = {'stocks':1, 'crypto':5, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440} #minutes + update_frequencies = {'stocks':2, 'crypto':5, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440} #minutes NY_zone = pytz.timezone('America/New_York') CET_zone = pytz.timezone('EST') @@ -630,6 +633,7 @@ if __name__ == '__main__': weather_key = api_keys[1].strip() except Exception as e: weather_key = False + 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)) @@ -637,6 +641,7 @@ if __name__ == '__main__': 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() @@ -681,7 +686,7 @@ if __name__ == '__main__': NY_time = datetime.now(NY_zone).replace(tzinfo=None) opening = NY_time.replace(hour=9, minute=30, second=0, microsecond=0).replace(tzinfo=None) - closing = NY_time.replace(hour=16, minute=0, second=0, microsecond=0).replace(tzinfo=None) + closing = NY_time.replace(hour=16, minute=5, second=0, microsecond=0).replace(tzinfo=None) stock_open = opening < NY_time < closing and datetime.today().weekday() <= 4 if last_updates['stocks']['force'] or (diff >= update_frequencies['stocks'] and stock_open):# or msg == 's': @@ -834,13 +839,14 @@ if __name__ == '__main__': process.join() process.terminate() update_processes.remove(process) - print('Number active database caller processes', len(update_processes)) + time.sleep(10) except Exception as e: - print(str(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)) @@ -848,7 +854,9 @@ if __name__ == '__main__': 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() + diff --git a/server.py b/server.py index 900e27d..8acf140 100755 --- a/server.py +++ b/server.py @@ -23,7 +23,7 @@ import copy import urllib.request import sys #stock_ticker = StockTicker() -#print('API CALLER NOT STARTED') + #open('log.txt', 'w').close() #wipe logs @@ -42,13 +42,16 @@ displaying_screensaver = False uploading = False screensaver_p = None 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 tickerList = 0 DelayTime = 20 LastCommand = '' -speedTime = 25 #print('save') +speedTime = 25 LOGO_FOLDER = 'logos/' CSV_FOLDER = 'csv/new/' @@ -57,7 +60,9 @@ ALLOWED_EXTENSIONS = {'csv', 'png'} ticker = pexpect.spawn("sudo -E python3 stockTicker.py") time.sleep(2) # give the ticker time to initialise -system_info = json.load(open('csv/system_info.json')) +f = open('csv/system_info.json') +system_info = json.load(f) +f.close() ticker.sendline('*') # run startup gif by default time.sleep(8) @@ -65,7 +70,9 @@ if system_info['first_boot']: # let startup message display ticker.sendline('-') 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: ticker.sendline('A') # run by default @@ -93,17 +100,23 @@ def index(): 'Sports (Team Stats)','Custom Images', 'Custom GIFs', 'Custom Messages', 'Stocks', 'Crypto', 'Forex'] 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: - 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]] 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]] with open('api_keys.txt', 'r') as f: @@ -116,21 +129,61 @@ def index(): timeString = now.strftime("%Y-%m-%d %H:%M") logos_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos') LogoList = os.listdir(logos_path) - - stocks_settings = json.load(open('csv/stocks_settings.json', 'r')) - crypto_settings = json.load(open('csv/crypto_settings.json', 'r')) - forex_settings = json.load(open('csv/forex_settings.json', 'r')) - current_weather= json.load(open('csv/current_weather.json', 'r')) - daily_weather = json.load(open('csv/daily_weather.json', 'r')) - news_settings = json.load(open('csv/news_settings.json', 'r')) - upcoming_games = json.load(open('csv/upcoming_games.json', 'r')) - live_games = json.load(open('csv/live_games.json', 'r')) - past_games = json.load(open('csv/past_games.json', 'r')) - team_stats = json.load(open('csv/league_tables.json', 'r')) - image_settings = json.load(open('csv/image_settings.json', 'r')) - GIF_settings = json.load(open('csv/GIF_settings.json', 'r')) - message_settings = json.load(open('csv/message_settings.json', 'r')) - general_settings = json.load(open('csv/general_settings.json', 'r')) + f = open('csv/stocks_settings.json', 'r') + stocks_settings = json.load(f) + f.close() + + f= open('csv/crypto_settings.json', 'r') + crypto_settings = json.load(f) + f.close() + + f = open('csv/forex_settings.json', 'r') + forex_settings = json.load(f) + f.close() + + f = open('csv/current_weather.json', 'r') + current_weather= json.load(f) + 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 api_keys = api_key2[1] except: @@ -165,15 +218,15 @@ def index(): 'wifi_SSID':wifi_SSID } - #print('database caller:', api_caller.isalive()) + return render_template('index.html', **templateData) def save_displaying(input_settings): - #print('save') + global professional - print('save_displaying_input:', input_settings) + 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'] professional = len(input_settings) == 2 @@ -195,7 +248,7 @@ def save_displaying(input_settings): s = "Professional" if professional else "Standard" display_settings = [s] + [input_settings] - print(display_settings) + with open('csv/display_settings.json', 'w+') as f: json.dump(list(display_settings), f) @@ -229,7 +282,7 @@ def start(): @app.route("/stop") def stop(): - print('stop') + global displaying_screensaver global ticker #global api_caller @@ -273,13 +326,13 @@ def restart(): @app.route("/reset") def reset(): - print('reset') + os.system("sudo ./setup_config_files.sh") return index() @app.route("/save", methods = ['PUT', 'POST', 'GET']) def save(): - print('save') + global uploading @@ -288,8 +341,7 @@ def save(): input_settings = json.loads(data) - - print(input_settings) + save_displaying(input_settings['displaying']) @@ -310,10 +362,9 @@ def save(): images = request.files names = list(request.files.keys()) - print(names) for name in names: - print(name) + images[name].save('user_uploads/' +name) @@ -327,7 +378,7 @@ def save(): # saves files uploaded to the webpage for images and GIFs @app.route("/upload", methods = ['PUT', 'POST', 'GET']) def upload(): - print('upload') + global uploading uploading = True try: @@ -339,15 +390,21 @@ def upload(): images[name].save('user_uploads/' +name) except Exception as e: - #print(e) + uploading = False return index() def remove_old_uploads(): #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'): if filename not in image_settings['images'] and filename not in GIF_settings['images']: os.remove('user_uploads/'+filename) @@ -360,15 +417,17 @@ def brightness(): data= request.data.decode('utf-8') settings = json.loads(data) - print(settings) + brightness =settings['brightness'] ticker.sendline(str(int(brightness)-1)) - - 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['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() @@ -383,7 +442,7 @@ def edit_wpa_sup(country, ssid, pwd): #remove this line to append to end instead of overwriting all networks wpa_lines = wpa_lines[0:3] - print(wpa_lines) + # create new file from scratch wpa_lines = [] @@ -399,7 +458,7 @@ def edit_wpa_sup(country, ssid, pwd): wpa_lines.append('}\n') wpa_string = ''.join(wpa_lines) - print(wpa_string) + current_wpa = open('/etc/wpa_supplicant/wpa_supplicant.conf', 'w+') current_wpa.write(wpa_string) @@ -408,17 +467,20 @@ def edit_wpa_sup(country, ssid, pwd): def set_wifi(): data= request.data.decode('utf-8') - print(str(data)) + settings = json.loads(data) country = settings['country'].upper() ssid = settings['ssid'] 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 - 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) # resstart netoworking @@ -440,14 +502,14 @@ def set_wifi(): #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') hosts_lines = current_hosts.readlines() - print(hosts_lines[5]) + hosts_lines[5] = '127.0.1.1 {}'.format(hostname) @@ -463,16 +525,20 @@ def hostname(): data= request.data.decode('utf-8') settings = json.loads(data) hostname = settings['hostname'] - print('hostname', hostname) + edit_hosts(hostname) os.system("sudo hostnamectl set-hostname {}".format(hostname)) 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 - 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() @@ -484,14 +550,14 @@ def saveWeatherAPIKey(): settings = json.loads(data) key = settings['api_key'] - print(key) + with open('./api_keys.txt') as f: lines = f.readlines() if len(lines) == 1: lines.append(str(key)) elif len(lines) == 2: lines[1] = str(key) - print(lines) + with open('./api_keys.txt', 'w') as f: for line in lines: f.write(line) @@ -560,7 +626,7 @@ def save_trade_settings(input_settings): filename = input_settings['feature'].lower() + '_settings.json' f = open('csv/' + filename, 'r') current_settings = json.load(f) - print(input_settings) + f.close() current_settings['speed'] = input_settings['speed'].lower() @@ -593,13 +659,14 @@ def save_trade_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' - print(filename) - - 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['speed2'] = input_settings['speed2'].lower() @@ -620,7 +687,9 @@ def save_weather_settings(input_settings): ''' 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') f = open('csv/last_updates.json', 'r') @@ -636,10 +705,11 @@ def save_weather_settings(input_settings): def save_news_settings(input_settings): 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['speed2'] = input_settings['speed2'].lower() @@ -653,9 +723,10 @@ def save_news_settings(input_settings): - print(current_settings) - - json.dump(current_settings, open('csv/' + filename, 'w+')) + + f = open('csv/' + filename, 'w+') + json.dump(current_settings, f) + f.close() #api_caller.sendline('n') f = open('csv/last_updates.json', 'r') last_updates = json.load(f) @@ -683,8 +754,10 @@ def save_sports_settings(input_settings): elif feature == 'Sports (Team Stats)': filename = 'league_tables.json' 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['speed2'] = input_settings['speed2'].lower() @@ -694,7 +767,9 @@ def save_sports_settings(input_settings): 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') f = open('csv/last_updates.json', 'r') @@ -721,29 +796,31 @@ def save_image_settings(input_settings): 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() 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) - print(current_settings) - print() - print(input_settings) - print() + for i,IS in enumerate(input_settings['messages']): # check if this is in current_settings for CS in current_settings['messages']: if IS['name'] == CS['name']: new_settings['messages'][i] = CS - print(CS) + break - print(new_settings) - json.dump(new_settings, open('csv/message_settings.json', 'w+')) + f = open('csv/message_settings.json', 'w+') + json.dump(new_settings, f) + f.close() diff --git a/stockTicker.py b/stockTicker.py index b4e3520..c9786af 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -57,10 +57,10 @@ class StockTicker(): options.chain_length = 2 options.parallel = 1 options.hardware_mapping = 'adafruit-hat' # If you have an Adafruit HAT: 'adafruit-hat' - options.gpio_slowdown = 1 + options.gpio_slowdown = 4 options.brightness = self.brightness self.matrix = RGBMatrix(options = options) - print(dir(self.matrix)) + #sys.exit() self.points = True # display crypto change in points or percent @@ -286,7 +286,7 @@ class StockTicker(): return kill def updateMultiple(self, options): - print('options', 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.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']) animation = settings['animation'].lower() @@ -615,7 +617,7 @@ class StockTicker(): kind, content, delay = row delays.append(delay) kinds.append(kind) - print(kind, content, delay) + if kind == 'text': images.append(self.textImage(content, font, 255, 255, 0, True, w_buff = 50)) elif kind == 'image': @@ -970,15 +972,15 @@ class StockTicker(): image_list.append(self.blank) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() finalDisplayImage = self.stitchImage(image_list) @@ -1042,13 +1044,15 @@ class StockTicker(): image_list.append(self.blank) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() finalDisplayImage = self.stitchImage(image_list) self.blank = Image.new('RGB', (10, 32)) @@ -1116,28 +1120,36 @@ class StockTicker(): image_list.append(new_im) 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(self.blank) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() finalDisplayImage = self.stitchImage(image_list) return finalDisplayImage def getForexProfessional(self): - print('forex prof') + self.blank = Image.new('RGB', (0, 16)) f = open('csv/forex_settings.json', 'r') all_forex_settings = json.load(f) @@ -1163,9 +1175,6 @@ class StockTicker(): current = float(forex_settings[sb]['current']) change = float(forex_settings[sb]['24hr_change']) - - - arrow, change = self.getArrow(change, professional = True) @@ -1201,23 +1210,30 @@ class StockTicker(): image_list.append(new_im) 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(self.blank) except Exception as e: - print(str(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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() finalDisplayImage = self.stitchImage(image_list) self.blank = Image.new('RGB', (10, 32)) @@ -1256,7 +1272,7 @@ class StockTicker(): percent_change = '%.2f' % abs(float(info['percent_change'])) + '%' point_change = '%.2f' % abs(change) - print(percent_change, point_change) + current = '%.2f' % float(info['current']) #TEXT @@ -1279,7 +1295,7 @@ class StockTicker(): logo = self.openImage(os.path.join(logos_path, ticker + '.png')) stitchedStock = self.stitchImage([logo,midFrame]) except Exception as e: - print(str(e)) + stitchedStock = midFrame else: stitchedStock = midFrame @@ -1289,14 +1305,15 @@ class StockTicker(): image_list.append(self.blank) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() finalDisplayImage = self.stitchImage(image_list) @@ -1373,14 +1390,15 @@ class StockTicker(): image_list.append(self.blank) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() finalDisplayImage = self.stitchImage(image_list) @@ -1390,7 +1408,10 @@ class StockTicker(): 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']: title_img = self.openImage('feature_titles/news.png') @@ -1455,21 +1476,24 @@ class StockTicker(): image_list.append(img) image_list.append(self.blank) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() news_image = self.stitchImage(image_list) return news_image 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']: title_img = self.openImage('feature_titles/small_feature_titles/news.png') @@ -1541,13 +1565,15 @@ class StockTicker(): image_list.append(img) image_list.append(blank) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() news_image = self.stitchImage(image_list) return news_image @@ -1558,11 +1584,16 @@ class StockTicker(): filepath = 'csv/{}_games.json'.format(time) else: - print(time) + 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') if all_settings['title']: title_img = self.openImage('feature_titles/sports_{}.png'.format(time)) @@ -1578,8 +1609,6 @@ class StockTicker(): for league in leagues: try: - - x_offset = 0 img = Image.new('RGB', (10000, 32)) league_info = leagues_info[league] @@ -1597,7 +1626,6 @@ class StockTicker(): large_font = ImageFont.load("./fonts/9x18B.pil") sports_info = self.readSportsCSV(league) - print(sports_info) buff_size = 25 @@ -1611,8 +1639,6 @@ class StockTicker(): dateEvent = match['date'].replace('-', '.') - #rond = match['round'] - try: @@ -1700,14 +1726,15 @@ class StockTicker(): imgs.append(img) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() @@ -1715,8 +1742,10 @@ class StockTicker(): 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'] @@ -1766,7 +1795,15 @@ class StockTicker(): x_offset += logo.size[0] + 2 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) @@ -1799,18 +1836,24 @@ class StockTicker(): imgs.append(img) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() return self.stitchImage(imgs) 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']: title_img = self.openImage('feature_titles/weather.png') @@ -1935,19 +1978,24 @@ class StockTicker(): imgs.append(img) imgs.append(self.blank) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() return self.stitchImage(imgs) 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']: title_img = self.openImage('feature_titles/small_feature_titles/weather.png') @@ -2077,13 +2125,15 @@ class StockTicker(): image_list.append(img) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() return self.stitchImage(image_list) def getDailyWeatherImageAlt(self): @@ -2230,8 +2280,10 @@ class StockTicker(): 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']: title_img = self.openImage('feature_titles/forecast.png') @@ -2246,7 +2298,6 @@ class StockTicker(): locations = list(daily_weathers['locations'].keys()) for i, location in enumerate(locations): - print(location) try: img = Image.new('RGB', (1000, 32)) @@ -2435,16 +2486,15 @@ class StockTicker(): imgs.append(self.blank) # add the image text except Exception as e: - print(str(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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() return self.stitchImage(imgs) @@ -2467,8 +2517,6 @@ class StockTicker(): def displayDailyWeatherAlt(self): img0, img1 = self.getDailyWeatherImageAlt() - #img = stock_ticker.getTodayWeatherImage() - while True: @@ -2483,14 +2531,10 @@ class StockTicker(): while offset_x > 64-img_width: offset_x -= 1 - 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 self.setImage(image, offset_x = offset_x + img_width, offset_y = offset_y, min_x = 64, min_y = 9) - - - try: msg = getInput() if msg == 'K': @@ -2509,8 +2553,6 @@ class StockTicker(): def getUserImages(self): - - f = open('csv/image_settings.json', 'r') all_settings = json.load(f) f.close() @@ -2520,9 +2562,9 @@ class StockTicker(): try: 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)) - print(img) + if all_settings['title'] and ind == 0: title_img = self.openImage('feature_titles/images.png') imgs.append(self.stitchImage([title_img, img])) @@ -2531,16 +2573,15 @@ class StockTicker(): imgs.append(img) except Exception as 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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() return imgs @@ -2586,15 +2627,15 @@ class StockTicker(): except Exception as e: - print(str(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] - self.logf.write(str(e)) - self.logf.write('. file: ' + fname) - self.logf.write('. line: ' + str(exc_tb.tb_lineno)) - self.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(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() #below code stitches title and GIF together @@ -2712,11 +2753,15 @@ class StockTicker(): #userSettings = [ 'daily_weather'] #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 = 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]) - elif len(userSettings[1][0])>0 and 'Standard'==userSettings[0]: - self.scrollFunctionsAnimated(userSettings[1][0], animation = 'down') + + + f = open('csv/display_settings.json', 'r') + user_settings = json.load(f) + 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': userSettings = json.load(open('csv/display_settings.json')) @@ -2751,41 +2796,25 @@ class StockTicker(): self.scrollFunctionsAnimated(['Custom Messages'], repeat = True) if __name__ == '__main__': - - with open('log.txt', "a") as log: - try: - stock_ticker = StockTicker() - stock_ticker.logf = log + + try: + stock_ticker = StockTicker() + stock_ticker.process_msg('A') - - - #stock_ticker.getLeagueImage('NHL', 'future') - #stock_ticker.getCryptoImage() - - # - - #stock_ticker.process_msg('*') - #time.sleep(8) - - #stock_ticker.process_msg('-') - #stock_ticker.process_msg('W') - #stock_ticker.process_msg('A') - - - - while True: - msg = getInput() - 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]))) + while True: + msg = getInput() + stock_ticker.process_msg(msg) + except Exception as 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() + From c02eb8b741deb67087f7d5211b2ed3f640c936c7 Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Thu, 7 Apr 2022 18:40:38 +0100 Subject: [PATCH 03/13] black screen fix --- stockTicker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stockTicker.py b/stockTicker.py index 6f8f584..3a8ed3c 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -2803,7 +2803,7 @@ if __name__ == '__main__': try: stock_ticker = StockTicker() - stock_ticker.process_msg('A') + while True: From a38efd3626359feccd2478e67d7368adc6dfcc1c Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Thu, 7 Apr 2022 19:10:41 +0100 Subject: [PATCH 04/13] server crash fix --- server.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 8acf140..1c5026a 100755 --- a/server.py +++ b/server.py @@ -60,8 +60,13 @@ ALLOWED_EXTENSIONS = {'csv', 'png'} ticker = pexpect.spawn("sudo -E python3 stockTicker.py") time.sleep(2) # give the ticker time to initialise -f = open('csv/system_info.json') -system_info = json.load(f) +f = open('csv/system_info.json', 'w') + +try: + system_info = json.load(f) +except: + system_info = {"update_available": False, "first_boot": False} + json.dump(system_info, f) f.close() ticker.sendline('*') # run startup gif by default From 64f33c308bb60b972ffb3cf2055a4806224cec6a Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Sun, 10 Apr 2022 12:50:10 +0100 Subject: [PATCH 05/13] fixed temp conversion bug in wether --- stockTicker.py | 69 +++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/stockTicker.py b/stockTicker.py index 3a8ed3c..6f97784 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -1850,7 +1850,14 @@ class StockTicker(): 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) - + 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): @@ -1887,21 +1894,21 @@ class StockTicker(): weather_dir = './logos/weather_icons' weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png') - temp = current_weather['temp'] - feels_temp = current_weather['feels_like'] - 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 = self.convertTemp(current_weather['temp'], all_settings['temp']) + feels_temp = self.convertTemp(current_weather['feels_like'], all_settings['temp']) + + temp_img = self.textImage(str("{0:.0f}".format(temp)), large_font) deg_img = self.textImage('o', small_font) main = current_weather['main_weather'] main_img = self.textImage(main.upper(), 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') htext_img = self.textImage(str(current_weather['humidity']) + '%', small_font) uv_img = Image.open(weather_dir + '/uv.png') @@ -2084,10 +2091,10 @@ class StockTicker(): 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)) - 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)) x_offset += max_img.size[0] + 2 @@ -2296,9 +2303,9 @@ class StockTicker(): imgs = [] - - daily_weathers = json.load(open('csv/daily_weather.json', 'r')) - + f = open('csv/daily_weather.json', 'r') + daily_weathers = json.load(f) + f.close() locations = list(daily_weathers['locations'].keys()) for i, location in enumerate(locations): @@ -2327,24 +2334,17 @@ class StockTicker(): temp = daily_weather[0]['temp'] - min_temp = daily_weather[0]['min_temp'] - max_temp = daily_weather[0]['max_temp'] + min_temp = self.convertTemp(daily_weather[0]['min_temp'], daily_weathers['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) deg_img = self.textImage('o', small_font) - min_img = self.textImage( "{0:.0f}".format(min_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) + min_img = self.textImage( "{0:.0f}".format(self.convertTemp(min_temp, daily_weathers['temp'])), small_font, r=0, g=0, b=255) + max_img = self.textImage( "{0:.0f}".format(self.convertTemp(max_temp, daily_weathers['temp'])), small_font, r=255, g=0, b=0) main = daily_weather[0]['main_weather'] main_img = self.textImage(main.upper(), small_font) @@ -2445,7 +2445,7 @@ class StockTicker(): #img.paste(wind_img, (96,0)) #img.paste(wtext_img, (109,0)) #img.paste(date_img, (70, 0)) - x_offset = 70 + x_offset = 75 for i in range(1,len(daily_weather)-1): weekday = weekdays[(datetime.today().weekday() + i)%7] @@ -2460,17 +2460,10 @@ class StockTicker(): - min_temp = weather['min_temp'] - max_temp = weather['max_temp'] + min_temp = self.convertTemp(weather['min_temp'], daily_weathers['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') min_img = self.textImage( "{0:.0f}".format(min_temp), small_font, r=0, g=0, b=255) From d07f7fa69991d6b39766e2a179effe22a0bdc258 Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Sun, 10 Apr 2022 13:06:03 +0100 Subject: [PATCH 06/13] update button fix --- check_update.sh | 4 ++++ server.py | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/check_update.sh b/check_update.sh index ec2d189..88ca69c 100755 --- a/check_update.sh +++ b/check_update.sh @@ -32,5 +32,9 @@ str=$(IFS=,; echo "${ar2[*]}") rm csv/system_info.json echo "$str" >> csv/system_info.json +echo "$str" + +chmod 777 csv/system_info.json + diff --git a/server.py b/server.py index 1c5026a..a90e01e 100755 --- a/server.py +++ b/server.py @@ -64,9 +64,10 @@ f = open('csv/system_info.json', 'w') try: system_info = json.load(f) -except: +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 @@ -320,6 +321,18 @@ def stop(): @app.route("/update", methods=['PUT','POST']) def update(): + + 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("sudo reboot now") return index() From 6d6e76d38b466421d9852e3ce5ea8f9caf1016d7 Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Sun, 10 Apr 2022 13:17:47 +0100 Subject: [PATCH 07/13] screensaver stop bug fixed --- server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index a90e01e..acc3bd5 100755 --- a/server.py +++ b/server.py @@ -295,9 +295,10 @@ def stop(): global professional global ticker_stopped - ticker.sendline('K') + if not displaying_screensaver: + ticker.sendline('K') time.sleep(0.1) # give time for leds to turn off ticker.close() else: From 972af42fd77a06c9457e3bf89230b29c491265ea Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 11 Apr 2022 23:24:59 +0800 Subject: [PATCH 08/13] gpio_slowdown changed to 2 to fix led pixel bug --- stockTicker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stockTicker.py b/stockTicker.py index 6f97784..50ddbaa 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -57,7 +57,7 @@ class StockTicker(): options.chain_length = 2 options.parallel = 1 options.hardware_mapping = 'adafruit-hat' # If you have an Adafruit HAT: 'adafruit-hat' - options.gpio_slowdown = 4 + options.gpio_slowdown = 2 options.brightness = self.brightness self.matrix = RGBMatrix(options = options) From 09a0b8b2bfb297f5fde6181059b7d07687c1e75a Mon Sep 17 00:00:00 2001 From: Neythen Treloar <33317183+zcqsntr@users.noreply.github.com> Date: Mon, 11 Apr 2022 16:53:41 +0100 Subject: [PATCH 09/13] weather fix --- stockTicker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stockTicker.py b/stockTicker.py index 50ddbaa..dfd3a44 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -2333,7 +2333,7 @@ class StockTicker(): 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 = self.convertTemp(daily_weather[0]['min_temp'], daily_weathers['temp']) max_temp = self.convertTemp(daily_weather[0]['max_temp'], daily_weathers['temp']) From 4e2859923c59bd44a591dfede5948f0babed9a33 Mon Sep 17 00:00:00 2001 From: Neythen Treloar <33317183+zcqsntr@users.noreply.github.com> Date: Mon, 11 Apr 2022 16:55:17 +0100 Subject: [PATCH 10/13] Update stockTicker.py --- stockTicker.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/stockTicker.py b/stockTicker.py index dfd3a44..65a3ad9 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -2075,11 +2075,8 @@ class StockTicker(): - temp = current_weather['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 = self.convertTemp(current_weather['temp'], all_settings['temp']) + temp_img = self.textImage(str("{0:.0f}".format(temp)), font) img.paste(temp_img, (x_offset,3)) From 2849ec8f06ee5d83c40f704632205f4cc67e0fe5 Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Mon, 11 Apr 2022 17:07:12 +0100 Subject: [PATCH 11/13] wethaer temp fix --- stockTicker.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stockTicker.py b/stockTicker.py index 65a3ad9..12c3f6e 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -2330,7 +2330,7 @@ class StockTicker(): weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png') - temp = self.convertTemp(daily_weather[0]['temp'], daily_weathers['temp'])) + temp = self.convertTemp(daily_weather[0]['temp'], daily_weathers['temp']) min_temp = self.convertTemp(daily_weather[0]['min_temp'], daily_weathers['temp']) max_temp = self.convertTemp(daily_weather[0]['max_temp'], daily_weathers['temp']) @@ -2340,8 +2340,8 @@ class StockTicker(): temp_img = self.textImage(str("{0:.0f}".format(temp)), large_font) deg_img = self.textImage('o', small_font) - min_img = self.textImage( "{0:.0f}".format(self.convertTemp(min_temp, daily_weathers['temp'])), small_font, r=0, g=0, b=255) - max_img = self.textImage( "{0:.0f}".format(self.convertTemp(max_temp, daily_weathers['temp'])), small_font, r=255, g=0, b=0) + 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, daily_weathers['temp']), small_font, r=255, g=0, b=0) main = daily_weather[0]['main_weather'] main_img = self.textImage(main.upper(), small_font) @@ -2442,7 +2442,7 @@ class StockTicker(): #img.paste(wind_img, (96,0)) #img.paste(wtext_img, (109,0)) #img.paste(date_img, (70, 0)) - x_offset = 75 + x_offset = 77 for i in range(1,len(daily_weather)-1): weekday = weekdays[(datetime.today().weekday() + i)%7] @@ -2795,7 +2795,7 @@ if __name__ == '__main__': stock_ticker = StockTicker() - + while True: msg = getInput() stock_ticker.process_msg(msg) From b354ac5a1e148a4c8d216815b16e8ecf3278e236 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 12 Apr 2022 01:18:51 +0800 Subject: [PATCH 12/13] Version number change to 1.0.1 --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 02aeb0b..2524d68 100644 --- a/templates/index.html +++ b/templates/index.html @@ -88,7 +88,7 @@ -

Version 1.0

+

Version 1.0.1

From 9fae976567eef25d36911680fc9cec152c7a4996 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 12 Apr 2022 01:25:01 +0800 Subject: [PATCH 13/13] Add files via upload --- logos/crypto/LINK.png | Bin 2057 -> 706 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/logos/crypto/LINK.png b/logos/crypto/LINK.png index 41050c5aa090aa4210aa91641f47cd97bed54ca3..0c26e351d68f4bbebb07f38a29fb9372666dcf7f 100644 GIT binary patch literal 706 zcmeAS@N?(olHy`uVBq!ia0vp^GC-`r!3-qLvR@PcDaPU;cPGZ1Cw1z99L@rd$YKTt zZeb8+WSBKa0;qr~z$e5ND5({7Yb2xVLH^5tp%7LQ}CSpWOq zv4FoP{VL!8>MFVW;nC~X9h;~B_;YU7!@QXD#YwlHd1*esaqX##N>=2RJE_4ZzOSD6 zc~$SXy1s@_)AZf9L~XhhUw(h)e5(s4l|RdXHhlMVaSW-Llbqnd*5h-A$AW=dTUy$h zJxtS2&&=S#vx8F}KTU3Cs$+CC(Nr``QP63cAS9aX%=}0wK+{um$BZpJb2PQtCruV_ z|JW)bAt5p~!6sFdjjhF#OQ1RA=0m3fPt(#F+$JWi0jfKAm+mKtcjaK#ed;g((t= zp&^)Le`FJ7m|%vVyV*@Bs3Vq^A7e*H#I#jAI;}G%``#v<7+Y$m_76HvI~`4Ds0p{{ z-nYcv&5|a1XU=S9^WMFmbI$jie|wf;X1E+>M@@GY9lmc~j=w$2;(g01x2YD%`zMR! z8?l<&KFYLsF4^*)-?MmOM@j9rUVf(gPr1rU4`t-fd9KbZHe3_=eP0{U)7XIaVk7q~ z7Eue9IUkl$083yZ=f#R4Fq&!h^%WO%tUvc^Kl)CGJ1X`nv*%Rr5`^{te`FXphHv8L zOfr_aA9L)(n83-L2P+%^acuzQ$5y3TEw*{?nepL|fAS`O-=*+YYw-qEK+bW7O+4I@ z#_YPmbBNstFuMW52M}!(MiKm9+Va|V*6q18y{N2KUn|PHeDp(O;d;y>;-xbs0_h-} z-~5jyKrV>PW=PEenj#4zeW8uB--+(j7K4W7!P= z&;TIqpdE+`?;Bq*&s#SIz*&doi@Obs9r@4!OdT5MQejfJIEn9Ev?e-Uy}2T)4-5W5~y z(@Y~m#F`;_|604P$2bA-%+T9>t{Qnq>JMUZ(MHgLeM;}RS#F%Mw+@?sa}0}W81u1i zY|y%~JP^U=%SW)d?lH_6UCDX@FrpDERw~$boS*A&n1Hw|dUlIJ3*I!J?$FbaR&)+3 zHc>9`|NgFqhurG;YiXJ@p$%*>8P-Vh)P z%7qs&!%wbzj(rG1=fPH!?~Qlgy~a*i->^Qo@h>(YBTrtRGa z-L!R>v1r}bf4RXBR)VeZuBUsi{|y>I2WVO4<$Cu0KY&|nS@g{Piq`!laZZSZv2j^- zQfEbM1*F3Zdk3IO+C~|pdI}zdsyK3RQYCPx258%8egAN|Z^d*W&j0%}lojpn)2k+g z#jQ^yL9px^fM|~E0-P7LAm)KsI^2|?1wA4H+DQS7f5?L$-qf>bx)5Z||G4`YO$mt9 zxZ|l5p+khZMhYPU3?szL%6OtR`7(lvFrYdbGLpL@TXW@1Ac_Zio+bdoAUNoLBmu%f zOI1YAQV2!xjx$2+BnT*s<(~y0Opdsc^^!8eyg)++mTmPMnF&PUKx98Ddr1Xd!MY+P`27Y7ldSpouG8m{*(>$k@9oT;E<|oL{1S;8iz{JIXNoW%06{)S)0{uY<7cc|e|U(C={2p?*Tcas{7tDsn?-x*EI>@* z17F{f-}>mGjw@5n0}Iridea|*W0HLf?ZC;mv3`e;uBixt(WQ$zN*G&z&k0gS1Vp~t zg;~L#)Mitf(gBpmemOVuV&~t*vMuyR)peGbj#3c( ze^YeO$+omyeXKUjF{`v!7fV`blm`fY@Dw)h-kb7L8APWX02=jKfcA|5Tt2?f=VrHd zl@zwS^KyM9^XD}!u@%=oZdthD6VBkg%|Jx11h+nIao+Kzi~P$ddDFG`xEwY7E4`+J zSnBJ-T#h^W5`)f323Y|;2`@M611yA7f1i}dWZm>%17ABv4j_kf@O*j*JGAT?`hJep zdm$-=4{GO&{>M=2p6frje=AUu zR?(Y>E*tU(!sp3d!jYa2O~%r?A0sjKYX3Gy((nkjNC$_P-03fxvc5Nsyl#Oe^ER0S zj9Q3}Y^D=lY?!;2=9q*Sv9}-n(h8A`b!ZcwWo~?H<=uy-*X(Lym*oX&By7}9jTtn3 zLXti_iOt)0V?NUjAk$9~Las4cf7(2F$NYm8JD=#C*-ydx;j8@jqP@0A(EC|x_%G1z|6$d7u4k(~pJqoR?-UN4?pPUnWkq@H7ikCK bsn-7h{j{sVVbrVw00000NkvXXu0mjfwT<7c