1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-08-25 09:49:53 +03:00

Added handling of missing files

This commit is contained in:
Valery Sinelnikov
2023-09-19 11:17:29 +04:00
parent 78815c5ecd
commit 5c0fc9bed0
3 changed files with 26 additions and 25 deletions

View File

@ -69,12 +69,6 @@ class kde_applier_user(applier_frontend):
__module_enabled = False __module_enabled = False
__hkcu_branch = 'Software\\BaseALT\\Policies\\KDE\\' __hkcu_branch = 'Software\\BaseALT\\Policies\\KDE\\'
__hkcu_lock_branch = 'Software\\BaseALT\\Policies\\KDELocks\\' __hkcu_lock_branch = 'Software\\BaseALT\\Policies\\KDELocks\\'
widget_utilities = {
'colorscheme': 'plasma-apply-colorscheme',
'cursortheme': 'plasma-apply-cursortheme',
'desktoptheme': 'plasma-apply-desktoptheme',
'wallpaperimage': 'plasma-apply-wallpaperimage'
}
def __init__(self, storage, sid=None, username=None, file_cache = None): def __init__(self, storage, sid=None, username=None, file_cache = None):
self.storage = storage self.storage = storage
@ -133,6 +127,7 @@ def create_dict(kde_settings, all_kde_settings, locks_settings, locks_dict, file
log('W16', logdata) log('W16', logdata)
def apply(all_kde_settings, locks_dict, username = None): def apply(all_kde_settings, locks_dict, username = None):
logdata = dict()
if username is None: if username is None:
for file_name, sections in all_kde_settings.items(): for file_name, sections in all_kde_settings.items():
file_path = f'/etc/xdg/{file_name}' file_path = f'/etc/xdg/{file_name}'
@ -179,22 +174,24 @@ def apply(all_kde_settings, locks_dict, username = None):
subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except OSError as exc: except OSError as exc:
logdata['exc'] = exc logdata['exc'] = exc
log('W18', exc) log('W18', logdata)
except Exception as exc: except Exception as exc:
logdata = dict()
logdata['command'] = command logdata['command'] = command
log('E68', logdata) log('E68', logdata)
new_content = [] new_content = []
file_path = os.path.expanduser(f'{get_homedir(username)}/.config/{file_name}') file_path = f'{get_homedir(username)}/.config/{file_name}'
with open(file_path, 'r') as file: try:
for line in file: with open(file_path, 'r') as file:
line = line.replace('/$i/', '[$i]').replace(')(', '][') for line in file:
new_content.append(line) line = line.replace('/$i/', '[$i]').replace(')(', '][')
with open(file_path, 'w') as file: new_content.append(line)
file.writelines(new_content) with open(file_path, 'w') as file:
logdata = dict() file.writelines(new_content)
logdata['file'] = file_name logdata['file'] = file_name
log('D202', logdata) log('D202', logdata)
except Exception as exc:
logdata['exc'] = exc
log('W19', logdata)
def clear_locks_settings(username, file_name, key): def clear_locks_settings(username, file_name, key):
''' '''
@ -217,6 +214,7 @@ def apply_for_widget(value, data, file_cache):
''' '''
Method for changing graphics settings in plasma context Method for changing graphics settings in plasma context
''' '''
logdata = dict()
try: try:
if value in widget_utilities: if value in widget_utilities:
if value == 'wallpaperimage': if value == 'wallpaperimage':
@ -233,7 +231,6 @@ def apply_for_widget(value, data, file_cache):
command = [f"{widget_utilities[value]}", f"{data}"] command = [f"{widget_utilities[value]}", f"{data}"]
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout = proc.communicate() stdout = proc.communicate()
logdata = dict()
logdata['Conclusion'] = stdout logdata['Conclusion'] = stdout
if proc.returncode == 0: if proc.returncode == 0:
log('D203', logdata) log('D203', logdata)

View File

@ -886,14 +886,17 @@ msgstr "Не удалось создать допустимый список к
msgid "Failed to copy file" msgid "Failed to copy file"
msgstr "Не удалось скопировать файл" msgstr "Не удалось скопировать файл"
msgid "Failed to create settings list" msgid "Failed to create KDE settings list"
msgstr "Не удалось создать список настроек" msgstr "Не удалось создать список настроек KDE"
msgid "Could not find application tools" msgid "Could not find application tools"
msgstr "Не удалось найти инструменты применения" msgstr "Не удалось найти инструменты применения"
msgid "Failed to open settings" msgid "Failed to open KDE settings"
msgstr "Не удалось открыть настройки" msgstr "Не удалось открыть настройки KDE"
msgid "Failed to change KDE configuration file"
msgstr "Не удалось изменить файл конфигурации KDE"
# Fatal # Fatal
msgid "Unable to refresh GPO list" msgid "Unable to refresh GPO list"

View File

@ -335,9 +335,10 @@ def warning_code(code):
warning_ids[13] = 'Failed to caching the file' warning_ids[13] = 'Failed to caching the file'
warning_ids[14] = 'Could not create a valid list of keys' warning_ids[14] = 'Could not create a valid list of keys'
warning_ids[15] = 'Failed to copy file' warning_ids[15] = 'Failed to copy file'
warning_ids[16] = 'Failed to create settings list' warning_ids[16] = 'Failed to create KDE settings list'
warning_ids[17] = 'Could not find application tools' warning_ids[17] = 'Could not find application tools'
warning_ids[18] = 'Failed to open settings' warning_ids[18] = 'Failed to open KDE settings'
warning_ids[19] = 'Failed to change KDE configuration file'
return warning_ids.get(code, 'Unknown warning code') return warning_ids.get(code, 'Unknown warning code')