mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-23 22:38:36 +01:00
backend: Error handling
This commit is contained in:
parent
277edbc5e0
commit
c10f7e7323
@ -3,7 +3,13 @@ Generate a colorscheme using ColorThief.
|
||||
"""
|
||||
import sys
|
||||
|
||||
from colorthief import ColorThief
|
||||
try:
|
||||
from colorthief import ColorThief
|
||||
|
||||
except ImportError:
|
||||
print("Error: ColorThief wasn't found on your system.",
|
||||
"Try another backend. (wal --backend)")
|
||||
sys.exit(1)
|
||||
|
||||
from .. import util
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
"""
|
||||
Generate a colorscheme using Colorz.
|
||||
"""
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from .. import util
|
||||
|
||||
@ -40,6 +42,11 @@ def adjust(colors, light):
|
||||
|
||||
def get(img, light=False):
|
||||
"""Get colorscheme."""
|
||||
if not shutil.which("colorz"):
|
||||
print("Error: Colorz wasn't found on your system.",
|
||||
"Try another backend. (wal --backend)")
|
||||
sys.exit(1)
|
||||
|
||||
colors = gen_colors(img)
|
||||
colors = [color.decode('UTF-8').split()[0] for color in colors]
|
||||
return adjust(colors, light)
|
||||
|
@ -26,8 +26,8 @@ def has_im():
|
||||
elif shutil.which("convert"):
|
||||
return ["convert"]
|
||||
|
||||
print("error: imagemagick not found, exiting...\n"
|
||||
"error: wal requires imagemagick to function.")
|
||||
print("Error: ImageMagick wasn't found on your system.",
|
||||
"Try another backend. (wal --backend)")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ Generate a palette using various backends.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from . import backends
|
||||
|
Loading…
Reference in New Issue
Block a user