scrolling images and gifs. error logging.

This commit is contained in:
Neythen 2021-05-31 12:22:56 +01:00
parent 97389d85d7
commit 03f42ae29a
11 changed files with 165 additions and 91 deletions

View File

@ -1,3 +1,3 @@
symbol,name,base,current,24hr change
BTC,bitcoin,usd,39062,1.451872309860798
ETH,ethereum,gbp,1957.05,1.4454835579595058
BTC,bitcoin,usd,36931,3.0260586808252348
ETH,ethereum,gbp,1816.03,6.4687249212788815

1 symbol name base current 24hr change
2 BTC bitcoin usd 39062 36931 1.451872309860798 3.0260586808252348
3 ETH ethereum gbp 1957.05 1816.03 1.4454835579595058 6.4687249212788815

View File

@ -1 +1 @@
27/05/2021 15:08:39
31/05/2021 07:21:51

1 27/05/2021 15:08:39 31/05/2021 07:21:51

View File

@ -1,21 +1,21 @@
headline,source,date,time
Competitor Fears Elon Musk's SpaceX Could "Monopolise" Space - NDTV,NDTV News,2021-05-27,18:31:03Z
Meme stocks mount a comeback as AMC^ GameStop shareholders squeeze short sellers again - CBC.ca,CBC News,2021-05-27,18:22:41Z
U.S. administers 290.7 mln doses of COVID-19 vaccines - CDC - Financial Post,Financial Post,2021-05-27,18:13:22Z
Covid-19: Up to 75% of new UK cases could be Indian variant - Matt Hancock - BBC News,BBC News,2021-05-27,18:09:12Z
Super Moon vs Blood Moon - India Today,India Today,2021-05-27,18:04:39Z
Vaccine target for majority of adults likely to be delayed Varadkar - The Irish Times,The Irish Times,2021-05-27,18:00:00Z
'Its a Champions League final but its just a football game for me' - Mahrez relaxed for Man City's big night - Goal.com,Sporting News,2021-05-27,18:00:00Z
UK aid cuts directly hamper fight against HIV^ warn politicians and Aids groups - Financial Times,Financial Times,2021-05-27,17:58:01Z
New York Knicks ban fan from Madison Square Garden for spitting on Atlanta Hawks' Trae Young - ESPN,ESPN,2021-05-27,17:46:50Z
I couldn't sleep for 8-9 days while I was playing: Ashwin on why he had to leave IPL midway - Times of India,The Times of India,2021-05-27,17:39:00Z
New studies claim COVID-19 immunity may last years - New York Post ,New York Post,2021-05-27,17:35:00Z
COVID-19: Matt Hancock says 'we worked as hard as we could to protect care homes' after Dominic Cummings's criticism - Sky News,Sky.com,2021-05-27,17:34:18Z
Mixed reaction from experts to new guidelines on dining out - The Irish Times,The Irish Times,2021-05-27,17:33:24Z
Gold-standard contact tracing swamped as Covid sites soar - Herald Sun,Herald Sun,2021-05-27,17:32:53Z
Shami receives first dose of COVID-19 vaccine - DTNext,Dtnext.in,2021-05-27,17:29:36Z
Some Canadians falsely assuming Pfizer COVID-19 vaccine more effective than Moderna - CP24 Toronto's Breaking News,CP24 Toronto's Breaking News,2021-05-27,17:19:00Z
China's Zhurong Mars rover lays down wheel tracks on the red planet - CNET,CNET,2021-05-27,17:13:00Z
Packers still not budging on Aaron Rodgers trade possibility - NBC Sports,NBCSports.com,2021-05-27,17:09:00Z
How John Krasinski tortured Emily Blunt (again) for 'A Quiet Place Part II' by exploiting 'her greatest weakness' - Yahoo Entertainment,Yahoo Entertainment,2021-05-27,17:01:50Z
Dark matter mapped using light from 100 million galaxies - The Irish News,The Irish News,2021-05-27,17:01:41Z
Twitter is working on tweet reactions so it can be more like Facebook - TechRadar,TechRadar,2021-05-31,10:35:22Z
Three-child policy: China lifts cap on births in major policy shift - The Straits Times,The Straits Times,2021-05-31,10:24:28Z
Saraki^ Ahmed to face prosecution over alleged mismanagement of Kwara properties - Vanguard,Vanguard,2021-05-31,10:23:24Z
Baby squid and 'water bears' part of ISS cargo: What NASA has planned for these little critters in space - Times Now,Zoom,2021-05-31,10:22:56Z
Prof Abdool Karim says Level 2 lockdown is 'right move' - IOL,IOL,2021-05-31,10:20:51Z
LIVE UPDATES: Jazz vs Grizzlies - NBA Western Conference playoffs first round 2021 - Rappler,Rappler,2021-05-31,10:17:00Z
Signal No. 1 up in parts of Northern^ Eastern Samar due to Tropical Storm Dante - Rappler,Rappler,2021-05-31,10:10:00Z
Duterte certifies as urgent creation of OFW department^ taxing POGOs - Rappler,Rappler,2021-05-31,10:05:00Z
ISS Canadarm2 robotic arm survives impact with orbital debris - SlashGear,SlashGear,2021-05-31,10:03:00Z
Nigerian govt engages Facebook over WhatsApp privacy policy - Premium Times,Premium Times,2021-05-31,09:57:59Z
The magazine of personal technology - Gadget,Gadget.co.za,2021-05-31,09:54:46Z
WhatsApp backs down on plan to block users who dont accept controversial new privacy terms... - The Irish Sun,The Irish Sun,2021-05-31,09:53:40Z
New Study Shows Brain Training Programmes Not Associated With Benefits of Cognition - Gadgets 360,NDTV News,2021-05-31,09:53:09Z
Sahara Reporters publisher Omoyele Sowore says policewoman shot him - Guardian,Guardian Nigeria,2021-05-31,09:48:00Z
People who want alternative COVID-19 vaccines can get them under special access route - CNA,CNA,2021-05-31,09:45:44Z
Ayade Sacks Four Commissioners^ Five Other Appointees - Channels Television,Channels Television,2021-05-31,09:45:00Z
COVID vaccination guidelines eased for pregnant^ breastfeeding women^ cancer patients - Yahoo India News,Yahoo Entertainment,2021-05-31,09:42:15Z
Magashule gets High Court dates to challenge ANC suspension - Eyewitness News,EWN,2021-05-31,09:40:54Z
UP law professors to Duterte: Act in the best interest of Filipinos^ retract remarks on WPS - ABS-CBN News,Abs-cbn.com,2021-05-31,09:40:00Z
Sunday was hottest day of year with more sunshine on the way - The Irish Times,The Irish Times,2021-05-31,09:39:04Z

Can't render this file because it contains an unexpected character in line 2 and column 43.

View File

@ -1,4 +1,4 @@
name,current,opening
MSFT,249.575,251.17
NFLX,501.03,501.8
GOOG,2431.38,2436.94
MSFT,249.68,250.995
NFLX,502.81,504.4
GOOG,2411.56,2421.96

1 name current opening
2 MSFT 249.575 249.68 251.17 250.995
3 NFLX 501.03 502.81 501.8 504.4
4 GOOG 2431.38 2411.56 2436.94 2421.96

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
final.ppm

Binary file not shown.

View File

@ -0,0 +1 @@
name 'sel' is not defined. file: stockTicker.py. line: 704. type: <class 'NameError'>

View File

@ -308,6 +308,7 @@ def matrix():
return hello()
if __name__ == "__main__":
app.run(host='0.0.0.0', port=1024, debug=False) # the debuggger causes flickering
app.run(host='0.0.0.0', port=1024, debug=False) # the debuggger causes flickering
#sudo ./demo -D1 final.ppm -t 50 -m 25 --led-gpio-mapping=adafruit-hat --led-rows=32 --led-cols=256 --led-slowdown-gpio=4

View File

@ -98,6 +98,16 @@ class StockTicker():
self.setImage(image, offset_x = offset_x, offset_y = offset_y)
# remove the ppixels behind the image, to stop trailing
for x in range(offset_x + img_width, 128):
for y in range(self.matrix.height):
self.matrix.SetPixel(x , y , 0,0,0)
try:
msg = getInput()
if msg == 'K':
@ -305,41 +315,74 @@ class StockTicker():
def displayGIF(self, gif_file):
with open('log.txt', "w") as log:
def displayGIF(self, gif):
# To iterate through the entire gif
i = 0
while True:
print(gif.tell())
try:
im = Image.open(gif_file)
# To iterate through the entire gif
gif.seek(i)
except EOFError:
print('finished')
i = 0
while 1:
print(im.tell())
try:
im.seek(i)
except EOFError:
print('finished')
i = 0
im.seek(i)
# do something to im
self.setImage(im.convert('RGB'))
time.sleep(0.5)
i += 1
try:
msg = getInput()
if msg == 'K':
im.close()
self.resetMatrix()
break
self.process_msg(msg)
except KeyboardInterrupt:
sys.stdout.flush()
pass
except Exception as e:
log.write(str(e))
gif.seek(i)
# do something to im
self.setImage(gif.convert('RGB'))
time.sleep(0.5)
i += 1
try:
msg = getInput()
if msg == 'K':
gif.close()
self.resetMatrix()
break
self.process_msg(msg)
except KeyboardInterrupt:
sys.stdout.flush()
pass
def scrollGIF(self, gif, offset_x = 0, offset_y = 0):
# To iterate through the entire gif
i = 0
img_width, img_height = gif.size
while offset_x > -img_width:
offset_x -= 1
try:
gif.seek(i)
except EOFError:
print('finished')
i = 0
gif.seek(i)
# do something to im
self.setImage(gif.convert('RGB'), offset_x = offset_x)
time.sleep(self.delay)
if offset_x % 20 == 0:
i += 1
for x in range(offset_x + img_width, 128):
for y in range(self.matrix.height):
self.matrix.SetPixel(x , y , 0,0,0)
try:
msg = getInput()
if msg == 'K':
gif.close()
self.resetMatrix()
break
self.process_msg(msg)
except KeyboardInterrupt:
sys.stdout.flush()
pass
@ -604,11 +647,21 @@ class StockTicker():
elif msg == 'I': # image
image = self.openImage(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_image'))
self.setImage( image)
#self.setImage( image)
while True:
kill = self.scrollImage(image, offset_x = 128)
if kill:
break
elif msg == 'G': # gif
self.displayGIF(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_gif'))
gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_gif'))
#self.displayGIF(gif)
while True:
kill = self.scrollGIF(gif, offset_x = 128)
if kill:
break
@ -618,33 +671,44 @@ class StockTicker():
if __name__ == '__main__':
#print(sys.stdin.readlines())
stock_ticker = StockTicker()
#stock_ticker.readCSV()
#stock_ticker.displayUserText()
#
stock_ticker.displayNews()
#stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/open.gif')
#stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/close.gif')
#stock_ticker.process_msg(brightness)
#stock_ticker.process_msg(speed)
#stock_ticker.displayText()
#stock_ticker.getFullStockImage(1)
#stock_ticker.process_msg('f')
#stock_ticker.displayStocks()
#stock_ticker.displayStocks()
#stock_ticker.delay = 0.001
#stock_ticker.scrollImageTransition(['final.ppm', 'final.ppm'], offset_x = 0, offset_y = 0)
while True:
msg = getInput()
stock_ticker.process_msg(msg)
with open('log.txt', "w") as log:
try:
stock_ticker = StockTicker()
#stock_ticker.process_msg('G')
#stock_ticker.scrollImageTransition([os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_image'), os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_image')], stocks = False)
#stock_ticker.readCSV()
#stock_ticker.displayUserText()
#
#stock_ticker.displayNews()
#stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/open.gif')
#stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/close.gif')
#stock_ticker.process_msg(brightness)
#stock_ticker.process_msg(speed)
#stock_ticker.displayText()
#stock_ticker.getFullStockImage(1)
#stock_ticker.process_msg('f')
#stock_ticker.displayStocks()
#stock_ticker.displayStocks()
#stock_ticker.delay = 0.001
#stock_ticker.scrollImageTransition(['final.ppm', 'final.ppm'], offset_x = 0, offset_y = 0)
while True:
msg = getInput()
stock_ticker.process_msg(msg)
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]
log.write(str(e))
log.write('. file: ' + fname)
log.write('. line: ' + str(exc_tb.tb_lineno))
log.write('. type: ' + str(exc_type))

View File

@ -14,6 +14,14 @@ import pexpect
from pycoingecko import CoinGeckoAPI
from newsapi import NewsApiClient
import sys, os
try:
raise NotImplementedError("No error")
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]
print(exc_type, fname, exc_tb.tb_lineno, exc_obj, exc_tb)
if __name__ == '__main__':
newsapi = NewsApiClient(api_key='cf08652bd17647b89aaf469a1a8198a9')