From 91fa1e0ca5177587dfb8a8689dbec0aab7f440b8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 9 Jul 2017 23:27:15 +1000 Subject: [PATCH] export: Add error handling --- pywal/__main__.py | 13 ++++++++----- pywal/wallpaper.py | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index ff86b00..0be6cc8 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -89,20 +89,23 @@ def process_args(args): # -i if args.i: image_file = image.get_image(args.i) - - # Create a list of hex colors. colors_plain = magic.get_colors(image_file, args.q) - if not args.n: - wallpaper.set_wallpaper(image_file) - # -f elif args.f: colors_plain = util.read_file_json(args.f) + # If wallpaper is unset, set it to "None" + if "wallpaper" not in colors_plain: + colors_plain["wallpaper"] = "None" + # -i or -f if args.i or args.f: sequences.send_sequences(colors_plain, args.t) + + if not args.n: + wallpaper.set_wallpaper(colors_plain["wallpaper"]) + export.export_all_templates(colors_plain) reload.reload_env() diff --git a/pywal/wallpaper.py b/pywal/wallpaper.py index 59f1aeb..5e524a3 100644 --- a/pywal/wallpaper.py +++ b/pywal/wallpaper.py @@ -82,6 +82,9 @@ def set_desktop_wallpaper(desktop, img): def set_wallpaper(img): """Set the wallpaper.""" + if not os.path.isfile(img): + return + desktop = get_desktop_env() if desktop: