mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 18:50:38 +03:00
Added logs with translation for systemd_applier
This commit is contained in:
parent
692a950d4a
commit
9357d5006f
@ -19,7 +19,7 @@
|
||||
import dbus
|
||||
import logging
|
||||
|
||||
from util.logging import slogm
|
||||
from util.logging import slogm, log
|
||||
|
||||
class systemd_unit:
|
||||
def __init__(self, unit_name, state):
|
||||
@ -39,7 +39,10 @@ class systemd_unit:
|
||||
self.manager.UnmaskUnitFiles([self.unit_name], dbus.Boolean(False))
|
||||
self.manager.EnableUnitFiles([self.unit_name], dbus.Boolean(False), dbus.Boolean(True))
|
||||
self.manager.StartUnit(self.unit_name, 'replace')
|
||||
logging.info(slogm('Starting systemd unit: {}'.format(self.unit_name)))
|
||||
logdata = dict()
|
||||
logdata['unit'] = self.unit_name
|
||||
log('I6', logdata)
|
||||
#logging.info(slogm('Starting systemd unit: {}'.format(self.unit_name)))
|
||||
|
||||
# In case the service has 'RestartSec' property set it
|
||||
# switches to 'activating (auto-restart)' state instead of
|
||||
@ -47,17 +50,26 @@ class systemd_unit:
|
||||
service_state = self._get_state()
|
||||
|
||||
if not service_state in ['active', 'activating']:
|
||||
logging.error(slogm('Unable to start systemd unit {}'.format(self.unit_name)))
|
||||
logdata = dict()
|
||||
logdata['unit'] = self.unit_name
|
||||
log('E46', logdata)
|
||||
#logging.error(slogm('Unable to start systemd unit {}'.format(self.unit_name)))
|
||||
else:
|
||||
self.manager.StopUnit(self.unit_name, 'replace')
|
||||
self.manager.DisableUnitFiles([self.unit_name], dbus.Boolean(False))
|
||||
self.manager.MaskUnitFiles([self.unit_name], dbus.Boolean(False), dbus.Boolean(True))
|
||||
logging.info(slogm('Stopping systemd unit: {}'.format(self.unit_name)))
|
||||
logdata = dict()
|
||||
logdata['unit'] = self.unit_name
|
||||
log('I6', logdata)
|
||||
#logging.info(slogm('Stopping systemd unit: {}'.format(self.unit_name)))
|
||||
|
||||
service_state = self._get_state()
|
||||
|
||||
if not service_state in ['stopped']:
|
||||
logging.error(slogm('Unable to stop systemd unit {}'.format(self.unit_name)))
|
||||
logdata = dict()
|
||||
logdata['unit'] = self.unit_name
|
||||
log('E46', logdata)
|
||||
#logging.error(slogm('Unable to stop systemd unit {}'.format(self.unit_name)))
|
||||
|
||||
def _get_state(self):
|
||||
'''
|
||||
|
@ -21,7 +21,7 @@ from .applier_frontend import (
|
||||
, check_enabled
|
||||
)
|
||||
from .appliers.systemd import systemd_unit
|
||||
from util.logging import slogm
|
||||
from util.logging import slogm, log
|
||||
|
||||
import logging
|
||||
|
||||
@ -46,24 +46,36 @@ class systemd_applier(applier_frontend):
|
||||
valuename = setting.hive_key.rpartition('\\')[2]
|
||||
try:
|
||||
self.units.append(systemd_unit(valuename, int(setting.data)))
|
||||
logging.info(slogm('Working with systemd unit {}'.format(valuename)))
|
||||
logdata = dict()
|
||||
logdata['unit'] = format(valuename)
|
||||
log('I4', logdata)
|
||||
#logging.info(slogm('Working with systemd unit {}'.format(valuename)))
|
||||
except Exception as exc:
|
||||
logging.info(slogm('Unable to work with systemd unit {}: {}'.format(valuename, exc)))
|
||||
logdata = dict()
|
||||
logdata['unit'] = format(valuename)
|
||||
logdata['exc'] = exc
|
||||
log('I5', logdata)
|
||||
#logging.info(slogm('Unable to work with systemd unit {}: {}'.format(valuename, exc)))
|
||||
for unit in self.units:
|
||||
try:
|
||||
unit.apply()
|
||||
except:
|
||||
logging.error(slogm('Failed applying unit {}'.format(unit.unit_name)))
|
||||
logdata = dict()
|
||||
logdata['unit'] = unit.unit_name
|
||||
log('E45', logdata)
|
||||
#logging.error(slogm('Failed applying unit {}'.format(unit.unit_name)))
|
||||
|
||||
def apply(self):
|
||||
'''
|
||||
Trigger control facility invocation.
|
||||
'''
|
||||
if self.__module_enabled:
|
||||
logging.debug(slogm('Running systemd applier for machine'))
|
||||
log('D78')
|
||||
#logging.debug(slogm('Running systemd applier for machine'))
|
||||
self.run()
|
||||
else:
|
||||
logging.debug(slogm('systemd applier for machine will not be started'))
|
||||
log('D79')
|
||||
#logging.debug(slogm('systemd applier for machine will not be started'))
|
||||
|
||||
class systemd_applier_user(applier_frontend):
|
||||
__module_name = 'SystemdApplierUser'
|
||||
|
@ -44,6 +44,15 @@ msgstr "Неизвестный код информационного сообщ
|
||||
msgid "Working with control"
|
||||
msgstr "Применение настроек control"
|
||||
|
||||
msgid "Working with systemd"
|
||||
msgstr "Работа с systemd"
|
||||
|
||||
msgid "Unable to work with systemd unit"
|
||||
msgstr "Невозможно создать оъект для unit systemd"
|
||||
|
||||
msgid "Starting systemd unit"
|
||||
msgstr "Запуск unit systemd"
|
||||
|
||||
# Error
|
||||
msgid "Insufficient permissions to run gpupdate"
|
||||
msgstr "Недостаточно прав для запуска gpupdate"
|
||||
@ -153,6 +162,12 @@ msgstr "Невозможно установить"
|
||||
msgid "Unable to generate file"
|
||||
msgstr "Невозможно создать файл"
|
||||
|
||||
msgid "Failed applying unit"
|
||||
msgstr "Не удалось применить настройки"
|
||||
|
||||
msgid "Unable to start systemd unit"
|
||||
msgstr "Невозможно запустить systemd unit"
|
||||
|
||||
# Debug
|
||||
msgid "The GPOA process was started for user"
|
||||
msgstr "Произведён запуск GPOA для обновления политик пользователя"
|
||||
@ -349,6 +364,12 @@ msgstr "Polkit для пользователя в контексте админ
|
||||
msgid "Generated file"
|
||||
msgstr "Созданный файл"
|
||||
|
||||
msgid "Running systemd applier for machine"
|
||||
msgstr "Начато применение настроек systemd для машины"
|
||||
|
||||
msgid "Running systemd applier for machine will not be started"
|
||||
msgstr "Применение настроек systemd для машины не удалось"
|
||||
|
||||
|
||||
# Warning
|
||||
msgid "Unable to perform gpupdate for non-existent user, will update machine settings"
|
||||
|
@ -24,6 +24,10 @@ def info_code(code):
|
||||
info_ids[1] = 'Got GPO list for username'
|
||||
info_ids[2] = 'Got GPO'
|
||||
info_ids[3] = 'Working with control'
|
||||
info_ids[4] = 'Working with systemd'
|
||||
info_ids[5] = 'Unable to work with systemd unit'
|
||||
info_ids[6] = 'Starting systemd unit'
|
||||
|
||||
return info_ids.get(code, 'Unknown info code')
|
||||
|
||||
def error_code(code):
|
||||
@ -72,6 +76,8 @@ def error_code(code):
|
||||
error_ids[42] = 'Is not in possible values for control'
|
||||
error_ids[43] = 'Unable to set'
|
||||
error_ids[44] = 'Unable to generate file'
|
||||
error_ids[45] = 'Failed applying unit'
|
||||
error_ids[46] = 'Unable to start systemd unit'
|
||||
|
||||
return error_ids.get(code, 'Unknown error code')
|
||||
|
||||
@ -154,6 +160,8 @@ def debug_code(code):
|
||||
debug_ids[75] = 'Polkit applier for machine will not be started'
|
||||
debug_ids[76] = 'Polkit applier for user in administrator context will not be started'
|
||||
debug_ids[77] = 'Generated file'
|
||||
debug_ids[78] = 'Running systemd applier for machine'
|
||||
debug_ids[79] = 'Running systemd applier for machine will not be started'
|
||||
|
||||
return debug_ids.get(code, 'Unknown debug code')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user