mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-02-03 03:50:30 +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
|
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
|
from .. import util
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
"""
|
"""
|
||||||
Generate a colorscheme using Colorz.
|
Generate a colorscheme using Colorz.
|
||||||
"""
|
"""
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
from .. import util
|
from .. import util
|
||||||
|
|
||||||
@ -40,6 +42,11 @@ def adjust(colors, light):
|
|||||||
|
|
||||||
def get(img, light=False):
|
def get(img, light=False):
|
||||||
"""Get colorscheme."""
|
"""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 = gen_colors(img)
|
||||||
colors = [color.decode('UTF-8').split()[0] for color in colors]
|
colors = [color.decode('UTF-8').split()[0] for color in colors]
|
||||||
return adjust(colors, light)
|
return adjust(colors, light)
|
||||||
|
@ -26,8 +26,8 @@ def has_im():
|
|||||||
elif shutil.which("convert"):
|
elif shutil.which("convert"):
|
||||||
return ["convert"]
|
return ["convert"]
|
||||||
|
|
||||||
print("error: imagemagick not found, exiting...\n"
|
print("Error: ImageMagick wasn't found on your system.",
|
||||||
"error: wal requires imagemagick to function.")
|
"Try another backend. (wal --backend)")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ Generate a palette using various backends.
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from . import backends
|
from . import backends
|
||||||
|
Loading…
Reference in New Issue
Block a user