1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

Added information reading for File_cp

This commit is contained in:
Valery Sinelnikov 2022-07-07 11:36:13 +04:00
parent baba56465c
commit cb720084fa
3 changed files with 49 additions and 4 deletions

View File

@ -18,13 +18,14 @@
from pathlib import Path
from .appliers.file_cp import Files_cp
from .applier_frontend import (
applier_frontend
, check_enabled
)
from util.logging import log
from util.windows import expand_windows_var
import re
class file_applier(applier_frontend):
__module_name = 'FilesApplier'
@ -38,6 +39,10 @@ class file_applier(applier_frontend):
self.files = self.storage.get_files(self.sid)
self.__module_enabled = check_enabled(self.storage, self.__module_name, self.__module_enabled)
def run(self):
dict_all_files = get_list_all_files(self.files, self.file_cache)
# def apply(self):
# if self.__module_enabled:
# log('#########D107#########')
@ -58,6 +63,7 @@ class file_applier_user(applier_frontend):
self.sid = sid
self.username = username
self.files = self.storage.get_files(self.sid)
self.ls_all_files = dict()
self.__module_enabled = check_enabled(
self.storage
, self.__module_name
@ -65,9 +71,7 @@ class file_applier_user(applier_frontend):
)
def run(self):
for file_obj in self.files:
check_from = expand_windows_var(file_obj.fromPath).replace('\\', '/')
check_target = expand_windows_var(file_obj.targetPath).replace('\\', '/')
ls_files_cp = get_list_all_files(self.files, self.file_cache, self.username)
# def admin_context_apply(self):
# if self.__module_enabled:
@ -82,3 +86,40 @@ class file_applier_user(applier_frontend):
# self.run()
# else:
# log('#############D112')
def get_list_all_files(files, file_cache, username = None):
ls_files_cp = list()
for file_obj in files:
fromPath = expand_windows_var(file_obj.fromPath).replace('\\', '/')
targetPath = expand_windows_var(file_obj.targetPath).replace('\\', '/')
dict_files_cp = dict()
dict_files_cp['targetPath'] = targetPath
dict_files_cp['action'] = file_obj.action
dict_files_cp['readOnly'] = file_obj.readOnly
dict_files_cp['archive'] = file_obj.archive
dict_files_cp['hidden'] = file_obj.hidden
dict_files_cp['suppress'] = file_obj.suppress
if fromPath[-1] != '*':
try:
file_cache.store(fromPath)
dict_files_cp['fromPath'] = file_cache.get(fromPath)
except Exception as exc:
logdata = dict({fromPath: str(exc)})
log('W13', logdata)
ls_files_cp.append(Files_cp(dict_files_cp))
else:
ls_files = file_cache.get_ls_smbdir(fromPath[:-1])
ls_from_paths = [fromPath[:-1] + file_s for file_s in ls_files]
for from_path in ls_from_paths:
try:
file_cache.store(from_path)
dict_files_cp['fromPath'] = file_cache.get(from_path)
except Exception as exc:
logdata = dict({from_path: str(exc)})
log('W13', logdata)
ls_files_cp.append(Files_cp(dict_files_cp))
return ls_files_cp
def cp_all_files(ls_files_cp):
ls_files_cp

View File

@ -736,6 +736,9 @@ msgstr "Неподдерживаемый тип сервера NTP"
msgid "Failed to read the list of files"
msgstr "Не удалось прочитать список файлов"
msgid "Failed to caching the file"
msgstr "Не удалось кэшировать файл"
# Fatal
msgid "Unable to refresh GPO list"
msgstr "Невозможно обновить список объектов групповых политик"

View File

@ -291,6 +291,7 @@ def warning_code(code):
warning_ids[10] = 'Unsupported NTP server type'
warning_ids[11] = 'Unable to refresh GPO list'
warning_ids[12] = 'Failed to read the list of files'
warning_ids[13] = 'Failed to caching the file'
return warning_ids.get(code, 'Unknown warning code')