Commit 3982f39d authored by Wolfgang Rohdewald's avatar Wolfgang Rohdewald
Browse files

pylint: move duplicate code into handleSignals()

parent 1fed5fe3
......@@ -15,6 +15,7 @@ import shutil
import logging
import logging.handlers
import socket
from signal import signal, SIGABRT, SIGINT, SIGTERM
from qt import QStandardPaths
try:
......@@ -139,6 +140,19 @@ def socketName():
return os.path.normpath('{}/socket{}'.format(serverDir, Internal.defaultPort))
def handleSignals(handler):
"""set up signal handling"""
signal(SIGABRT, handler)
signal(SIGINT, handler)
signal(SIGTERM, handler)
if os.name != 'nt':
from signal import SIGHUP, SIGQUIT
signal(SIGHUP, handler)
signal(SIGQUIT, handler)
class Debug:
"""holds flags for debugging output. At a later time we might
......
......@@ -10,7 +10,6 @@ SPDX-License-Identifier: GPL-2.0
# pylint: disable=wrong-import-order, wrong-import-position
import sys
import os
import codecs
from itertools import chain
......@@ -18,10 +17,9 @@ import cgitb
import tempfile
import webbrowser
import logging
from signal import signal, SIGABRT, SIGINT, SIGTERM
from log import logError, logDebug
from common import Options, Internal, isAlive, Debug
from common import Options, Internal, isAlive, Debug, handleSignals
class MyHook(cgitb.Hook):
......@@ -111,13 +109,7 @@ def cleanExit(*unusedArgs): # pylint: disable=unused-argument
# sys.exit(0)
MainWindow.aboutToQuit()
signal(SIGABRT, cleanExit)
signal(SIGINT, cleanExit)
signal(SIGTERM, cleanExit)
if os.name != 'nt':
from signal import SIGHUP, SIGQUIT
signal(SIGHUP, cleanExit)
signal(SIGQUIT, cleanExit)
handleSignals(cleanExit)
class MainWindow(KXmlGuiWindow):
......
......@@ -17,7 +17,6 @@ import sys
import os
import logging
import datetime
from signal import signal, SIGABRT, SIGINT, SIGTERM
from zope.interface import implementer
......@@ -45,14 +44,8 @@ def cleanExit(*unusedArgs): # pylint: disable=unused-argument
except ReactorNotRunning:
pass
signal(SIGABRT, cleanExit)
signal(SIGINT, cleanExit)
signal(SIGTERM, cleanExit)
if os.name != 'nt':
from signal import SIGHUP, SIGQUIT
signal(SIGHUP, cleanExit)
signal(SIGQUIT, cleanExit)
from common import handleSignals
handleSignals(cleanExit)
from common import Options, Internal, Debug
Internal.isServer = True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment