commit
45bfb41f14
@ -71,7 +71,7 @@ def updateStocks(api_key):
|
|||||||
stock_info = {}
|
stock_info = {}
|
||||||
|
|
||||||
for stock in data:
|
for stock in data:
|
||||||
stock_info[stock['symbol']] = {'current': stock['price'], 'opening': float(stock['price']) - float(stock['change_since'])}
|
stock_info[stock['symbol']] = {'current': stock['price'], 'change': stock['change_since'], 'percent_change':stock['percent']}
|
||||||
|
|
||||||
print(stock_info)
|
print(stock_info)
|
||||||
all_stocks_settings['symbols'] = stock_info
|
all_stocks_settings['symbols'] = stock_info
|
||||||
@ -127,7 +127,7 @@ def updateCrypto(api_key):
|
|||||||
symbol = d['symbol']
|
symbol = d['symbol']
|
||||||
base = d['currency']
|
base = d['currency']
|
||||||
|
|
||||||
coin_info[symbol.upper() + ',' + base.upper()] = {'current': d['price'], '24hr_change': d['percent_over_24hr']}
|
coin_info[symbol.upper() + ',' + base.upper()] = {'current': d['price'], '24hr_change': d['price_over_24hr'], 'percent_change': d['percent_over_24hr']}
|
||||||
|
|
||||||
all_crypto_settings['symbols'] = coin_info
|
all_crypto_settings['symbols'] = coin_info
|
||||||
|
|
||||||
@ -175,12 +175,12 @@ def updateForex(api_key):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print(data)
|
||||||
c_dict = {}
|
c_dict = {}
|
||||||
|
|
||||||
for d in data:
|
for d in data:
|
||||||
|
|
||||||
c_dict[d['uid'].replace('/',',')] = {'current': d['rate'], '24hr_change': d['rate_over_24hr']}
|
c_dict[d['uid'].replace('/',',')] = {'current': d['rate'], '24hr_change': d['rate_over_24hr'], 'percent_change':d['percent_over_24hr']}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -572,6 +572,7 @@ if __name__ == '__main__':
|
|||||||
api_keys = f.readlines()
|
api_keys = f.readlines()
|
||||||
api_key = api_keys[0].strip()
|
api_key = api_keys[0].strip()
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
weather_key = api_keys[1].strip()
|
weather_key = api_keys[1].strip()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
File diff suppressed because one or more lines are too long
@ -260,11 +260,14 @@ class StockTicker():
|
|||||||
|
|
||||||
if stocks:
|
if stocks:
|
||||||
update_process.join()
|
update_process.join()
|
||||||
|
update_process.terminate()
|
||||||
if current_img == 1:
|
if current_img == 1:
|
||||||
current_img = 2
|
current_img = 2
|
||||||
elif current_img == 2:
|
elif current_img == 2:
|
||||||
current_img = 1
|
current_img = 1
|
||||||
offset_x = 0
|
offset_x = 0
|
||||||
|
update_process.join()
|
||||||
|
update_process.terminate()
|
||||||
|
|
||||||
def scrollImageStacked(self, image, offset_x = 0, offset_y = 0):
|
def scrollImageStacked(self, image, offset_x = 0, offset_y = 0):
|
||||||
img_width, img_height = image.size
|
img_width, img_height = image.size
|
||||||
@ -427,6 +430,7 @@ class StockTicker():
|
|||||||
if not repeat:
|
if not repeat:
|
||||||
break
|
break
|
||||||
update_process.join()
|
update_process.join()
|
||||||
|
update_process.terminate()
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
def scrollProfessionalAnimated(self, options, animation = 'on'):
|
def scrollProfessionalAnimated(self, options, animation = 'on'):
|
||||||
@ -494,7 +498,7 @@ class StockTicker():
|
|||||||
update_t1 = time.time()
|
update_t1 = time.time()
|
||||||
update_t2 = time.time()
|
update_t2 = time.time()
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
if offset_x1 < -(img_width1+1):
|
if offset_x1 < -(img_width1+1):
|
||||||
i1 += 1
|
i1 += 1
|
||||||
settings1 = json.load(open(self.JSONs[top[i1 % len(top)]]))
|
settings1 = json.load(open(self.JSONs[top[i1 % len(top)]]))
|
||||||
@ -510,6 +514,7 @@ class StockTicker():
|
|||||||
offset_x1 = 0
|
offset_x1 = 0
|
||||||
|
|
||||||
update_process.join()
|
update_process.join()
|
||||||
|
update_process.terminate()
|
||||||
update_process = Process(target = self.updateMultiple, args = ([top[(i1+1) % len(top)]+ ' Prof'],))
|
update_process = Process(target = self.updateMultiple, args = ([top[(i1+1) % len(top)]+ ' Prof'],))
|
||||||
update_process.start()
|
update_process.start()
|
||||||
image1 = self.openImage('./display_images/' + top[i1 % len(top)] +' Prof.ppm')
|
image1 = self.openImage('./display_images/' + top[i1 % len(top)] +' Prof.ppm')
|
||||||
@ -531,6 +536,7 @@ class StockTicker():
|
|||||||
|
|
||||||
|
|
||||||
update_process.join()
|
update_process.join()
|
||||||
|
update_process.terminate()
|
||||||
update_process = Process(target = self.updateMultiple, args = ([bottom[i2 % len(bottom)]+ ' Prof'],))
|
update_process = Process(target = self.updateMultiple, args = ([bottom[i2 % len(bottom)]+ ' Prof'],))
|
||||||
update_process.start()
|
update_process.start()
|
||||||
image2 = self.openImage('./display_images/' + bottom[(i2+1) % len(bottom)] +' Prof.ppm')
|
image2 = self.openImage('./display_images/' + bottom[(i2+1) % len(bottom)] +' Prof.ppm')
|
||||||
@ -580,6 +586,8 @@ class StockTicker():
|
|||||||
|
|
||||||
|
|
||||||
if kill: break
|
if kill: break
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def scrollMultiple(self, animation = 'down'):
|
def scrollMultiple(self, animation = 'down'):
|
||||||
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
|
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
|
||||||
@ -929,15 +937,18 @@ class StockTicker():
|
|||||||
try:
|
try:
|
||||||
ticker, base = cb.split(',')
|
ticker, base = cb.split(',')
|
||||||
current = float(coin_info[cb]["current"])
|
current = float(coin_info[cb]["current"])
|
||||||
change = float(coin_info[cb]["24hr_change"])
|
point_change = float(coin_info[cb]["24hr_change"])
|
||||||
|
|
||||||
percent_change = '%.2f' % abs(change) +'%'
|
percent_change = float(coin_info[cb]["percent_change"])
|
||||||
|
|
||||||
|
|
||||||
point_change = '%.2f' % abs(change/100 * current)
|
|
||||||
|
arrow, change = self.getArrow(point_change)
|
||||||
|
|
||||||
|
percent_change = str(abs(percent_change))
|
||||||
|
point_change = str(abs(point_change))
|
||||||
|
current = str(current)
|
||||||
|
|
||||||
arrow, change = self.getArrow(change)
|
|
||||||
current = '%.2f' % current
|
|
||||||
if not all_crypto_settings['percent']:
|
if not all_crypto_settings['percent']:
|
||||||
percent_change = False
|
percent_change = False
|
||||||
if not all_crypto_settings['point']:
|
if not all_crypto_settings['point']:
|
||||||
@ -951,8 +962,8 @@ class StockTicker():
|
|||||||
|
|
||||||
logo = self.openImage(os.path.join(logos_path, ticker + '.png'))
|
logo = self.openImage(os.path.join(logos_path, ticker + '.png'))
|
||||||
stitchedStock = self.stitchImage([logo,midFrame])
|
stitchedStock = self.stitchImage([logo,midFrame])
|
||||||
except:
|
except Exception as e:
|
||||||
|
|
||||||
stitchedStock = midFrame
|
stitchedStock = midFrame
|
||||||
else:
|
else:
|
||||||
stitchedStock = midFrame
|
stitchedStock = midFrame
|
||||||
@ -962,6 +973,7 @@ class StockTicker():
|
|||||||
image_list.append(self.blank)
|
image_list.append(self.blank)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
self.logf.write(str(e))
|
||||||
@ -1006,13 +1018,12 @@ class StockTicker():
|
|||||||
change = float(coin_info[cb]["24hr_change"])
|
change = float(coin_info[cb]["24hr_change"])
|
||||||
arrow, change = self.getArrow(change, professional=True)
|
arrow, change = self.getArrow(change, professional=True)
|
||||||
|
|
||||||
if all_crypto_settings["point"]:
|
if all_crypto_settings["percent"]:
|
||||||
# convert percent to points
|
# convert percent to points
|
||||||
change = abs(change)/100 * current
|
change = str(abs(float(coin_info[cb]['percent_change']))) + '%'
|
||||||
change = str(change)
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
change = str(change)
|
change = str(abs(float(change)))
|
||||||
|
|
||||||
current = str(current)
|
current = str(current)
|
||||||
midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
|
midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
|
||||||
@ -1071,11 +1082,11 @@ class StockTicker():
|
|||||||
current = float(forex_settings[sb]['current'])
|
current = float(forex_settings[sb]['current'])
|
||||||
change = float(forex_settings[sb]['24hr_change'])
|
change = float(forex_settings[sb]['24hr_change'])
|
||||||
|
|
||||||
percent_change = str(abs(change)) +'%'
|
percent_change = str(abs(float(forex_settings[sb]['percent_change']))) +'%'
|
||||||
|
|
||||||
|
|
||||||
point_change = str(abs(change/100 * current))
|
point_change = str(abs(change))
|
||||||
|
|
||||||
if not all_forex_settings['percent']:
|
if not all_forex_settings['percent']:
|
||||||
percent_change = False
|
percent_change = False
|
||||||
if not all_forex_settings['point']:
|
if not all_forex_settings['point']:
|
||||||
@ -1085,7 +1096,7 @@ class StockTicker():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
current = '%.3f' % current
|
current = str(current)
|
||||||
|
|
||||||
|
|
||||||
midFrame = self.textToImage(base+ '(' + symbol + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT
|
midFrame = self.textToImage(base+ '(' + symbol + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT
|
||||||
@ -1114,6 +1125,7 @@ class StockTicker():
|
|||||||
image_list.append(self.blank)
|
image_list.append(self.blank)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
self.logf.write(str(e))
|
||||||
@ -1162,7 +1174,7 @@ class StockTicker():
|
|||||||
|
|
||||||
if all_forex_settings["percent"]:
|
if all_forex_settings["percent"]:
|
||||||
# convert percent to points
|
# convert percent to points
|
||||||
change = abs(change)/current * 100
|
change = abs(float(forex_settings[sb]['percent_change']))
|
||||||
|
|
||||||
change = str(change) + '%'
|
change = str(change) + '%'
|
||||||
else:
|
else:
|
||||||
@ -1234,13 +1246,15 @@ class StockTicker():
|
|||||||
try:
|
try:
|
||||||
info = stock_info[symbol]
|
info = stock_info[symbol]
|
||||||
|
|
||||||
change = float(info['current'])-float(info['opening']) #TEXT
|
change = float(info['change']) #TEXT
|
||||||
ticker = symbol #TEXT
|
ticker = symbol #TEXT
|
||||||
|
|
||||||
percent_change = str(abs(float(change)/float(info['current'])*100)) + '%'
|
|
||||||
point_change = str(abs(change))
|
|
||||||
arrow, change = self.getArrow(change)
|
arrow, change = self.getArrow(change)
|
||||||
|
|
||||||
|
percent_change = str(abs(float(info['percent_change']))) + '%'
|
||||||
|
point_change = str(abs(change))
|
||||||
|
|
||||||
print(percent_change, point_change)
|
print(percent_change, point_change)
|
||||||
|
|
||||||
current = str(float(info['current'])) #TEXT
|
current = str(float(info['current'])) #TEXT
|
||||||
@ -1313,7 +1327,7 @@ class StockTicker():
|
|||||||
try:
|
try:
|
||||||
info = stock_info[symbol]
|
info = stock_info[symbol]
|
||||||
|
|
||||||
change = float(info['current'])-float(info['opening']) #TEXT
|
change = float(info['change'])#TEXT
|
||||||
ticker = symbol #TEXT
|
ticker = symbol #TEXT
|
||||||
|
|
||||||
|
|
||||||
@ -1321,12 +1335,11 @@ class StockTicker():
|
|||||||
arrow, change = self.getArrow(change, professional=True)
|
arrow, change = self.getArrow(change, professional=True)
|
||||||
|
|
||||||
if all_stocks_settings["percent"]:
|
if all_stocks_settings["percent"]:
|
||||||
# convert percent to points
|
change = str(abs(float(info['percent_change']))) + '%'
|
||||||
change = change/float(info['current'])* 100
|
|
||||||
|
|
||||||
change = str(change) + '%'
|
|
||||||
else:
|
else:
|
||||||
change = str(change)
|
change = str(abs(change))
|
||||||
|
|
||||||
|
|
||||||
current = str(float(info['current'])) #TEXT
|
current = str(float(info['current'])) #TEXT
|
||||||
midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
|
midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
|
||||||
|
|
||||||
@ -1781,7 +1794,7 @@ class StockTicker():
|
|||||||
img = img.crop((0,0,x_offset ,32))
|
img = img.crop((0,0,x_offset ,32))
|
||||||
imgs.append(img)
|
imgs.append(img)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
self.logf.write(str(e))
|
self.logf.write(str(e))
|
||||||
@ -2758,7 +2771,7 @@ if __name__ == '__main__':
|
|||||||
msg = getInput()
|
msg = getInput()
|
||||||
stock_ticker.process_msg(msg)
|
stock_ticker.process_msg(msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
log.write(str(e))
|
log.write(str(e))
|
||||||
|
Loading…
Reference in New Issue
Block a user