Skip to content

Commit 4ae1884

Browse files
committed
common.py: Fix downloading web icons.
There was a namespace conflict with PIL.Image and PIL.Image.Image.
1 parent d9fc766 commit 4ae1884

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

usr/lib/webapp-manager/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
# 2. Related third party imports.
2323
from gi.repository import GObject
24-
from PIL.Image import Image
24+
import PIL.Image
2525
import requests
2626
# Note: BeautifulSoup is an optional import supporting another way of getting a website's favicons.
2727

@@ -394,17 +394,17 @@ def normalize_url(url):
394394
return urllib.parse.urlunparse((scheme, path, "", "", "", ""))
395395
return urllib.parse.urlunparse((scheme, netloc, path, "", "", ""))
396396

397-
def download_image(root_url: str, link: str) -> Optional[Image]:
397+
def download_image(root_url: str, link: str) -> Optional[PIL.Image.Image]:
398398
if "://" not in link:
399399
if link.startswith("/"):
400400
link = root_url + link
401401
else:
402402
link = root_url + "/" + link
403403
try:
404404
response = requests.get(link, timeout=3)
405-
image = Image.open(BytesIO(response.content))
405+
image = PIL.Image.open(BytesIO(response.content))
406406
if image.height > 256:
407-
return image.resize((256, 256), Image.BICUBIC)
407+
return image.resize((256, 256), PIL.Image.BICUBIC)
408408
return image
409409
except Exception as e:
410410
print(e)

0 commit comments

Comments
 (0)