pull/936/head
Louis Vézina 5 years ago
parent 1f25fdde2f
commit b2d8d49495

@ -1,7 +1,7 @@
# coding=utf-8 # coding=utf-8
import bazarr.libs
import os import os
import platform
import signal import signal
import subprocess import subprocess
import sys import sys
@ -15,14 +15,13 @@ def check_python_version():
minimum_py3_tuple = (3, 7, 0) minimum_py3_tuple = (3, 7, 0)
minimum_py3_str = ".".join(str(i) for i in minimum_py3_tuple) minimum_py3_str = ".".join(str(i) for i in minimum_py3_tuple)
if int(python_version[0]) < 3: if int(python_version[0]) < minimum_py3_tuple[0]:
print("Python " + minimum_py3_str + " or greater required. " print("Python " + minimum_py3_str + " or greater required. Current version is " + platform.python_version() +
"Current version is " + platform.python_version() + ". Please upgrade Python.") ". Please upgrade Python.")
sys.exit(1) sys.exit(1)
elif (int(python_version[0]) == minimum_py3_tuple[0] and int(python_version[1]) < minimum_py3_tuple[1]) or \ elif int(python_version[1]) < minimum_py3_tuple[1]:
(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() +
print("Python " + minimum_py3_str + " or greater required. " ". Please upgrade Python.")
"Current version is " + platform.python_version() + ". Please upgrade Python.")
sys.exit(1) sys.exit(1)
@ -137,19 +136,19 @@ if __name__ == '__main__':
daemonStatus = DaemonStatus() daemonStatus = DaemonStatus()
def force_shutdown(): def force_shutdown():
# force the killing of children processes # force the killing of children processes
daemonStatus.force_stop() daemonStatus.force_stop()
# if a new SIGTERM signal is caught the standard behaviour should be followed # if a new SIGTERM signal is caught the standard behaviour should be followed
signal.signal(signal.SIGTERM, signal.SIG_DFL) 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") # emulate a Ctrl C command on itself (bypasses the signal thing but, then, emulates the "Ctrl+C break")
os.kill(os.getpid(), signal.SIGINT) os.kill(os.getpid(), signal.SIGINT)
def shutdown(): def shutdown():
# indicates that everything should stop # indicates that everything should stop
daemonStatus.stop() daemonStatus.stop()
# if a new sigterm signal is caught it should force the shutdown of children processes # 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: force_shutdown())
signal.signal(signal.SIGTERM, lambda signal_no, frame: shutdown()) signal.signal(signal.SIGTERM, lambda signal_no, frame: shutdown())

Loading…
Cancel
Save