From 4e7d568ee514a00316778d688109e79f90d870ab Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 25 Apr 2023 18:52:10 +0800 Subject: [PATCH] try except added for fighter country img --- stockTicker.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/stockTicker.py b/stockTicker.py index 4eaeaba..4095326 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -2827,9 +2827,12 @@ class StockTicker(): max_fighter1_pic = max(fighter1_img.size[0], name1_img.size[0], record1_img.size[0]) draw = ImageDraw.Draw(img, "RGBA") img.paste(fighter1_img, (x_offset + int(max_fighter1_pic/2) - int(fighter1_img.size[0]/2), 0), mask=fighter1_img) - country1_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter1country'].split('/')[-1].split('&')[0])) - country1_img.thumbnail((9000,12)) - img.paste(country1_img,(x_offset, 0)) + try: + country1_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter1country'].split('/')[-1].split('&')[0])) + country1_img.thumbnail((9000,12)) + img.paste(country1_img,(x_offset, 0)) + except: + pass draw.rectangle([(x_offset,32),(x_offset + max(name1_img.size[0],record1_img.size[0])-4,21)], fill=(5,5,5,200)) @@ -2895,10 +2898,12 @@ class StockTicker(): draw.text((widest + int(weight_img.size[0]/2) + 2,0), 'DRAW', fill=(80,80,80),font=extra_small_font) else: draw.text((widest + int(weight_img.size[0]/2) + 2,0), 'LOSS', fill=(255,0,0),font=extra_small_font) - - country2_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter2country'].split('/')[-1].split('&')[0])) - country2_img.thumbnail((9000,12)) - img.paste(country2_img,(x_offset-country2_img.size[0]-25, 0)) + try: + country2_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter2country'].split('/')[-1].split('&')[0])) + country2_img.thumbnail((9000,12)) + img.paste(country2_img,(x_offset-country2_img.size[0]-25, 0)) + except: + pass except: pass