diff --git a/matter.py b/matter.py index 3abe6c3..1962694 100755 --- a/matter.py +++ b/matter.py @@ -11,7 +11,12 @@ from argparse import ArgumentParser, RawTextHelpFormatter from os.path import dirname, basename, isdir, exists from shutil import which, rmtree, copytree, copyfile -from PIL import Image +try: + from PIL import Image +except: + has_PIL = False +else: + has_PIL = True # Local Matter modules from utils import * @@ -179,13 +184,16 @@ def download_icon(icon_name): def download_background(background_path): + if not has_PIL: + error("PIL not detected, cannot download background") info(f"Downloading background image") + url = f"{background_path}" try: with request.urlopen(url) as f: response = f.read() except HTTPError as err: # A subclass of URLError - error(f"Couldn't get background image ({err.reason})", f"At URL {err.geturl()}") + error(f"Couldn't get background image ({err.reason})", f"At URL {err.geturl()}") except URLError as err: error(f"Couldn't get background image ({err.reason})") bg_path = BACKGROUND_TMP_PATHF.format('background_image') @@ -215,7 +223,7 @@ def convert_icon_svg2png(icon_name, whisper=False): if not has_command("inkscape"): if not has_command("convert"): error( - "Stop. Both `inkscape` and `convert` command from imagemagick was not found", + "Stop. Both `inkscape` and `convert` command from imagemagick were not found", "Consider installing `inkscape` for the best results", ) else: @@ -505,7 +513,7 @@ def do_preinstall_hint(): f"{color_string('Grub Theme'.upper(), fg='lightcyan')}" f"{color_string(' ]', fg='brightwhite')}" ) - info("Argument -i required. Which icons go to which grub entries?.") + info("Argument -i required. Which icons go to which grub entries?") info("Your grub entries are:") do_list_grub_cfg_entries() info("Look for icons you like at https://materialdesignicons.com/")