'sys.exit' -> 'SystemExit'

pull/4489/head
Mike Fährmann 1 year ago
parent 410f783a33
commit 92f98e6f5e
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -297,7 +297,7 @@ def main():
return retval return retval
except KeyboardInterrupt: except KeyboardInterrupt:
sys.exit("\nKeyboardInterrupt") raise SystemExit("\nKeyboardInterrupt")
except BrokenPipeError: except BrokenPipeError:
pass pass
except OSError as exc: except OSError as exc:

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2017-2019 Mike Fährmann # Copyright 2017-2023 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # 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 import gallery_dl
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(gallery_dl.main()) raise SystemExit(gallery_dl.main())

@ -9,7 +9,6 @@
""" """ """ """
import re import re
import sys
import logging import logging
import operator import operator
from . import util, exception from . import util, exception
@ -98,7 +97,7 @@ def action_exit(opts):
pass pass
def _exit(args): def _exit(args):
sys.exit(opts) raise SystemExit(opts)
return _exit return _exit

@ -100,12 +100,12 @@ def load(files=None, strict=False, loads=util.json_loads):
except OSError as exc: except OSError as exc:
if strict: if strict:
log.error(exc) log.error(exc)
sys.exit(1) raise SystemExit(1)
except Exception as exc: except Exception as exc:
log.error("%s when loading '%s': %s", log.error("%s when loading '%s': %s",
exc.__class__.__name__, path, exc) exc.__class__.__name__, path, exc)
if strict: if strict:
sys.exit(2) raise SystemExit(2)
else: else:
if not _config: if not _config:
_config.update(conf) _config.update(conf)

@ -515,7 +515,7 @@ class DownloadJob(Job):
elif skip == "terminate": elif skip == "terminate":
self._skipexc = exception.TerminateExtraction self._skipexc = exception.TerminateExtraction
elif skip == "exit": elif skip == "exit":
self._skipexc = sys.exit self._skipexc = SystemExit
self._skipmax = text.parse_int(smax) self._skipmax = text.parse_int(smax)
else: else:
# monkey-patch methods to always return False # monkey-patch methods to always return False

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2020-2021 Mike Fährmann # Copyright 2020-2023 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@ -10,7 +10,6 @@
from .common import PostProcessor from .common import PostProcessor
from .. import text, util, exception from .. import text, util, exception
import sys
import os import os
@ -31,7 +30,7 @@ class ComparePP(PostProcessor):
elif equal == "terminate": elif equal == "terminate":
self._equal_exc = exception.TerminateExtraction self._equal_exc = exception.TerminateExtraction
elif equal == "exit": elif equal == "exit":
self._equal_exc = sys.exit self._equal_exc = SystemExit
job.register_hooks({"file": ( job.register_hooks({"file": (
self.enumerate self.enumerate

Loading…
Cancel
Save