mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 18:50:38 +03:00
Added logs with translation for shortcut_applier
This commit is contained in:
parent
57dda04216
commit
9571f46e73
@ -25,7 +25,7 @@ from .applier_frontend import (
|
||||
)
|
||||
from gpt.shortcuts import json2sc
|
||||
from util.windows import expand_windows_var
|
||||
from util.logging import slogm
|
||||
from util.logging import slogm, log
|
||||
from util.util import (
|
||||
get_homedir,
|
||||
homedir_exists
|
||||
@ -55,8 +55,10 @@ def apply_shortcut(shortcut, username=None):
|
||||
dest_abspath = shortcut.dest
|
||||
if not dest_abspath.startswith('/') and not dest_abspath.startswith('%'):
|
||||
dest_abspath = '%HOME%/' + dest_abspath
|
||||
|
||||
logging.debug(slogm('Try to expand path for shortcut: {} for {}'.format(dest_abspath, username)))
|
||||
logdata = dict()
|
||||
logdata['shortcut'] = dest_abspath
|
||||
logdata['for'] = username
|
||||
log('D105', logdata)
|
||||
dest_abspath = expand_windows_var(dest_abspath, username).replace('\\', '/') + '.desktop'
|
||||
|
||||
# Check that we're working for user, not on global system level
|
||||
@ -66,21 +68,33 @@ def apply_shortcut(shortcut, username=None):
|
||||
if dest_abspath.startswith(get_homedir(username)):
|
||||
# Don't try to operate on non-existent directory
|
||||
if not homedir_exists(username):
|
||||
logging.warning(slogm('No home directory exists for user {}: will not apply link {}'.format(username, dest_abspath)))
|
||||
logdata = dict()
|
||||
logdata['user'] = username
|
||||
logdata['dest_abspath'] = dest_abspath
|
||||
log('W7', logdata)
|
||||
return None
|
||||
else:
|
||||
logging.warning(slogm('User\'s shortcut not placed to home directory for {}: bad path {}'.format(username, dest_abspath)))
|
||||
logdata = dict()
|
||||
logdata['user'] = username
|
||||
logdata['bad path'] = dest_abspath
|
||||
log('W8', logdata)
|
||||
return None
|
||||
|
||||
if '%' in dest_abspath:
|
||||
logging.debug(slogm('Fail for applying shortcut to file with \'%\': {}'.format(dest_abspath)))
|
||||
logdata = dict()
|
||||
logdata['dest_abspath'] = dest_abspath
|
||||
log('E53', logdata)
|
||||
return None
|
||||
|
||||
if not dest_abspath.startswith('/'):
|
||||
logging.debug(slogm('Fail for applying shortcut to not absolute path \'%\': {}'.format(dest_abspath)))
|
||||
logdata = dict()
|
||||
logdata['dest_abspath'] = dest_abspath
|
||||
log('E54', logdata)
|
||||
return None
|
||||
|
||||
logging.debug(slogm('Applying shortcut file to {} with action {}'.format(dest_abspath, shortcut.action)))
|
||||
logdata = dict()
|
||||
logdata['file'] = dest_abspath
|
||||
logdata['with_action'] = shortcut.action
|
||||
log('D106', logdata)
|
||||
shortcut.apply_desktop(dest_abspath)
|
||||
|
||||
class shortcut_applier(applier_frontend):
|
||||
@ -108,14 +122,16 @@ class shortcut_applier(applier_frontend):
|
||||
# /usr/local/share/applications
|
||||
subprocess.check_call(['/usr/bin/update-desktop-database'])
|
||||
else:
|
||||
logging.debug(slogm('No shortcuts to process for {}'.format(self.storage.get_info('machine_sid'))))
|
||||
logdata = dict()
|
||||
logdata['machine_sid'] = self.storage.get_info('machine_sid')
|
||||
log('D100', logdata)
|
||||
|
||||
def apply(self):
|
||||
if self.__module_enabled:
|
||||
logging.debug(slogm('Running Shortcut applier for machine'))
|
||||
log('D98')
|
||||
self.run()
|
||||
else:
|
||||
logging.debug(slogm('Shortcut applier for machine will not be started'))
|
||||
log('D99')
|
||||
|
||||
class shortcut_applier_user(applier_frontend):
|
||||
__module_name = 'ShortcutsApplierUser'
|
||||
@ -137,19 +153,21 @@ class shortcut_applier_user(applier_frontend):
|
||||
if not in_usercontext and not sc.is_usercontext():
|
||||
apply_shortcut(sc, self.username)
|
||||
else:
|
||||
logging.debug(slogm('No shortcuts to process for {}'.format(self.sid)))
|
||||
logdata = dict()
|
||||
logdata['sid'] = self.sid
|
||||
log('D100', logdata)
|
||||
|
||||
def user_context_apply(self):
|
||||
if self.__module_enabled:
|
||||
logging.debug(slogm('Running Shortcut applier for user in user context'))
|
||||
log('D101')
|
||||
self.run(True)
|
||||
else:
|
||||
logging.debug(slogm('Shortcut applier for user in user context will not be started'))
|
||||
log('D102')
|
||||
|
||||
def admin_context_apply(self):
|
||||
if self.__module_enabled:
|
||||
logging.debug(slogm('Running Shortcut applier for user in administrator context'))
|
||||
log('D103')
|
||||
self.run(False)
|
||||
else:
|
||||
logging.debug(slogm('Shortcut applier for user in administrator context will not be started'))
|
||||
log('D104')
|
||||
|
||||
|
@ -198,6 +198,12 @@ msgstr "Файл настроек Chromium в данный момент не с
|
||||
msgid "Error during attempt to read Chromium preferences for user"
|
||||
msgstr "Ошибка при попытке прочитать настройки Chromium для пользователя"
|
||||
|
||||
msgid "Fail for applying shortcut to file with %"
|
||||
msgstr "Не удалось применить ярлык к файлу с %"
|
||||
|
||||
msgid "Fail for applying shortcut to not absolute path"
|
||||
msgstr "Не удалось применить ярлык к не абсолютному пути"
|
||||
|
||||
# Error_end
|
||||
|
||||
# Debug
|
||||
@ -459,6 +465,34 @@ msgstr "Применение настроек Chromium для компьютер
|
||||
msgid "Wrote Chromium preferences to"
|
||||
msgstr "Настройки Chromium записаны в"
|
||||
|
||||
msgid "Running Shortcut applier for machine"
|
||||
msgstr "Запуск применение ярлыков для машины"
|
||||
|
||||
msgid "Shortcut applier for machine will not be started"
|
||||
msgstr "Применение ярлыков для компьютера не запускается"
|
||||
|
||||
msgid "No shortcuts to process for"
|
||||
msgstr "Нет ярлыков для обработки"
|
||||
|
||||
msgid "Running Shortcut applier for user in user context"
|
||||
msgstr "Запуск применение ярлыков в контексте пользователя"
|
||||
|
||||
msgid "Shortcut applier for user in user context will not be started"
|
||||
msgstr "Применение ярлыков в контексте пользователя не запускается"
|
||||
|
||||
msgid "Running Shortcut applier for user in administrator context"
|
||||
msgstr "Запуск применение ярлыков в контексте администратора"
|
||||
|
||||
msgid "Shortcut applier for user in administrator context will not be started"
|
||||
msgstr "Применение ярлыков в контексте администратора не запускается"
|
||||
|
||||
msgid "Try to expand path for shortcut"
|
||||
msgstr "Попытка расширить путь для ярлыка"
|
||||
|
||||
msgid "Applying shortcut file to"
|
||||
msgstr "Применение ярлыка к файлу"
|
||||
|
||||
|
||||
# Debug_end
|
||||
|
||||
# Warning
|
||||
@ -484,6 +518,12 @@ msgstr "Неизвестный код предупреждения"
|
||||
msgid "Unable to resolve GSettings parameter"
|
||||
msgstr "Не удалось установить параметр GSettings"
|
||||
|
||||
msgid "No home directory exists for user"
|
||||
msgstr "Для пользователя не существует домашнего каталога"
|
||||
|
||||
msgid "User's shortcut not placed to home directory"
|
||||
msgstr "Ярлык пользователя не помещен в домашний каталог"
|
||||
|
||||
# Fatal
|
||||
msgid "Unable to refresh GPO list"
|
||||
msgstr "Невозможно обновить список объектов групповых политик"
|
||||
|
@ -87,6 +87,8 @@ def error_code(code):
|
||||
error_ids[50] = 'Unable to cache specified URI for user'
|
||||
error_ids[51] = 'Chromium preferences file does not exist at the moment'
|
||||
error_ids[52] = 'Error during attempt to read Chromium preferences for user'
|
||||
error_ids[53] = 'Fail for applying shortcut to file with \'%\''
|
||||
error_ids[54] = 'Fail for applying shortcut to not absolute path'
|
||||
|
||||
return error_ids.get(code, 'Unknown error code')
|
||||
|
||||
@ -189,7 +191,16 @@ def debug_code(code):
|
||||
debug_ids[95] = 'Running Chromium applier for machine'
|
||||
debug_ids[96] = 'Chromium applier for machine will not be started'
|
||||
debug_ids[97] = 'Wrote Chromium preferences to'
|
||||
|
||||
debug_ids[98] = 'Running Shortcut applier for machine'
|
||||
debug_ids[99] = 'Shortcut applier for machine will not be started'
|
||||
debug_ids[100] = 'No shortcuts to process for'
|
||||
debug_ids[101] = 'Running Shortcut applier for user in user context'
|
||||
debug_ids[102] = 'Shortcut applier for user in user context will not be started'
|
||||
debug_ids[103] = 'Running Shortcut applier for user in administrator context'
|
||||
debug_ids[104] = 'Shortcut applier for user in administrator context will not be started'
|
||||
debug_ids[105] = 'Try to expand path for shortcut'
|
||||
debug_ids[106] = 'Applying shortcut file to'
|
||||
|
||||
return debug_ids.get(code, 'Unknown debug code')
|
||||
|
||||
def warning_code(code):
|
||||
@ -206,6 +217,8 @@ def warning_code(code):
|
||||
warning_ids[4] = 'No SYSVOL entry assigned to GPO'
|
||||
warning_ids[5] = 'ADP package is not installed - plugin will not be initialized'
|
||||
warning_ids[6] = 'Unable to resolve GSettings parameter'
|
||||
warning_ids[7] = 'No home directory exists for user'
|
||||
warning_ids[8] = 'User\'s shortcut not placed to home directory'
|
||||
|
||||
return warning_ids.get(code, 'Unknown warning code')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user