diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2018-04-01 12:28:32 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2018-04-01 12:28:32 +1000 |
| commit | cf6ac7944d08e64a1392a9ee4ec46a3624732418 (patch) | |
| tree | 54784210f3a51955e4a25face379117684f5067c /pywal/backends | |
| parent | d5f39135b2d054af23c0af8594ee772b2a544669 (diff) | |
general: Added logging.
Diffstat (limited to 'pywal/backends')
| -rw-r--r-- | pywal/backends/colorthief.py | 12 | ||||
| -rw-r--r-- | pywal/backends/colorz.py | 5 | ||||
| -rw-r--r-- | pywal/backends/haishoku.py | 5 | ||||
| -rw-r--r-- | pywal/backends/schemer2.py | 5 | ||||
| -rw-r--r-- | pywal/backends/wal.py | 12 |
5 files changed, 21 insertions, 18 deletions
diff --git a/pywal/backends/colorthief.py b/pywal/backends/colorthief.py index 180af5f..7b2e2bc 100644 --- a/pywal/backends/colorthief.py +++ b/pywal/backends/colorthief.py @@ -1,14 +1,15 @@ """ Generate a colorscheme using ColorThief. """ +import logging import sys try: from colorthief import ColorThief except ImportError: - print("error: ColorThief wasn't found on your system.", - "Try another backend. (wal --backend)") + logging.error("ColorThief wasn't found on your system.") + logging.error("Try another backend. (wal --backend)") sys.exit(1) from .. import util @@ -25,13 +26,12 @@ def gen_colors(img): break elif i == 19: - print("colors: ColorThief couldn't generate a suitable palette", - "for the image. Exiting...") + logging.error("ColorThief couldn't generate a suitable palette.") sys.exit(1) else: - print("colors: ColorThief couldn't create a suitable palette, " - "trying a larger palette size", 8 + i) + logging.warning("ColorThief couldn't generate a palette.") + logging.warning("Trying a larger palette size %s", 8 + i) return [util.rgb_to_hex(color) for color in raw_colors] diff --git a/pywal/backends/colorz.py b/pywal/backends/colorz.py index 0c5148d..490f585 100644 --- a/pywal/backends/colorz.py +++ b/pywal/backends/colorz.py @@ -1,6 +1,7 @@ """ Generate a colorscheme using Colorz. """ +import logging import shutil import subprocess import sys @@ -28,8 +29,8 @@ def adjust(cols, 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)") + logging.error("Colorz wasn't found on your system.") + logging.error("Try another backend. (wal --backend)") sys.exit(1) cols = [col.decode('UTF-8').split()[0] for col in gen_colors(img)] diff --git a/pywal/backends/haishoku.py b/pywal/backends/haishoku.py index 413c9d7..00025b2 100644 --- a/pywal/backends/haishoku.py +++ b/pywal/backends/haishoku.py @@ -1,14 +1,15 @@ """ Generate a colorscheme using Haishoku. """ +import logging import sys try: from haishoku.haishoku import Haishoku except ImportError: - print("error: Haishoku wasn't found on your system.", - "Try another backend. (wal --backend)") + logging.error("Haishoku wasn't found on your system.") + logging.error("Try another backend. (wal --backend)") sys.exit(1) from .. import colors diff --git a/pywal/backends/schemer2.py b/pywal/backends/schemer2.py index 87873ec..adae650 100644 --- a/pywal/backends/schemer2.py +++ b/pywal/backends/schemer2.py @@ -1,6 +1,7 @@ """ Generate a colorscheme using Schemer2. """ +import logging import shutil import subprocess import sys @@ -26,8 +27,8 @@ def adjust(cols, light): def get(img, light=False): """Get colorscheme.""" if not shutil.which("schemer2"): - print("error: Schemer2 wasn't found on your system.", - "Try another backend. (wal --backend)") + logging.error("Schemer2 wasn't found on your system.") + logging.error("Try another backend. (wal --backend)") sys.exit(1) cols = [col.decode('UTF-8') for col in gen_colors(img)] diff --git a/pywal/backends/wal.py b/pywal/backends/wal.py index 678c66c..cd13092 100644 --- a/pywal/backends/wal.py +++ b/pywal/backends/wal.py @@ -1,6 +1,7 @@ """ Generate a colorscheme using imagemagick. """ +import logging import re import shutil import subprocess @@ -26,8 +27,8 @@ def has_im(): elif shutil.which("convert"): return ["convert"] - print("error: ImageMagick wasn't found on your system.", - "Try another backend. (wal --backend)") + logging.error("Imagemagick wasn't found on your system.") + logging.error("Try another backend. (wal --backend)") sys.exit(1) @@ -43,13 +44,12 @@ def gen_colors(img): break elif i == 19: - print("colors: Imagemagick couldn't generate a suitable palette", - "for the image. Exiting...") + logging.error("Imagemagick couldn't generate a suitable palette.") sys.exit(1) else: - print("colors: Imagemagick couldn't generate a suitable palette, " - "trying a larger palette size", 16 + i) + logging.warning("Imagemagick couldn't generate a palette.") + logging.warning("Trying a larger palette size %s", 16 + i) return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]] |
