black screen fix
This commit is contained in:
parent
82cdcc0022
commit
3eaf0fb3ca
@ -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:
|
||||
|
||||
all_settings = json.load(open('csv/news_settings.json', 'r'))
|
||||
try:
|
||||
f = open('csv/news_settings.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
currents = []
|
||||
dailys = []
|
||||
current_weathers = {}
|
||||
daily_weathers = {}
|
||||
|
||||
|
||||
|
||||
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)
|
||||
|
||||
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]
|
||||
|
||||
|
||||
if location in daily_locations:
|
||||
daily_weathers[location] = daily_weather
|
||||
|
||||
|
||||
|
||||
|
||||
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,6 +854,8 @@ 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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
227
server.py
227
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
|
||||
|
||||
@ -94,16 +101,22 @@ def index():
|
||||
|
||||
global professional
|
||||
|
||||
feature_settings = json.load(open('csv/display_settings.json', 'r'))
|
||||
f = open('csv/display_settings.json', 'r')
|
||||
feature_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
|
||||
print('professional',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]]
|
||||
|
||||
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)
|
||||
f = open('csv/stocks_settings.json', 'r')
|
||||
stocks_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
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/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
|
||||
|
||||
|
||||
@ -289,7 +342,6 @@ 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)
|
||||
@ -684,7 +755,9 @@ def save_sports_settings(input_settings):
|
||||
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()
|
||||
|
||||
|
||||
|
||||
|
373
stockTicker.py
373
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'))
|
||||
@ -2752,40 +2797,24 @@ class StockTicker():
|
||||
|
||||
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')
|
||||
|
||||
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()
|
||||
|
||||
|
||||
|
||||
#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])))
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user