mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-08-25 09:49:53 +03:00
Merge pull request #39 from altlinux/initial_signal_handling
Initial signal handling tested.
This commit is contained in:
@ -20,6 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import signal
|
||||||
|
|
||||||
from backend import backend_factory
|
from backend import backend_factory
|
||||||
from frontend.frontend_manager import frontend_manager, determine_username
|
from frontend.frontend_manager import frontend_manager, determine_username
|
||||||
@ -35,6 +36,7 @@ from util.arguments import (
|
|||||||
set_loglevel
|
set_loglevel
|
||||||
)
|
)
|
||||||
from util.logging import slogm
|
from util.logging import slogm
|
||||||
|
from util.signals import signal_handler
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
arguments = argparse.ArgumentParser(description='Generate configuration out of parsed policies')
|
arguments = argparse.ArgumentParser(description='Generate configuration out of parsed policies')
|
||||||
@ -128,5 +130,6 @@ def main():
|
|||||||
controller.run()
|
controller.run()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import pwd
|
import pwd
|
||||||
|
import signal
|
||||||
|
|
||||||
from util.users import (
|
from util.users import (
|
||||||
is_root
|
is_root
|
||||||
@ -36,6 +37,7 @@ from util.dbus import (
|
|||||||
is_oddjobd_gpupdate_accessible,
|
is_oddjobd_gpupdate_accessible,
|
||||||
dbus_runner
|
dbus_runner
|
||||||
)
|
)
|
||||||
|
from util.signals import signal_handler
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
@ -155,5 +157,6 @@ def main():
|
|||||||
return int(ExitCodeUpdater.EXIT_SUCCESS)
|
return int(ExitCodeUpdater.EXIT_SUCCESS)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
sys.exit(int(main()))
|
sys.exit(int(main()))
|
||||||
|
|
||||||
|
@ -84,4 +84,5 @@ class ExitCodeUpdater(IntEnum):
|
|||||||
FAIL_NO_RUNNER = 1
|
FAIL_NO_RUNNER = 1
|
||||||
FAIL_GPUPDATE_COMPUTER_NOREPLY = 2
|
FAIL_GPUPDATE_COMPUTER_NOREPLY = 2
|
||||||
FAIL_GPUPDATE_USER_NOREPLY = 3
|
FAIL_GPUPDATE_USER_NOREPLY = 3
|
||||||
|
EXIT_SIGINT = 130
|
||||||
|
|
||||||
|
31
gpoa/util/signals.py
Normal file
31
gpoa/util/signals.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#
|
||||||
|
# GPOA - GPO Applier for Linux
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019-2020 BaseALT Ltd.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import signal
|
||||||
|
from sys import exit
|
||||||
|
|
||||||
|
from .arguments import ExitCodeUpdater
|
||||||
|
|
||||||
|
default_handler = signal.getsignal(signal.SIGINT)
|
||||||
|
|
||||||
|
def signal_handler(sig_number, frame):
|
||||||
|
# Ignore extra signals
|
||||||
|
signal.signal(sig_number, signal.SIG_IGN)
|
||||||
|
print('Received signal, exiting gracefully')
|
||||||
|
exit(ExitCodeUpdater.EXIT_SIGINT)
|
||||||
|
|
Reference in New Issue
Block a user