export: Add error handling

This commit is contained in:
Dylan Araps 2017-07-09 23:27:15 +10:00
parent 07fd6fa661
commit 91fa1e0ca5
2 changed files with 11 additions and 5 deletions

View File

@ -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()

View File

@ -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: