mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-05 21:48:55 +01:00
general: Use sys.exit everywhere.
This commit is contained in:
parent
d67cd885ea
commit
b60d9d0d97
@ -73,16 +73,16 @@ def process_args(args):
|
||||
if not len(sys.argv) > 1:
|
||||
print("error: wal needs to be given arguments to run.\n"
|
||||
" Refer to \"wal -h\" for more info.")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
if args.i and args.f:
|
||||
print("error: Conflicting arguments -i and -f.\n"
|
||||
" Refer to \"wal -h\" for more info.")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
if args.v:
|
||||
print(f"wal {__version__}")
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
|
||||
if args.q:
|
||||
sys.stdout = sys.stderr = open(os.devnull, "w")
|
||||
@ -125,10 +125,6 @@ def main():
|
||||
args = get_args(sys.argv[1:])
|
||||
process_args(args)
|
||||
|
||||
# This saves 10ms.
|
||||
# pylint: disable=W0212
|
||||
# os._exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -4,6 +4,7 @@ Generate a colorscheme using imagemagick.
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from .settings import CACHE_DIR, COLOR_COUNT
|
||||
from . import util
|
||||
@ -25,7 +26,7 @@ def gen_colors(img, color_count):
|
||||
if not shutil.which("convert"):
|
||||
print("error: imagemagick not found, exiting...\n"
|
||||
"error: wal requires imagemagick to function.")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
raw_colors = imagemagick(color_count, img)
|
||||
|
||||
@ -41,7 +42,7 @@ def gen_colors(img, color_count):
|
||||
if index > 20:
|
||||
print("colors: Imagemagick couldn't generate a suitable scheme",
|
||||
"for the image. Exiting...")
|
||||
quit(1)
|
||||
sys.exit(1)
|
||||
|
||||
# Remove the first element because it isn't a color code.
|
||||
del raw_colors[0]
|
||||
|
@ -4,6 +4,7 @@ Get the image file.
|
||||
import os
|
||||
import pathlib
|
||||
import random
|
||||
import sys
|
||||
|
||||
from .settings import CACHE_DIR
|
||||
from . import util
|
||||
@ -21,7 +22,7 @@ def get_random_image(img_dir):
|
||||
|
||||
if not images:
|
||||
print("image: No new images found (nothing to do), exiting...")
|
||||
quit(1)
|
||||
sys.exit(1)
|
||||
|
||||
return str(img_dir / random.choice(images).name)
|
||||
|
||||
@ -38,7 +39,7 @@ def get(img, cache_dir=CACHE_DIR):
|
||||
|
||||
else:
|
||||
print("error: No valid image file found.")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
# Cache the image file path.
|
||||
util.save_file(wal_img, cache_dir / "wal")
|
||||
|
@ -4,6 +4,7 @@ Reload programs.
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from .settings import CACHE_DIR, HOME, MODULE_DIR
|
||||
from . import util
|
||||
@ -71,4 +72,4 @@ def colors(vte, cache_dir=CACHE_DIR):
|
||||
|
||||
print(sequences, end="")
|
||||
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
|
Loading…
Reference in New Issue
Block a user