non prof image generation finished
@ -327,7 +327,7 @@ def updateWeather():
|
||||
all_daily_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
f = open('csv/daily_weather.json', 'r')
|
||||
f = open('csv/current_weather.json', 'r')
|
||||
all_current_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
@ -370,8 +370,8 @@ def updateWeather():
|
||||
current_weather['rain_chance'] = r.json()['hourly'][0]['pop']
|
||||
|
||||
|
||||
if location in current_locations:
|
||||
current_weathers[location] = current_weather
|
||||
|
||||
current_weathers[location] = current_weather
|
||||
|
||||
daily_weather = []
|
||||
daily = r.json()['daily']
|
||||
@ -385,8 +385,8 @@ def updateWeather():
|
||||
daily_weather.append(dct)
|
||||
|
||||
|
||||
if location in daily_locations:
|
||||
daily_weathers[location] = daily_weather
|
||||
|
||||
daily_weathers[location] = daily_weather
|
||||
|
||||
|
||||
|
||||
@ -546,7 +546,11 @@ def checkStocks(last_update, update_frequency):
|
||||
closing = NY_time.replace(hour=16, minute=0, second=0, microsecond=0).replace(tzinfo=None)
|
||||
|
||||
|
||||
symbols, stock_info = readJSON('csv/stocks_settings.json', max_stocks)
|
||||
f = open('csv/stocks_settings.json', 'r')
|
||||
all_stocks_settings = json.load(f)
|
||||
f.close()
|
||||
stock_info = all_stocks_settings['symbols']
|
||||
symbols = list(stock_info.keys())
|
||||
|
||||
updated = False
|
||||
|
||||
@ -589,8 +593,7 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
newsapi = NewsApiClient(api_key='cf08652bd17647b89aaf469a1a8198a9')
|
||||
updateNews()
|
||||
sys.exit()
|
||||
|
||||
|
||||
update_frequencies = {'stocks':2, 'crypto':10, 'news':120, 'weather': 120, 'sports': 120} #minutes
|
||||
|
||||
@ -610,7 +613,8 @@ if __name__ == '__main__':
|
||||
#f.close()
|
||||
|
||||
|
||||
|
||||
updateWeather()
|
||||
sys.exit()
|
||||
try:
|
||||
f = open('csv/last_updates.json', 'r')
|
||||
last_updates = json.load(f)
|
||||
|
@ -1 +1 @@
|
||||
{"feature": "Stocks", "speed": "medium", "animation": "continuous", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 38.91, "24hr_change": -10.214531272448745}, "BTC,USD": {"current": 42257, "24hr_change": -6.370431167988443}, "ETH,BTC": {"current": 0.06787408, "24hr_change": -7.725740924537157}, "ADA,GBP": {"current": 1.69, "24hr_change": -0.5989543849163771}}}
|
||||
{"feature": "Stocks", "speed": "medium", "animation": "continuous", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 43.42, "24hr_change": -3.963839231643678}, "BTC,USD": {"current": 49343, "24hr_change": 0.902025932223419}, "ETH,BTC": {"current": 0.06930671, "24hr_change": -1.7367682270496585}, "ADA,GBP": {"current": 1.62, "24hr_change": -3.549646457710461}}}
|
@ -1 +1 @@
|
||||
{"feature": "Current Weather", "speed": "medium", "animation": "continuous", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Moscow": {"main_weather": "Rain", "description": "light rain", "temp": 9.49, "min_temp": 7.65, "max_temp": 10.51, "feels_like": 7.58, "humidity": 84, "clouds": 100, "wind_speed": 3.59, "wind_direction": 183, "visibility": 10000, "uv": 0.78, "rain_chance": 0.2}, "London": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 16.83, "min_temp": 16.43, "max_temp": 21.14, "feels_like": 16.97, "humidity": 92, "clouds": 90, "wind_speed": 1.54, "wind_direction": 0, "visibility": 10000, "uv": 1.35, "rain_chance": 0}, "Beijing": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 22.72, "min_temp": 18.1, "max_temp": 22.92, "feels_like": 22.69, "humidity": 63, "clouds": 99, "wind_speed": 2.06, "wind_direction": 185, "visibility": 10000, "uv": 0.28, "rain_chance": 0.06}, "Tokyo": {"main_weather": "Clouds", "description": "scattered clouds", "temp": 22, "min_temp": 21.23, "max_temp": 24.98, "feels_like": 22.16, "humidity": 73, "clouds": 40, "wind_speed": 1.34, "wind_direction": 52, "visibility": 10000, "uv": 0, "rain_chance": 0.36}}, "current_weather": true}
|
||||
{"feature": "Current Weather", "speed": "medium", "animation": "continuous", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Moscow": {"main_weather": "Clouds", "description": "few clouds", "temp": 4.6, "min_temp": 4.6, "max_temp": 11.07, "feels_like": 2.79, "humidity": 73, "clouds": 16, "wind_speed": 2.11, "wind_direction": 120, "visibility": 10000, "uv": 0, "rain_chance": 0}, "Beijing": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 11.63, "min_temp": 11.63, "max_temp": 14.76, "feels_like": 11.28, "humidity": 93, "clouds": 100, "wind_speed": 1.1, "wind_direction": 9, "visibility": 10000, "uv": 0, "rain_chance": 0.84}, "Tokyo": {"main_weather": "Clouds", "description": "few clouds", "temp": 21.42, "min_temp": 21.42, "max_temp": 27.62, "feels_like": 21.73, "humidity": 81, "clouds": 20, "wind_speed": 0.45, "wind_direction": 291, "visibility": 10000, "uv": 0, "rain_chance": 0}, "London": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 12.23, "min_temp": 11.77, "max_temp": 16.42, "feels_like": 11.91, "humidity": 92, "clouds": 91, "wind_speed": 4.01, "wind_direction": 181, "visibility": 10000, "uv": 0, "rain_chance": 0}}, "current_weather": true}
|
@ -1 +1 @@
|
||||
{"feature": "Current Weather", "speed": "medium", "animation": "continuous", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Moscow": [{"main_weather": "Rain", "description": "light rain", "min_temp": 7.65, "max_temp": 10.51}, {"main_weather": "Rain", "description": "light rain", "min_temp": 8.46, "max_temp": 9.36}, {"main_weather": "Rain", "description": "light rain", "min_temp": 7.77, "max_temp": 10.32}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 6.71, "max_temp": 8.53}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 4.13, "max_temp": 9.61}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 5.87, "max_temp": 12.32}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 5.82, "max_temp": 12.78}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 6.06, "max_temp": 13.3}], "London": [{"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 16.43, "max_temp": 21.14}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 14.49, "max_temp": 22.91}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 13.23, "max_temp": 18.43}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 12.03, "max_temp": 17.55}, {"main_weather": "Rain", "description": "light rain", "min_temp": 8.64, "max_temp": 15.93}, {"main_weather": "Rain", "description": "light rain", "min_temp": 11.89, "max_temp": 17.45}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 12.55, "max_temp": 18.84}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 10.94, "max_temp": 15.26}], "Beijing": [{"main_weather": "Rain", "description": "light rain", "min_temp": 18.1, "max_temp": 22.92}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 17.48, "max_temp": 19.87}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 16.77, "max_temp": 25.9}, {"main_weather": "Rain", "description": "light rain", "min_temp": 18.78, "max_temp": 23.9}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 18.28, "max_temp": 28.13}, {"main_weather": "Rain", "description": "light rain", "min_temp": 17.59, "max_temp": 21.57}, {"main_weather": "Rain", "description": "light rain", "min_temp": 17.99, "max_temp": 20.7}, {"main_weather": "Rain", "description": "light rain", "min_temp": 17.22, "max_temp": 26.37}], "Tokyo": [{"main_weather": "Rain", "description": "light rain", "min_temp": 21.23, "max_temp": 24.98}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 20.36, "max_temp": 23.48}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 19.58, "max_temp": 25.58}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 19.32, "max_temp": 25.64}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 19.51, "max_temp": 23.75}, {"main_weather": "Rain", "description": "light rain", "min_temp": 20.69, "max_temp": 23.92}, {"main_weather": "Rain", "description": "light rain", "min_temp": 20.13, "max_temp": 27.1}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 20.75, "max_temp": 25.79}]}, "current_weather": true}
|
||||
{"feature": "Current Weather", "speed": "medium", "animation": "continuous", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Moscow": [{"main_weather": "Clouds", "description": "broken clouds", "min_temp": 4.6, "max_temp": 11.07}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 4.88, "max_temp": 11.53}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 4.11, "max_temp": 11.44}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 3.34, "max_temp": 10.75}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 3.99, "max_temp": 11.32}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 4.57, "max_temp": 11.12}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 3.94, "max_temp": 9.68}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 5.99, "max_temp": 10.77}], "Beijing": [{"main_weather": "Rain", "description": "light rain", "min_temp": 11.63, "max_temp": 14.76}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 10.22, "max_temp": 12.33}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 10.29, "max_temp": 17.61}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 11.53, "max_temp": 19.55}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 13.15, "max_temp": 19.6}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 14.29, "max_temp": 19.8}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 13.08, "max_temp": 18.87}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 11.42, "max_temp": 19.6}], "Tokyo": [{"main_weather": "Clear", "description": "clear sky", "min_temp": 21.42, "max_temp": 27.62}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 21.12, "max_temp": 26.36}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 20.3, "max_temp": 22.81}, {"main_weather": "Rain", "description": "light rain", "min_temp": 21.31, "max_temp": 26.99}, {"main_weather": "Rain", "description": "light rain", "min_temp": 20.53, "max_temp": 23.98}, {"main_weather": "Rain", "description": "light rain", "min_temp": 19.15, "max_temp": 24.43}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 21.26, "max_temp": 26.41}, {"main_weather": "Rain", "description": "light rain", "min_temp": 22.4, "max_temp": 26.43}], "London": [{"main_weather": "Rain", "description": "light rain", "min_temp": 11.77, "max_temp": 16.42}, {"main_weather": "Rain", "description": "heavy intensity rain", "min_temp": 10.89, "max_temp": 13.15}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 9.54, "max_temp": 15.37}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 10.64, "max_temp": 17.51}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 13.65, "max_temp": 17.56}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 14.4, "max_temp": 18.88}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 12.83, "max_temp": 18.66}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 12.03, "max_temp": 19.24}]}, "current_weather": true}
|
@ -1 +0,0 @@
|
||||
{"stocks": "19/09/2021 12:09:24", "crypto": "19/09/2021 12:09:26", "news": "19/09/2021 12:09:28", "weather": "19/09/2021 12:09:26", "forex": "19/09/2021 18:09:31", "sports": "19/09/2021 12:09:29"}
|
@ -1 +1 @@
|
||||
{"feature": "Stocks", "speed": "medium", "animation": "continuous", "percent": true, "point": false, "logos": true, "chart": false, "title": true, "symbols": {"MSFT": {"current": 299.35, "opening": 298.21}, "GOOG": {"current": 2854.185, "opening": 2821.99}}}
|
||||
{"feature": "Stocks", "speed": "medium", "animation": "continuous", "percent": true, "point": false, "logos": true, "chart": false, "title": true, "symbols": {"MSFT": {"current": 282.63, "opening": 287.28}, "GOOG": {"current": 2665.2, "opening": 2713.99}}}
|
9
log.txt
@ -0,0 +1,9 @@
|
||||
'StockTicker' object has no attribute 'readStocksCSV'. file: stockTicker.py. line: 2186. type: <class 'AttributeError'>
|
||||
Traceback (most recent call last):
|
||||
File "stockTicker.py", line 2186, in <module>
|
||||
stock_ticker.updateMultiple(['Stocks Prof'])
|
||||
File "stockTicker.py", line 276, in updateMultiple
|
||||
img = self.functions[option]()
|
||||
File "stockTicker.py", line 927, in getStockProfessional
|
||||
self.readStocksCSV()
|
||||
AttributeError: 'StockTicker' object has no attribute 'readStocksCSV'
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
356
stockTicker.py
@ -661,6 +661,8 @@ class StockTicker():
|
||||
title_img = self.openImage('feature_titles/crypto.png')
|
||||
image_list = [title_img]
|
||||
image_list.append(self.blank)
|
||||
else:
|
||||
image_list = []
|
||||
|
||||
|
||||
|
||||
@ -754,6 +756,8 @@ class StockTicker():
|
||||
title_img = self.openImage('feature_titles/forex.png')
|
||||
image_list = [title_img]
|
||||
image_list.append(self.blank)
|
||||
else:
|
||||
image_list = []
|
||||
|
||||
forex_settings = all_forex_settings['symbols']
|
||||
|
||||
@ -798,9 +802,17 @@ class StockTicker():
|
||||
|
||||
def getForexProfessional(self):
|
||||
|
||||
title_img = self.openImage('feature_titles/small_feature_titles/forex.png')
|
||||
self.blank = Image.new('RGB', (0, 16))
|
||||
image_list = [title_img, Image.new('RGB', (5, 16))]
|
||||
f = open('csv/forex_settings.json', 'r')
|
||||
all_forex_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
if all_forex_settings['title']:
|
||||
title_img = self.openImage('feature_titles/small_feature_titles/forex.png')
|
||||
self.blank = Image.new('RGB', (0, 16))
|
||||
image_list = [title_img, Image.new('RGB', (5, 16))]
|
||||
else:
|
||||
image_list = []
|
||||
|
||||
|
||||
base, currency_info = json.load(open('csv/currency.json', 'r'))
|
||||
currencies = ['AUD', 'CAD', 'CHF', 'EUR', 'GBP', 'JPY', 'NZD']
|
||||
@ -862,6 +874,8 @@ class StockTicker():
|
||||
title_img = self.openImage('feature_titles/stocks.png')
|
||||
image_list = [title_img]
|
||||
image_list.append(self.blank)
|
||||
else:
|
||||
image_list = []
|
||||
|
||||
|
||||
symbols = []
|
||||
@ -906,8 +920,17 @@ class StockTicker():
|
||||
return finalDisplayImage
|
||||
|
||||
def getStockProfessional(self):
|
||||
title_img = self.openImage('feature_titles/small_feature_titles/stocks.png')
|
||||
image_list = [title_img, Image.new('RGB', (5, 16))]
|
||||
|
||||
f = open('csv/stocks_settings.json', 'r')
|
||||
all_stocks_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
if all_stocks_settings['title']:
|
||||
title_img = self.openImage('feature_titles/small_feature_titles/stocks.png')
|
||||
image_list = [title_img, Image.new('RGB', (5, 16))]
|
||||
image_list.append(self.blank)
|
||||
else:
|
||||
image_list = []
|
||||
|
||||
self.readStocksCSV()
|
||||
|
||||
@ -915,11 +938,12 @@ class StockTicker():
|
||||
for i, symbol in enumerate(self.symbols):
|
||||
|
||||
|
||||
info = self.stock_info[symbol]
|
||||
info = stock_info[symbol]
|
||||
|
||||
change = float(info[0])-float(info[1]) #TEXT
|
||||
change = float(info['current'])-float(info['opening']) #TEXT
|
||||
ticker = symbol #TEXT
|
||||
current = '%.2f' % float(info[0]) #TEXT
|
||||
current = '%.2f' % float(info['current']) #TEXT
|
||||
|
||||
|
||||
arrow, change = self.getArrow(change, professional=True)
|
||||
change = '%.2f' % change
|
||||
@ -1079,9 +1103,6 @@ class StockTicker():
|
||||
|
||||
logo = Image.open(os.path.join(logos_path, logo_name + '.png'))
|
||||
|
||||
|
||||
|
||||
|
||||
width, height = logo.size
|
||||
|
||||
logo = logo.resize((int(width/2), int(height/2)))
|
||||
@ -1103,134 +1124,144 @@ class StockTicker():
|
||||
|
||||
def getLeagueImage(self, league=False, time = 'past'):
|
||||
|
||||
if not league:
|
||||
f = open( "csv/league.txt", 'r' )
|
||||
league = f.read().replace('\n', '')
|
||||
f.close()
|
||||
if time in ['past', 'live']:
|
||||
filepath = 'csv/{}_games.json'.format(time)
|
||||
|
||||
else:
|
||||
filepath = 'csv/upcoming_games.json'
|
||||
|
||||
|
||||
all_settings = json.load(open(filepath, 'r'))
|
||||
title_img = self.openImage('feature_titles/sports_'+ time + '.png')
|
||||
if all_settings['title']:
|
||||
title_img = self.openImage('feature_titles/sports_{}.png'.format(time))
|
||||
imgs = [title_img, self.blank]
|
||||
else:
|
||||
imgs = []
|
||||
|
||||
img = Image.new('RGB', (10000, 32))
|
||||
league_info = json.load(open('csv/sports/{}/{}_games.json'.format(league, time), 'r'))
|
||||
|
||||
leagues_info = all_settings['leagues']
|
||||
|
||||
leagues = list(leagues_info.keys())
|
||||
|
||||
|
||||
for league in leagues:
|
||||
|
||||
|
||||
|
||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||
med_font = ImageFont.load("./fonts/7x14B.pil")
|
||||
large_font = ImageFont.load("./fonts/9x18B.pil")
|
||||
img = Image.new('RGB', (10000, 32))
|
||||
league_info = json.load(open('csv/sports/{}/{}_games.json'.format(league, time), 'r'))
|
||||
|
||||
|
||||
|
||||
sports_info = self.readSportsCSV(league)
|
||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||
med_font = ImageFont.load("./fonts/7x14B.pil")
|
||||
large_font = ImageFont.load("./fonts/9x18B.pil")
|
||||
|
||||
|
||||
|
||||
buff_size = 25
|
||||
x_offset = 0
|
||||
sports_info = self.readSportsCSV(league)
|
||||
|
||||
|
||||
for match in league_info[-15:]:
|
||||
home_team = match['home_team']
|
||||
away_team = match['away_team']
|
||||
|
||||
home_score = match['home_score']
|
||||
away_score = match['away_score']
|
||||
|
||||
date = match['date'].replace('-', '.')
|
||||
|
||||
#rond = match['round']
|
||||
buff_size = 25
|
||||
x_offset = 0
|
||||
|
||||
|
||||
try:
|
||||
for match in league_info[-15:]:
|
||||
home_team = match['home_team']
|
||||
away_team = match['away_team']
|
||||
|
||||
home_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[home_team]['logo']))
|
||||
home_score = match['home_score']
|
||||
away_score = match['away_score']
|
||||
|
||||
except Exception as e:
|
||||
home_logo = self.textImage(home_team.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
|
||||
date = match['date'].replace('-', '.')
|
||||
|
||||
#rond = match['round']
|
||||
|
||||
|
||||
try:
|
||||
try:
|
||||
|
||||
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[away_team]['logo']))
|
||||
home_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[home_team]['logo']))
|
||||
|
||||
except Exception as e:
|
||||
away_logo = self.textImage(away_team.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
|
||||
except Exception as e:
|
||||
home_logo = self.textImage(home_team.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
|
||||
date_timage = self.textImage(date, small_font, r = 255, g = 255, b = 255)
|
||||
try:
|
||||
|
||||
img.paste(home_logo, (x_offset,0))
|
||||
away_logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[away_team]['logo']))
|
||||
|
||||
x_offset += home_logo.size[0] + 2
|
||||
except Exception as e:
|
||||
away_logo = self.textImage(away_team.replace(' ', '\n'), small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
|
||||
if time == 'future':
|
||||
img.paste(date_timage, (x_offset+5, 0))
|
||||
date_timage = self.textImage(date, small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
|
||||
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
|
||||
img.paste(home_logo, (x_offset,0))
|
||||
|
||||
x_offset += home_logo.size[0] + 2
|
||||
|
||||
|
||||
hc_timage = self.textImage(sports_info[home_team]['code'], med_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
|
||||
ac_timage = self.textImage(sports_info[away_team]['code'], med_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
|
||||
vs_timage = self.textImage('vs', med_font, r = 255, g = 255, b = 255, h_buff = 5)
|
||||
if time == 'future':
|
||||
img.paste(date_timage, (x_offset+5, 0))
|
||||
|
||||
img.paste(hc_timage, (x_offset, 9))
|
||||
img.paste(vs_timage, (x_offset + hc_timage.size[0], 9))
|
||||
img.paste(ac_timage, (x_offset + hc_timage.size[0] + vs_timage.size[0], 9))
|
||||
x_offset += max( date_timage.size[0], hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0])
|
||||
else:
|
||||
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
|
||||
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
|
||||
|
||||
score_image = self.textImage(home_score + '-' + away_score, large_font, h_buff = 5, r = 255, g = 255, b = 255)
|
||||
|
||||
#vs_timage = self.textImage(sports_info[home_team]['code'] + 'vs' + sports_info[away_team]['code'], small_font, r = 255, g = 255, b = 255)
|
||||
hc_timage = self.textImage(sports_info[home_team]['code'], med_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
|
||||
ac_timage = self.textImage(sports_info[away_team]['code'], med_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
|
||||
vs_timage = self.textImage('vs', med_font, r = 255, g = 255, b = 255, h_buff = 5)
|
||||
|
||||
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
|
||||
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
|
||||
|
||||
hc_timage = self.textImage(sports_info[home_team]['code'], small_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
|
||||
ac_timage = self.textImage(sports_info[away_team]['code'], small_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
|
||||
vs_timage = self.textImage('vs', small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
if date_timage.size[0] > score_image.size[0]:
|
||||
img.paste(date_timage, (x_offset+2, 0))
|
||||
img.paste(hc_timage, (x_offset+6, 9))
|
||||
img.paste(vs_timage, (x_offset+5 + hc_timage.size[0], 9))
|
||||
img.paste(ac_timage, (x_offset+6 + hc_timage.size[0] + vs_timage.size[0], 9))
|
||||
img.paste(score_image, (x_offset + 2 + int((date_timage.size[0] - score_image.size[0])/2), 15))
|
||||
img.paste(hc_timage, (x_offset, 9))
|
||||
img.paste(vs_timage, (x_offset + hc_timage.size[0], 9))
|
||||
img.paste(ac_timage, (x_offset + hc_timage.size[0] + vs_timage.size[0], 9))
|
||||
x_offset += max( date_timage.size[0], hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0])
|
||||
else:
|
||||
|
||||
img.paste(date_timage, (x_offset+1+int((score_image.size[0] - date_timage.size[0] )/2), 0))
|
||||
vs_size = hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]
|
||||
img.paste(hc_timage, (x_offset + 1 + int((score_image.size[0] - vs_size)/2), 9))
|
||||
img.paste(vs_timage, (x_offset + int((score_image.size[0] - vs_size)/2) + hc_timage.size[0], 9))
|
||||
img.paste(ac_timage, (x_offset+1 + int((score_image.size[0] - vs_size)/2) + hc_timage.size[0] + vs_timage.size[0], 9))
|
||||
score_image = self.textImage(home_score + '-' + away_score, large_font, h_buff = 5, r = 255, g = 255, b = 255)
|
||||
|
||||
img.paste(score_image, (x_offset+1, 15))
|
||||
#vs_timage = self.textImage(sports_info[home_team]['code'] + 'vs' + sports_info[away_team]['code'], small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
h_colour = mcolors.to_rgb(sports_info[home_team]['colour'].replace(' ', ''))
|
||||
a_colour = mcolors.to_rgb(sports_info[away_team]['colour'].replace(' ', ''))
|
||||
|
||||
hc_timage = self.textImage(sports_info[home_team]['code'], small_font, r = int(h_colour[0]*255), g = int(h_colour[1]*255), b = int(h_colour[2]*255))
|
||||
ac_timage = self.textImage(sports_info[away_team]['code'], small_font, r = int(a_colour[0]*255), g = int(a_colour[1]*255), b = int(a_colour[2]*255))
|
||||
vs_timage = self.textImage('vs', small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
if date_timage.size[0] > score_image.size[0]:
|
||||
img.paste(date_timage, (x_offset+2, 0))
|
||||
img.paste(hc_timage, (x_offset+6, 9))
|
||||
img.paste(vs_timage, (x_offset+5 + hc_timage.size[0], 9))
|
||||
img.paste(ac_timage, (x_offset+6 + hc_timage.size[0] + vs_timage.size[0], 9))
|
||||
img.paste(score_image, (x_offset + 2 + int((date_timage.size[0] - score_image.size[0])/2), 15))
|
||||
else:
|
||||
|
||||
img.paste(date_timage, (x_offset+1+int((score_image.size[0] - date_timage.size[0] )/2), 0))
|
||||
vs_size = hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]
|
||||
img.paste(hc_timage, (x_offset + 1 + int((score_image.size[0] - vs_size)/2), 9))
|
||||
img.paste(vs_timage, (x_offset + int((score_image.size[0] - vs_size)/2) + hc_timage.size[0], 9))
|
||||
img.paste(ac_timage, (x_offset+1 + int((score_image.size[0] - vs_size)/2) + hc_timage.size[0] + vs_timage.size[0], 9))
|
||||
|
||||
img.paste(score_image, (x_offset+1, 15))
|
||||
|
||||
|
||||
x_offset += max( date_timage.size[0]+4, hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]+4, 2 + int(score_image.size[0]))
|
||||
x_offset += max( date_timage.size[0]+4, hc_timage.size[0] + vs_timage.size[0] + ac_timage.size[0]+4, 2 + int(score_image.size[0]))
|
||||
|
||||
#img.paste(vs_timage, (x_offset+4, 9))
|
||||
#img.paste(vs_timage, (x_offset+4, 9))
|
||||
|
||||
#if league == 'NHL':
|
||||
#
|
||||
#if league == 'NHL':
|
||||
#
|
||||
#img.paste(round_timage, (x_offset+ 7, 8))
|
||||
#x_offset += max(home_timage.size[0], away_timage.size[0], date_timage.size[0], round_timage.size[0], score_image.size[0])
|
||||
|
||||
img.paste(away_logo, (x_offset,0))
|
||||
|
||||
|
||||
#img.paste(round_timage, (x_offset+ 7, 8))
|
||||
|
||||
|
||||
#x_offset += max(home_timage.size[0], away_timage.size[0], date_timage.size[0], round_timage.size[0], score_image.size[0])
|
||||
|
||||
|
||||
|
||||
|
||||
img.paste(away_logo, (x_offset,0))
|
||||
|
||||
x_offset += away_logo.size[0]
|
||||
x_offset += buff_size
|
||||
img = img.crop((0,0,x_offset ,32))
|
||||
x_offset += away_logo.size[0]
|
||||
x_offset += buff_size
|
||||
img = img.crop((0,0,x_offset ,32))
|
||||
|
||||
|
||||
|
||||
@ -1240,81 +1271,92 @@ class StockTicker():
|
||||
def getLeagueTableImage(self, league = False):
|
||||
|
||||
|
||||
if not league:
|
||||
f = open( "csv/table_league.txt", 'r' )
|
||||
league = f.read().replace('\n', '')
|
||||
f.close()
|
||||
all_settings = json.load(open('csv/league_tables.json', 'r'))
|
||||
|
||||
title_img = self.openImage('feature_titles/sports_team_stats.png')
|
||||
leagues_info = all_settings['leagues']
|
||||
|
||||
leagues = list(leagues_info.keys())
|
||||
|
||||
if all_settings['title']:
|
||||
title_img = self.openImage('feature_titles/sports_team_stats.png')
|
||||
imgs = [title_img, self.blank]
|
||||
else:
|
||||
imgs = []
|
||||
|
||||
for league in leagues:
|
||||
|
||||
|
||||
img = Image.new('RGB', (10000, 32))
|
||||
team_info = json.load(open('csv/sports/{}/team_stats.json'.format(league), 'r'))
|
||||
|
||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||
med_font = ImageFont.load("./fonts/8x13B.pil")
|
||||
large_font = ImageFont.load("./fonts/10x20.pil")
|
||||
img = Image.new('RGB', (10000, 32))
|
||||
team_info = leagues_info[league]
|
||||
|
||||
if league =='NHL': # read the NHl info from the csv, prem will need this as well
|
||||
sports_info = self.readSportsCSV(league)
|
||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||
med_font = ImageFont.load("./fonts/8x13B.pil")
|
||||
large_font = ImageFont.load("./fonts/10x20.pil")
|
||||
|
||||
buff_size = 20
|
||||
x_offset = 0
|
||||
for team in team_info:
|
||||
|
||||
try:
|
||||
if league == 'NHL':
|
||||
#if league =='NHL': # read the NHl info from the csv, prem will need this as well
|
||||
sports_info = self.readSportsCSV(league) # gets colour and symbol info etc from csv
|
||||
|
||||
buff_size = 20
|
||||
x_offset = 0
|
||||
for team in team_info:
|
||||
|
||||
try:
|
||||
|
||||
|
||||
logo = Image.open('logos/sports/{}/{}'.format(league, sports_info[team['name']]['logo']))
|
||||
elif league == 'premier_league':
|
||||
|
||||
logo = Image.open('logos/sports/{}/{}.png'.format(league, team['name']))
|
||||
img.paste(logo, (x_offset, 0))
|
||||
x_offset += logo.size[0] + 2
|
||||
except Exception as e:
|
||||
print('no logo for:', team['name'])
|
||||
img.paste(logo, (x_offset, 0))
|
||||
x_offset += logo.size[0] + 2
|
||||
except Exception as e:
|
||||
print('no logo for:', team['name'])
|
||||
|
||||
|
||||
name_timage = self.textImage(team['name'], med_font, r = 255, g = 255, b = 0)
|
||||
wins_timage = self.textImage('Wins:' + team['wins'], small_font, r = 0, g = 255, b = 0)
|
||||
loss_timage = self.textImage('Losses:' + team['loss'], small_font, r = 255, g = 0, b = 0)
|
||||
draw_timage = self.textImage('Draws:' + team['draw'], small_font, r = 0, g = 0, b = 255)
|
||||
points_timage = self.textImage('Points:' + team['points'], small_font, r = 255, g = 255, b = 255)
|
||||
standing_timage = self.textImage('Standing:' + team['standing'], small_font, r = 255, g = 255, b = 255)
|
||||
name_timage = self.textImage(team['name'], med_font, r = 255, g = 255, b = 0)
|
||||
wins_timage = self.textImage('Wins:' + team['wins'], small_font, r = 0, g = 255, b = 0)
|
||||
loss_timage = self.textImage('Losses:' + team['loss'], small_font, r = 255, g = 0, b = 0)
|
||||
draw_timage = self.textImage('Draws:' + team['draw'], small_font, r = 0, g = 0, b = 255)
|
||||
points_timage = self.textImage('Points:' + team['points'], small_font, r = 255, g = 255, b = 255)
|
||||
standing_timage = self.textImage('Standing:' + team['standing'], small_font, r = 255, g = 255, b = 255)
|
||||
|
||||
|
||||
|
||||
img.paste(name_timage, (x_offset, -1))
|
||||
img.paste(wins_timage, (x_offset, 12))
|
||||
img.paste(loss_timage, (x_offset, 19))
|
||||
img.paste(draw_timage, (x_offset, 26))
|
||||
img.paste(name_timage, (x_offset, -1))
|
||||
img.paste(wins_timage, (x_offset, 12))
|
||||
img.paste(loss_timage, (x_offset, 19))
|
||||
img.paste(draw_timage, (x_offset, 26))
|
||||
|
||||
x_offset += max( wins_timage.size[0], loss_timage.size[0], draw_timage.size[0])
|
||||
img.paste(points_timage, (x_offset, 14))
|
||||
img.paste(standing_timage, (x_offset, 22))
|
||||
x_offset += max( wins_timage.size[0], loss_timage.size[0], draw_timage.size[0])
|
||||
img.paste(points_timage, (x_offset, 14))
|
||||
img.paste(standing_timage, (x_offset, 22))
|
||||
|
||||
x_offset += max(points_timage.size[0], standing_timage.size[0]) + buff_size
|
||||
x_offset += max(points_timage.size[0], standing_timage.size[0]) + buff_size
|
||||
|
||||
|
||||
img = img.crop((0,0,x_offset ,32))
|
||||
img = img.crop((0,0,x_offset ,32))
|
||||
|
||||
return self.stitchImage([title_img, img])
|
||||
return self.stitchImage([title_img, img])
|
||||
|
||||
def getTodayWeatherImage(self):
|
||||
f = open( "csv/weather_location.txt", 'r' )
|
||||
line = next(f)
|
||||
locations = line.split(',')
|
||||
f.close()
|
||||
all_settings = json.load(open('csv/current_weather.json', 'r'))
|
||||
|
||||
if all_settings['title']:
|
||||
title_img = self.openImage('feature_titles/weather.png')
|
||||
imgs = [title_img, self.blank]
|
||||
else:
|
||||
imgs = []
|
||||
|
||||
|
||||
title_img = self.openImage('feature_titles/weather.png')
|
||||
imgs = [title_img, self.blank]
|
||||
current_weathers = json.load(open('csv/current_weather.json', 'r'))
|
||||
|
||||
current_weathers = all_settings['locations']
|
||||
locations = list(current_weathers.keys())
|
||||
|
||||
for i, location in enumerate(locations):
|
||||
img = Image.new('RGB', (203, 32))
|
||||
|
||||
|
||||
current_weather = current_weathers[i]
|
||||
current_weather = current_weathers[location]
|
||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||
large_font = ImageFont.load("./fonts/10x20.pil")
|
||||
|
||||
@ -1675,11 +1717,13 @@ class StockTicker():
|
||||
|
||||
daily_weathers = json.load(open('csv/daily_weather.json', 'r'))
|
||||
|
||||
locations = list(daily_weathers['locations'].keys())
|
||||
|
||||
for i, location in enumerate(locations):
|
||||
img = Image.new('RGB', (1000, 32))
|
||||
|
||||
current_weather = current_weathers[i]
|
||||
daily_weather = daily_weathers[i]
|
||||
current_weather = current_weathers['locations'][location]
|
||||
daily_weather = daily_weathers['locations'][location]
|
||||
|
||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||
extra_small_font = ImageFont.load("./fonts/4x6.pil")
|
||||
@ -1876,17 +1920,37 @@ class StockTicker():
|
||||
|
||||
title_img = self.openImage('feature_titles/images.png')
|
||||
|
||||
f = open('csv/image_settings.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
|
||||
image = self.openImage(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/user_image.ppm'))
|
||||
return self.stitchImage([title_img, image])
|
||||
|
||||
if all_settings['title']:
|
||||
imgs = [title_img, image]
|
||||
else:
|
||||
imgs = [image]
|
||||
|
||||
return self.stitchImage(imgs)
|
||||
|
||||
def getUserGIF(self):
|
||||
title_img = self.openImage('feature_titles/gifs.png')
|
||||
|
||||
gif = Image.open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_images/user_gif.gif'))
|
||||
|
||||
f = open('csv/GIF_settings.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
frames = []
|
||||
|
||||
for i, frame in enumerate(ImageSequence.Iterator(gif)):
|
||||
f = self.stitchImage([title_img, frame])
|
||||
|
||||
if all_settings['title']:
|
||||
f = self.stitchImage([title_img, frame])
|
||||
else:
|
||||
f = self.stitchImage([frame])
|
||||
frames.append(f)
|
||||
|
||||
|
||||
@ -2127,7 +2191,7 @@ if __name__ == '__main__':
|
||||
|
||||
start_image = Image.open('./logos/startup_logo.png')
|
||||
|
||||
stock_ticker.updateMultiple(['News'])
|
||||
stock_ticker.updateMultiple(['Stocks Prof', 'Crypto Prof', 'Forex Prof'])
|
||||
stock_ticker.setImage(start_image)
|
||||
time.sleep(1)
|
||||
stock_ticker.resetMatrix()
|
||||
|