From 03e0cec715996fa0c22abf460342b57818e7e826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 27 Oct 2019 23:34:52 +0100 Subject: [PATCH] return with non-zero exit status on error --- bin/gallery-dl | 7 +++---- gallery_dl/__init__.py | 10 +++++++--- gallery_dl/__main__.py | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bin/gallery-dl b/bin/gallery-dl index 12da2fd3..e7d2bb26 100755 --- a/bin/gallery-dl +++ b/bin/gallery-dl @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -# -*- coding: UTF-8 -*- +# -*- coding: utf-8 -*- +import sys import gallery_dl - -if __name__ == '__main__': - gallery_dl.main() +sys.exit(gallery_dl.main()) diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index 94a445a6..cdea21fb 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -234,6 +234,7 @@ def main(): if pformat and len(urls) > 1 and args.loglevel < logging.ERROR: urls = progress(urls, pformat) + retval = 0 for url in urls: try: log.debug("Starting %s for '%s'", jobtype.__name__, url) @@ -241,17 +242,20 @@ def main(): for key, value in url.gconfig: config.set(key, value) with config.apply(url.lconfig): - jobtype(url.value).run() + retval |= jobtype(url.value).run() else: - jobtype(url).run() + retval |= jobtype(url).run() except exception.NoExtractorError: log.error("No suitable extractor found for '%s'", url) + retval |= 128 + return retval except KeyboardInterrupt: sys.exit("\nKeyboardInterrupt") except BrokenPipeError: pass - except IOError as exc: + except OSError as exc: import errno if exc.errno != errno.EPIPE: raise + return 1 diff --git a/gallery_dl/__main__.py b/gallery_dl/__main__.py index 04ea9fe1..637d463f 100644 --- a/gallery_dl/__main__.py +++ b/gallery_dl/__main__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2017 Mike Fährmann +# Copyright 2017-2019 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -17,4 +17,4 @@ if __package__ is None and not hasattr(sys, "frozen"): import gallery_dl if __name__ == "__main__": - gallery_dl.main() + sys.exit(gallery_dl.main())