From b2d8d49495385ba95ae1d01f7718322d702e19d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 12 Apr 2020 09:29:43 -0400 Subject: [PATCH] WIP --- bazarr.py | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/bazarr.py b/bazarr.py index fe07c9813..a689131d1 100644 --- a/bazarr.py +++ b/bazarr.py @@ -1,7 +1,7 @@ # coding=utf-8 -import bazarr.libs import os +import platform import signal import subprocess import sys @@ -15,14 +15,13 @@ def check_python_version(): minimum_py3_tuple = (3, 7, 0) minimum_py3_str = ".".join(str(i) for i in minimum_py3_tuple) - if int(python_version[0]) < 3: - print("Python " + minimum_py3_str + " or greater required. " - "Current version is " + platform.python_version() + ". Please upgrade Python.") + if int(python_version[0]) < minimum_py3_tuple[0]: + print("Python " + minimum_py3_str + " or greater required. Current version is " + platform.python_version() + + ". Please upgrade Python.") sys.exit(1) - elif (int(python_version[0]) == minimum_py3_tuple[0] and int(python_version[1]) < minimum_py3_tuple[1]) or \ - (int(python_version[0]) != minimum_py3_tuple[0] and int(python_version[0]) != minimum_py2_tuple[0]): - print("Python " + minimum_py3_str + " or greater required. " - "Current version is " + platform.python_version() + ". Please upgrade Python.") + elif int(python_version[1]) < minimum_py3_tuple[1]: + print("Python " + minimum_py3_str + " or greater required. Current version is " + platform.python_version() + + ". Please upgrade Python.") sys.exit(1) @@ -137,19 +136,19 @@ if __name__ == '__main__': daemonStatus = DaemonStatus() - def force_shutdown(): - # force the killing of children processes - daemonStatus.force_stop() - # if a new SIGTERM signal is caught the standard behaviour should be followed - signal.signal(signal.SIGTERM, signal.SIG_DFL) - # emulate a Ctrl C command on itself (bypasses the signal thing but, then, emulates the "Ctrl+C break") - os.kill(os.getpid(), signal.SIGINT) - - def shutdown(): - # indicates that everything should stop - daemonStatus.stop() - # if a new sigterm signal is caught it should force the shutdown of children processes - signal.signal(signal.SIGTERM, lambda signal_no, frame: force_shutdown()) + def force_shutdown(): + # force the killing of children processes + daemonStatus.force_stop() + # if a new SIGTERM signal is caught the standard behaviour should be followed + signal.signal(signal.SIGTERM, signal.SIG_DFL) + # emulate a Ctrl C command on itself (bypasses the signal thing but, then, emulates the "Ctrl+C break") + os.kill(os.getpid(), signal.SIGINT) + + def shutdown(): + # indicates that everything should stop + daemonStatus.stop() + # if a new sigterm signal is caught it should force the shutdown of children processes + signal.signal(signal.SIGTERM, lambda signal_no, frame: force_shutdown()) signal.signal(signal.SIGTERM, lambda signal_no, frame: shutdown())