mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-10-22 11:33:10 +03:00
refactor: more constructor replacements with literals
This commit is contained in:
@@ -68,7 +68,7 @@ class samba_backend(applier_backend):
|
||||
self.gpo_cache_part ='gpo_cache'
|
||||
self._cached = False
|
||||
self.storage.set_info('cache_dir', os.path.join(self.cache_dir, self.gpo_cache_part))
|
||||
logdata = dict({'cachedir': self.cache_dir})
|
||||
logdata = {'cachedir': self.cache_dir}
|
||||
log('D7', logdata)
|
||||
|
||||
def __del__(self):
|
||||
@@ -98,7 +98,7 @@ class samba_backend(applier_backend):
|
||||
Retrieve settings and strore it in a database
|
||||
'''
|
||||
# Get policies for machine at first.
|
||||
machine_gpts = list()
|
||||
machine_gpts = []
|
||||
try:
|
||||
machine_gpts = self._get_gpts(get_machine_name(), self.storage.get_info('machine_sid'))
|
||||
except Exception as exc:
|
||||
@@ -110,14 +110,14 @@ class samba_backend(applier_backend):
|
||||
try:
|
||||
gptobj.merge_machine()
|
||||
except Exception as exc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['msg'] = str(exc)
|
||||
log('E26', logdata)
|
||||
|
||||
# Load user GPT values in case user's name specified
|
||||
# This is a buggy implementation and should be tested more
|
||||
else:
|
||||
user_gpts = list()
|
||||
user_gpts = []
|
||||
try:
|
||||
user_gpts = self._get_gpts(self.username, self.sid)
|
||||
except Exception as exc:
|
||||
@@ -127,7 +127,7 @@ class samba_backend(applier_backend):
|
||||
# Merge user settings if UserPolicyMode set accordingly
|
||||
# and user settings (for HKCU) are exist.
|
||||
policy_mode = self.get_policy_mode()
|
||||
logdata = dict({'mode': upm2str(policy_mode), 'sid': self.sid})
|
||||
logdata = {'mode': upm2str(policy_mode), 'sid': self.sid}
|
||||
log('D152', logdata)
|
||||
|
||||
if policy_mode < 2:
|
||||
@@ -135,7 +135,7 @@ class samba_backend(applier_backend):
|
||||
try:
|
||||
gptobj.merge_user()
|
||||
except Exception as exc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['msg'] = str(exc)
|
||||
log('E27', logdata)
|
||||
|
||||
@@ -145,7 +145,7 @@ class samba_backend(applier_backend):
|
||||
gptobj.sid = self.sid
|
||||
gptobj.merge_user()
|
||||
except Exception as exc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['msg'] = str(exc)
|
||||
log('E63', logdata)
|
||||
|
||||
@@ -162,13 +162,13 @@ class samba_backend(applier_backend):
|
||||
self._cached = True
|
||||
return True
|
||||
elif 'Local Policy' != gpo.name:
|
||||
logdata = dict({'gponame': gpo.name})
|
||||
logdata = {'gponame': gpo.name}
|
||||
log('W4', logdata)
|
||||
return False
|
||||
return True
|
||||
|
||||
def _get_gpts(self, username, sid):
|
||||
gpts = list()
|
||||
gpts = []
|
||||
|
||||
log('D45', {'username': username, 'sid': sid})
|
||||
# util.windows.smbcreds
|
||||
@@ -178,7 +178,7 @@ class samba_backend(applier_backend):
|
||||
if self._check_sysvol_present(gpo):
|
||||
if not self._cached:
|
||||
path = check_safe_path(gpo.file_sys_path).upper()
|
||||
slogdata = dict({'sysvol_path': gpo.file_sys_path, 'gpo_name': gpo.display_name, 'gpo_path': path})
|
||||
slogdata = {'sysvol_path': gpo.file_sys_path, 'gpo_name': gpo.display_name, 'gpo_path': path}
|
||||
log('D30', slogdata)
|
||||
gpt_abspath = os.path.join(self.cache_dir, self.gpo_cache_part, path)
|
||||
else:
|
||||
|
@@ -24,7 +24,7 @@ def control_subst(preg_name):
|
||||
This is a workaround for control names which can't be used in
|
||||
PReg/ADMX files.
|
||||
'''
|
||||
control_triggers = dict()
|
||||
control_triggers = {}
|
||||
control_triggers['dvd_rw-format'] = 'dvd+rw-format'
|
||||
control_triggers['dvd_rw-mediainfo'] = 'dvd+rw-mediainfo'
|
||||
control_triggers['dvd_rw-booktype'] = 'dvd+rw-booktype'
|
||||
@@ -50,7 +50,7 @@ class control:
|
||||
Query possible values from control in order to perform check of
|
||||
parameter passed to constructor.
|
||||
'''
|
||||
values = list()
|
||||
values = []
|
||||
|
||||
popen_call = ['/usr/sbin/control', self.control_name, 'list']
|
||||
with subprocess.Popen(popen_call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:
|
||||
@@ -68,7 +68,7 @@ class control:
|
||||
try:
|
||||
str_status = self.possible_values[int_status]
|
||||
except IndexError as exc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['control'] = self.control_name
|
||||
logdata['value from'] = self.possible_values
|
||||
logdata['by index'] = int_status
|
||||
@@ -97,20 +97,20 @@ class control:
|
||||
if type(self.control_value) == int:
|
||||
status = self._map_control_status(self.control_value)
|
||||
if status == None:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['control'] = self.control_name
|
||||
logdata['inpossible values'] = self.control_value
|
||||
log('E42', logdata)
|
||||
return
|
||||
elif type(self.control_value) == str:
|
||||
if self.control_value not in self.possible_values:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['control'] = self.control_name
|
||||
logdata['inpossible values'] = self.control_value
|
||||
log('E59', logdata)
|
||||
return
|
||||
status = self.control_value
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['control'] = self.control_name
|
||||
logdata['status'] = status
|
||||
log('D68', logdata)
|
||||
@@ -120,7 +120,7 @@ class control:
|
||||
with subprocess.Popen(popen_call, stdout=subprocess.PIPE) as proc:
|
||||
proc.wait()
|
||||
except:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['control'] = self.control_name
|
||||
logdata['status'] = status
|
||||
log('E43', logdata)
|
||||
|
@@ -64,7 +64,7 @@ class Envvar:
|
||||
|
||||
def _create_action(self, create_dict, envvar_file):
|
||||
lines_old = envvar_file.readlines()
|
||||
lines_new = list()
|
||||
lines_new = []
|
||||
for name in create_dict:
|
||||
exist = False
|
||||
for line in lines_old:
|
||||
@@ -93,7 +93,7 @@ class Envvar:
|
||||
with open(self.envvar_file_path, 'r') as f:
|
||||
lines = f.readlines()
|
||||
else:
|
||||
lines = list()
|
||||
lines = []
|
||||
|
||||
file_changed = False
|
||||
for envvar_object in self.envvars:
|
||||
|
@@ -49,7 +49,7 @@ class Files_cp:
|
||||
self.suppress = str2bool(file_obj.suppress)
|
||||
self.executable = str2bool(file_obj.executable)
|
||||
self.username = username
|
||||
self.fromPathFiles = list()
|
||||
self.fromPathFiles = []
|
||||
if self.fromPath:
|
||||
if targetPath[-1] == '/' or self.is_pattern(Path(self.fromPath).name):
|
||||
self.isTargetPathDirectory = True
|
||||
@@ -254,8 +254,8 @@ class Execution_check():
|
||||
marker_usage_path_branch = '{}\\{}%'.format(self.__hklm_branch, self.__marker_usage_path_key_name)
|
||||
self.etension_marker = storage.filter_hklm_entries(etension_marker_branch)
|
||||
self.marker_usage_path = storage.filter_hklm_entries(marker_usage_path_branch)
|
||||
self.list_paths = list()
|
||||
self.list_markers = list()
|
||||
self.list_paths = []
|
||||
self.list_markers = []
|
||||
for marker in self.etension_marker:
|
||||
self.list_markers.append(marker.data)
|
||||
for usage_path in self.marker_usage_path:
|
||||
|
@@ -20,7 +20,7 @@ from enum import Enum
|
||||
import subprocess
|
||||
|
||||
def getprops(param_list):
|
||||
props = dict()
|
||||
props = {}
|
||||
|
||||
for entry in param_list:
|
||||
lentry = entry.lower()
|
||||
@@ -35,7 +35,7 @@ def getprops(param_list):
|
||||
|
||||
|
||||
def get_ports(param_list):
|
||||
portlist = list()
|
||||
portlist = []
|
||||
|
||||
for entry in param_list:
|
||||
lentry = entry.lower()
|
||||
|
@@ -53,8 +53,8 @@ class system_gsettings:
|
||||
__profile_data = 'user-db:user\nsystem-db:policy\nsystem-db:local\n'
|
||||
|
||||
def __init__(self, override_file_path):
|
||||
self.gsettings = list()
|
||||
self.locks = list()
|
||||
self.gsettings = []
|
||||
self.locks = []
|
||||
self.override_file_path = override_file_path
|
||||
|
||||
def append(self, schema, path, data, lock, helper):
|
||||
@@ -132,7 +132,7 @@ def check_existing_gsettings (schema, path):
|
||||
|
||||
class user_gsettings:
|
||||
def __init__(self):
|
||||
self.gsettings = list()
|
||||
self.gsettings = []
|
||||
|
||||
def append(self, schema, path, value, helper=None):
|
||||
if check_existing_gsettings(schema, path):
|
||||
|
@@ -54,7 +54,7 @@ class Ini_file:
|
||||
if self.path.is_dir():
|
||||
return
|
||||
if self.section not in self.config:
|
||||
self.config[self.section] = dict()
|
||||
self.config[self.section] = {}
|
||||
|
||||
self.config[self.section][self.key] = self.value
|
||||
self.config.write()
|
||||
@@ -85,7 +85,7 @@ class Ini_file:
|
||||
if self.action == FileAction.REPLACE:
|
||||
self._create_action()
|
||||
except Exception as exc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['action'] = self.action
|
||||
logdata['exc'] = exc
|
||||
log('W23', logdata)
|
||||
|
@@ -31,7 +31,7 @@ class Networkshare:
|
||||
def __init__(self, networkshare_obj, username = None):
|
||||
self.net_full_cmd = ['/usr/bin/net', 'usershare']
|
||||
self.net_cmd_check = ['/usr/bin/net', 'usershare', 'list']
|
||||
self.cmd = list()
|
||||
self.cmd = []
|
||||
self.name = networkshare_obj.name
|
||||
self.path = expand_windows_var(networkshare_obj.path, username).replace('\\', '/') if networkshare_obj.path else None
|
||||
|
||||
@@ -52,7 +52,7 @@ class Networkshare:
|
||||
return exc
|
||||
|
||||
def _run_net_full_cmd(self):
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
try:
|
||||
res = subprocess.check_output(self.net_full_cmd, stderr=subprocess.DEVNULL, encoding='utf-8')
|
||||
if res:
|
||||
|
@@ -57,12 +57,12 @@ class polkit:
|
||||
with open(self.outfile, 'w') as f:
|
||||
f.write(text)
|
||||
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['file'] = self.outfile
|
||||
logdata['arguments'] = self.args
|
||||
log('D77', logdata)
|
||||
except Exception as exc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['file'] = self.outfile
|
||||
logdata['arguments'] = self.args
|
||||
log('E44', logdata)
|
||||
|
@@ -31,7 +31,7 @@ def storage_get_printers(storage, sid):
|
||||
Query printers configuration from storage
|
||||
'''
|
||||
printer_objs = storage.get_printers(sid)
|
||||
printers = list()
|
||||
printers = []
|
||||
|
||||
for prnj in printer_objs:
|
||||
printers.append(prnj)
|
||||
@@ -80,8 +80,8 @@ class cups_applier(applier_frontend):
|
||||
try:
|
||||
self.cups_connection = cups.Connection()
|
||||
except Exception as exc:
|
||||
logdata = dict()
|
||||
logdata['exc', exc]
|
||||
logdata = {}
|
||||
logdata['exc'] = exc
|
||||
log('W20', logdata)
|
||||
self.printers = storage_get_printers(self.storage, self.storage.get_info('machine_sid'))
|
||||
|
||||
|
@@ -47,10 +47,10 @@ class firefox_applier(applier_frontend):
|
||||
self.sid = sid
|
||||
self.username = username
|
||||
self._is_machine_name = is_machine_name(self.username)
|
||||
self.policies = dict()
|
||||
self.policies_json = dict({ 'policies': self.policies })
|
||||
self.policies = {}
|
||||
self.policies_json = {'policies': self.policies}
|
||||
self.firefox_keys = self.storage.filter_hklm_entries(self.__registry_branch)
|
||||
self.policies_gen = dict()
|
||||
self.policies_gen = {}
|
||||
self.__module_enabled = check_enabled(
|
||||
self.storage
|
||||
, self.__module_name
|
||||
@@ -112,13 +112,13 @@ def clean_data_firefox(data):
|
||||
|
||||
|
||||
|
||||
def create_dict(firefox_keys, registry_branch, excp=list()):
|
||||
def create_dict(firefox_keys, registry_branch, excp=[]):
|
||||
'''
|
||||
Collect dictionaries from registry keys into a general dictionary
|
||||
'''
|
||||
get_boolean = lambda data: data in ['1', 'true', 'True', True, 1] if isinstance(data, (str, int)) else False
|
||||
get_parts = lambda hivekey, registry: hivekey.replace(registry, '').split('/')
|
||||
counts = dict()
|
||||
counts = {}
|
||||
for it_data in firefox_keys:
|
||||
branch = counts
|
||||
try:
|
||||
@@ -153,7 +153,7 @@ def create_dict(firefox_keys, registry_branch, excp=list()):
|
||||
for part in parts[:-1]:
|
||||
branch = branch.setdefault(part, {})
|
||||
if branch.get(parts[-1]) is None:
|
||||
branch[parts[-1]] = list()
|
||||
branch[parts[-1]] = []
|
||||
if it_data.type == 4:
|
||||
branch[parts[-1]].append(get_boolean(it_data.data))
|
||||
else:
|
||||
|
@@ -53,7 +53,7 @@ class polkit_applier(applier_frontend):
|
||||
template_vars_all = self.__polkit_map[self.__registry_branch][1]
|
||||
template_file_all_lock = self.__polkit_map[self.__registry_locks_branch][0]
|
||||
template_vars_all_lock = self.__polkit_map[self.__registry_locks_branch][1]
|
||||
locks = list()
|
||||
locks = []
|
||||
for lock in self.polkit_locks:
|
||||
if bool(int(lock.data)):
|
||||
locks.append(lock.valuename)
|
||||
@@ -77,7 +77,7 @@ class polkit_applier(applier_frontend):
|
||||
self.__polkit_map[self.__registry_locks_branch][1][key] = item[1]
|
||||
|
||||
if deny_all_win:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['Deny_All_win'] = deny_all_win.data
|
||||
log('D69', logdata)
|
||||
self.__polkit_map[self.__deny_all_win][1]['Deny_All'] = deny_all_win.data
|
||||
@@ -146,7 +146,7 @@ class polkit_applier_user(applier_frontend):
|
||||
self.__polkit_map[self.__registry_branch][1][key] = item
|
||||
|
||||
if deny_all_win:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['user'] = self.username
|
||||
logdata['Deny_All_win'] = deny_all_win.data
|
||||
log('D70', logdata)
|
||||
|
@@ -41,7 +41,7 @@ class yandex_browser_applier(applier_frontend):
|
||||
self._is_machine_name = is_machine_name(self.username)
|
||||
self.yandex_keys = self.storage.filter_hklm_entries(self.__registry_branch)
|
||||
|
||||
self.policies_json = dict()
|
||||
self.policies_json = {}
|
||||
|
||||
self.__module_enabled = check_enabled(
|
||||
self.storage
|
||||
@@ -159,7 +159,7 @@ class yandex_browser_applier(applier_frontend):
|
||||
'''
|
||||
Collect dictionaries from registry keys into a general dictionary
|
||||
'''
|
||||
counts = dict()
|
||||
counts = {}
|
||||
#getting the list of keys to read as an integer
|
||||
valuename_typeint = self.get_valuename_typeint()
|
||||
for it_data in yandex_keys:
|
||||
|
@@ -21,7 +21,7 @@ from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
|
||||
def read_envvars(envvars_file):
|
||||
variables = list()
|
||||
variables = []
|
||||
|
||||
for var in get_xml_root(envvars_file):
|
||||
props = var.find('Properties')
|
||||
|
@@ -20,7 +20,7 @@ from util.xml import get_xml_root
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
def read_files(filesxml):
|
||||
files = list()
|
||||
files = []
|
||||
|
||||
for fil in get_xml_root(filesxml):
|
||||
props = fil.find('Properties')
|
||||
|
@@ -40,7 +40,7 @@ def folder_int2bool(val):
|
||||
|
||||
|
||||
def read_folders(folders_file):
|
||||
folders = list()
|
||||
folders = []
|
||||
|
||||
for fld in get_xml_root(folders_file):
|
||||
props = fld.find('Properties')
|
||||
|
@@ -110,7 +110,7 @@ def get_preftype(path_to_file):
|
||||
return None
|
||||
|
||||
def pref_parsers():
|
||||
parsers = dict()
|
||||
parsers = {}
|
||||
|
||||
parsers[FileType.PREG] = read_polfile
|
||||
parsers[FileType.SHORTCUTS] = read_shortcuts
|
||||
@@ -132,7 +132,7 @@ def get_parser(preference_type):
|
||||
return parsers[preference_type]
|
||||
|
||||
def pref_mergers():
|
||||
mergers = dict()
|
||||
mergers = {}
|
||||
|
||||
mergers[FileType.PREG] = merge_polfile
|
||||
mergers[FileType.SHORTCUTS] = merge_shortcuts
|
||||
|
@@ -20,7 +20,7 @@ from util.xml import get_xml_root
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
def read_inifiles(inifiles_file):
|
||||
inifiles = list()
|
||||
inifiles = []
|
||||
|
||||
for ini in get_xml_root(inifiles_file):
|
||||
prors = ini.find('Properties')
|
||||
|
@@ -20,7 +20,7 @@ from util.xml import get_xml_root
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
def read_networkshares(networksharesxml):
|
||||
networkshares = list()
|
||||
networkshares = []
|
||||
|
||||
for share in get_xml_root(networksharesxml):
|
||||
props = share.find('Properties')
|
||||
|
@@ -25,7 +25,7 @@ def read_printers(printers_file):
|
||||
'''
|
||||
Read printer configurations from Printer.xml
|
||||
'''
|
||||
printers = list()
|
||||
printers = []
|
||||
|
||||
for prn in get_xml_root(printers_file):
|
||||
prn_obj = printer(prn.tag, prn.get('name'), prn.get('status'))
|
||||
@@ -101,7 +101,7 @@ class printer(DynamicAttributes):
|
||||
'''
|
||||
Return string-serialized JSON representation of the object.
|
||||
'''
|
||||
printer = dict()
|
||||
printer = {}
|
||||
printer['type'] = self.printer_type
|
||||
printer['name'] = self.name
|
||||
printer['status'] = self.status
|
||||
@@ -113,7 +113,7 @@ class printer(DynamicAttributes):
|
||||
|
||||
# Nesting JSON object into JSON object makes it easier to add
|
||||
# metadata if needed.
|
||||
config = dict()
|
||||
config = {}
|
||||
config['printer'] = printer
|
||||
|
||||
return json.dumps(config)
|
||||
|
@@ -23,7 +23,7 @@ def read_services(service_file):
|
||||
'''
|
||||
Read Services.xml from GPT.
|
||||
'''
|
||||
services = list()
|
||||
services = []
|
||||
|
||||
for srv in get_xml_root(service_file):
|
||||
srv_obj = service(srv.get('name'))
|
||||
|
@@ -69,7 +69,7 @@ def read_shortcuts(shortcuts_file):
|
||||
|
||||
:shortcuts_file: Location of Shortcuts.xml
|
||||
'''
|
||||
shortcuts = list()
|
||||
shortcuts = []
|
||||
|
||||
for link in get_xml_root(shortcuts_file):
|
||||
props = link.find('Properties')
|
||||
|
@@ -1106,7 +1106,5 @@ msgstr "Не удалось получить GPT для пользователя
|
||||
msgid "Unknown fatal code"
|
||||
msgstr "Неизвестный код фатальной ошибки"
|
||||
|
||||
# get_message
|
||||
msgid "Unknown message type, no message assigned"
|
||||
msgstr "Неизвестный тип сообщения"
|
||||
|
||||
|
||||
|
@@ -20,7 +20,7 @@
|
||||
import gettext
|
||||
|
||||
def info_code(code):
|
||||
info_ids = dict()
|
||||
info_ids = {}
|
||||
info_ids[1] = 'Got GPO list for username'
|
||||
info_ids[2] = 'Got GPO'
|
||||
info_ids[3] = 'Working with control'
|
||||
@@ -36,7 +36,7 @@ def info_code(code):
|
||||
return info_ids.get(code, 'Unknown info code')
|
||||
|
||||
def error_code(code):
|
||||
error_ids = dict()
|
||||
error_ids = {}
|
||||
error_ids[1] = 'Insufficient permissions to run gpupdate'
|
||||
error_ids[2] = 'gpupdate will not be started'
|
||||
error_ids[3] = 'Backend execution error'
|
||||
@@ -115,7 +115,7 @@ def error_code(code):
|
||||
return error_ids.get(code, 'Unknown error code')
|
||||
|
||||
def debug_code(code):
|
||||
debug_ids = dict()
|
||||
debug_ids = {}
|
||||
debug_ids[1] = 'The GPOA process was started for user'
|
||||
debug_ids[2] = 'Username is not specified - will use username of the current process'
|
||||
debug_ids[3] = 'Initializing plugin manager'
|
||||
@@ -353,7 +353,7 @@ def debug_code(code):
|
||||
return debug_ids.get(code, 'Unknown debug code')
|
||||
|
||||
def warning_code(code):
|
||||
warning_ids = dict()
|
||||
warning_ids = {}
|
||||
warning_ids[1] = (
|
||||
'Unable to perform gpupdate for non-existent user, '
|
||||
'will update machine settings'
|
||||
@@ -406,7 +406,7 @@ def warning_code(code):
|
||||
return warning_ids.get(code, 'Unknown warning code')
|
||||
|
||||
def fatal_code(code):
|
||||
fatal_ids = dict()
|
||||
fatal_ids = {}
|
||||
fatal_ids[1] = 'Unable to refresh GPO list'
|
||||
fatal_ids[2] = 'Error getting GPTs for machine'
|
||||
fatal_ids[3] = 'Error getting GPTs for user'
|
||||
|
@@ -27,7 +27,7 @@ from messages import message_with_code
|
||||
|
||||
class plugin_manager:
|
||||
def __init__(self):
|
||||
self.plugins = dict()
|
||||
self.plugins = {}
|
||||
logging.debug(slogm(message_with_code('D3')))
|
||||
try:
|
||||
self.plugins['adp'] = adp()
|
||||
|
@@ -68,7 +68,7 @@ def process_target(target_name=None):
|
||||
if target_name:
|
||||
target = target_name
|
||||
|
||||
logdata = dict({'target': target})
|
||||
logdata = {'target': target}
|
||||
log('D10', logdata)
|
||||
|
||||
return target.upper()
|
||||
|
@@ -71,7 +71,7 @@ class dbus_runner:
|
||||
|
||||
def run(self):
|
||||
if self.username:
|
||||
logdata = dict({'username': self.username})
|
||||
logdata = {'username': self.username}
|
||||
log('D6', logdata)
|
||||
gpupdate = 'gpupdate' if not Dconf_registry._force else 'gpupdate_force'
|
||||
if is_root():
|
||||
@@ -88,8 +88,7 @@ class dbus_runner:
|
||||
timeout=self._synchronous_timeout)
|
||||
print_dbus_result(result)
|
||||
except dbus.exceptions.DBusException as exc:
|
||||
logdata = dict()
|
||||
logdata['username'] = self.username
|
||||
logdata = {'username': self.username}
|
||||
log('E23', logdata)
|
||||
raise exc
|
||||
else:
|
||||
@@ -103,7 +102,7 @@ class dbus_runner:
|
||||
timeout=self._synchronous_timeout)
|
||||
print_dbus_result(result)
|
||||
except dbus.exceptions.DBusException as exc:
|
||||
logdata = dict({'error': str(exc)})
|
||||
logdata = {'error': str(exc)}
|
||||
log('E21', logdata)
|
||||
raise exc
|
||||
else:
|
||||
@@ -121,7 +120,7 @@ class dbus_runner:
|
||||
timeout=self._synchronous_timeout)
|
||||
print_dbus_result(result)
|
||||
except dbus.exceptions.DBusException as exc:
|
||||
logdata = dict({'error': str(exc)})
|
||||
logdata = {'error': str(exc)}
|
||||
log('E22', logdata)
|
||||
raise exc
|
||||
|
||||
@@ -194,7 +193,7 @@ def print_dbus_result(result):
|
||||
'''
|
||||
exitcode = result[0]
|
||||
message = result[1:]
|
||||
logdata = dict({'retcode': exitcode})
|
||||
logdata = {'retcode': exitcode}
|
||||
log('D12', logdata)
|
||||
|
||||
for line in message:
|
||||
@@ -208,7 +207,7 @@ class dbus_session:
|
||||
self.session_dbus = self.session_bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
|
||||
self.session_iface = dbus.Interface(self.session_dbus, 'org.freedesktop.DBus')
|
||||
except dbus.exceptions.DBusException as exc:
|
||||
logdata = dict({'error': str(exc)})
|
||||
logdata = {'error': str(exc)}
|
||||
log('E31', logdata)
|
||||
raise exc
|
||||
|
||||
@@ -219,7 +218,7 @@ class dbus_session:
|
||||
log('D57', {"pid": pid})
|
||||
except dbus.exceptions.DBusException as exc:
|
||||
if exc.get_dbus_name() != 'org.freedesktop.DBus.Error.NameHasNoOwner':
|
||||
logdata = dict({'error': str(exc)})
|
||||
logdata = {'error': str(exc)}
|
||||
log('E32', logdata)
|
||||
raise exc
|
||||
log('D58', {'connection': connection})
|
||||
|
@@ -27,13 +27,13 @@ def geterr():
|
||||
'''
|
||||
etype, evalue, etrace = sys.exc_info()
|
||||
|
||||
traceinfo = dict({
|
||||
traceinfo = {
|
||||
'file': etrace.tb_frame.f_code.co_filename
|
||||
, 'line': etrace.tb_lineno
|
||||
, 'name': etrace.tb_frame.f_code.co_name
|
||||
, 'type': etype.__name__
|
||||
, 'message': evalue
|
||||
})
|
||||
}
|
||||
|
||||
del(etype, evalue, etrace)
|
||||
|
||||
|
@@ -80,11 +80,11 @@ def check_krb_ticket():
|
||||
subprocess.check_call(['klist', '-s'])
|
||||
output = subprocess.check_output('klist', stderr=subprocess.STDOUT).decode()
|
||||
result = True
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['output'] = output
|
||||
log('D17', logdata)
|
||||
except Exception as exc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['krb-exc'] = exc
|
||||
log('E14', logdata)
|
||||
|
||||
|
@@ -40,15 +40,13 @@ class slogm(object):
|
||||
'''
|
||||
Structured log message class
|
||||
'''
|
||||
def __init__(self, message, kwargs=dict()):
|
||||
def __init__(self, message, kwargs={}):
|
||||
self.message = message
|
||||
self.kwargs = kwargs
|
||||
if not self.kwargs:
|
||||
self.kwargs = dict()
|
||||
self.kwargs = {}
|
||||
|
||||
def __str__(self):
|
||||
now = str(datetime.datetime.now().isoformat(sep=' ', timespec='milliseconds'))
|
||||
args = dict()
|
||||
args = {}
|
||||
args.update(self.kwargs)
|
||||
result = '{}|{}|{}'.format(now, self.message, args)
|
||||
|
||||
|
@@ -39,7 +39,7 @@ def load_xml_preg(xml_path):
|
||||
'''
|
||||
Parse XML/PReg file and return its preg object
|
||||
'''
|
||||
logdata = dict({'polfile': xml_path})
|
||||
logdata = {'polfile': xml_path}
|
||||
log('D36', logdata)
|
||||
gpparser = GPPolParser()
|
||||
xml_root = ElementTree.parse(xml_path).getroot()
|
||||
@@ -53,14 +53,14 @@ def load_pol_preg(polfile):
|
||||
'''
|
||||
Parse PReg file and return its preg object
|
||||
'''
|
||||
logdata = dict({'polfile': polfile})
|
||||
logdata = {'polfile': polfile}
|
||||
log('D31', logdata)
|
||||
gpparser = GPPolParser()
|
||||
data = None
|
||||
|
||||
with open(polfile, 'rb') as f:
|
||||
data = f.read()
|
||||
logdata = dict({'polfile': polfile, 'length': len(data)})
|
||||
logdata = {'polfile': polfile, 'length': len(data)}
|
||||
log('D33', logdata)
|
||||
gpparser.parse(data)
|
||||
|
||||
@@ -71,7 +71,7 @@ def load_pol_preg(polfile):
|
||||
|
||||
def preg_keymap(preg):
|
||||
pregfile = load_preg(preg)
|
||||
keymap = dict()
|
||||
keymap = {}
|
||||
|
||||
for entry in pregfile.entries:
|
||||
hive_key = '{}\\{}'.format(entry.keyname, entry.valuename)
|
||||
@@ -86,7 +86,7 @@ def merge_polfile(preg, sid=None, reg_name='registry', reg_path=None, policy_nam
|
||||
load_preg_dconf(pregfile, preg, policy_name, None, gpo_info)
|
||||
else:
|
||||
load_preg_dconf(pregfile, preg, policy_name, username, gpo_info)
|
||||
logdata = dict({'pregfile': preg})
|
||||
logdata = {'pregfile': preg}
|
||||
log('D32', logdata)
|
||||
|
||||
|
||||
@@ -97,16 +97,12 @@ class entry:
|
||||
self.valuename = e_valuename
|
||||
self.type = e_type
|
||||
self.data = e_data
|
||||
logdata = dict()
|
||||
logdata['keyname'] = self.keyname
|
||||
logdata['valuename'] = self.valuename
|
||||
logdata['type'] = self.type
|
||||
logdata['data'] = self.data
|
||||
logdata = {'keyname': self.keyname, 'valuename': self.valuename, 'type': self.type, 'data': self.data}
|
||||
log('D22', logdata)
|
||||
|
||||
class pentries:
|
||||
def __init__(self):
|
||||
self.entries = list()
|
||||
self.entries = []
|
||||
|
||||
|
||||
def preg2entries(preg_obj):
|
||||
|
@@ -65,10 +65,10 @@ def get_sid(domain, username, is_machine = False):
|
||||
try:
|
||||
sid = wbinfo_getsid(domain, username)
|
||||
except:
|
||||
logdata = dict({'sid': sid})
|
||||
logdata = {'sid': sid}
|
||||
log('E16', logdata)
|
||||
|
||||
logdata = dict({'sid': sid})
|
||||
logdata = {'sid': sid}
|
||||
log('D21', logdata)
|
||||
|
||||
return sid
|
||||
@@ -203,7 +203,7 @@ def is_sid(sid):
|
||||
pass
|
||||
|
||||
def sid2descr(sid):
|
||||
sids = dict()
|
||||
sids = {}
|
||||
sids['S-1-0'] = 'Null Authority'
|
||||
sids['S-1-0-0'] = 'Nobody'
|
||||
sids['S-1-1'] = 'World Authority'
|
||||
|
@@ -55,7 +55,7 @@ def set_privileges(username, uid, gid, groups, home):
|
||||
|
||||
os.chdir(home)
|
||||
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['uid'] = uid
|
||||
logdata['gid'] = gid
|
||||
logdata['username'] = username
|
||||
@@ -123,12 +123,12 @@ def with_privileges(username, func):
|
||||
pass
|
||||
|
||||
except Exception as exc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['msg'] = str(exc)
|
||||
log('E33', logdata)
|
||||
result = 1;
|
||||
finally:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['dbus_pid'] = dbus_pid
|
||||
logdata['dconf_pid'] = dconf_pid
|
||||
log('D56', logdata)
|
||||
|
@@ -76,7 +76,7 @@ class smbcreds (smbopts):
|
||||
|
||||
try:
|
||||
if dc_fqdn is not None:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['user_dc'] = dc_fqdn
|
||||
log('D38', logdata)
|
||||
|
||||
@@ -84,7 +84,7 @@ class smbcreds (smbopts):
|
||||
else:
|
||||
self.selected_dc = get_dc_hostname(self.creds, self.lp)
|
||||
except Exception as exc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['msg'] = str(exc)
|
||||
log('E10', logdata)
|
||||
raise exc
|
||||
@@ -99,7 +99,7 @@ class smbcreds (smbopts):
|
||||
# Look and python/samba/netcmd/domain.py for more examples
|
||||
res = netcmd_get_domain_infos_via_cldap(self.lp, None, self.selected_dc)
|
||||
dns_domainname = res.dns_domain
|
||||
logdata = dict({'domain': dns_domainname})
|
||||
logdata = {'domain': dns_domainname}
|
||||
log('D18', logdata)
|
||||
except Exception as exc:
|
||||
log('E15')
|
||||
@@ -112,7 +112,7 @@ class smbcreds (smbopts):
|
||||
Get GPO list for the specified username for the specified DC
|
||||
hostname
|
||||
'''
|
||||
gpos = list()
|
||||
gpos = []
|
||||
if Dconf_registry.get_info('machine_name') == username:
|
||||
dconf_dict = Dconf_registry.get_dictionary_from_dconf_file_db(save_dconf_db=True)
|
||||
else:
|
||||
@@ -124,7 +124,7 @@ class smbcreds (smbopts):
|
||||
if ads.connect():
|
||||
log('D47')
|
||||
gpos = ads.get_gpo_list(username)
|
||||
logdata = dict({'username': username})
|
||||
logdata = {'username': username}
|
||||
log('I1', logdata)
|
||||
for gpo in gpos:
|
||||
# These setters are taken from libgpo/pygpo.c
|
||||
@@ -132,16 +132,16 @@ class smbcreds (smbopts):
|
||||
if gpo.display_name in dict_gpo_name_version.keys() and dict_gpo_name_version.get(gpo.display_name, {}).get('version') == str(getattr(gpo, 'version', None)):
|
||||
if Path(dict_gpo_name_version.get(gpo.display_name, {}).get('correct_path')).exists():
|
||||
gpo.file_sys_path = ''
|
||||
ldata = dict({'gpo_name': gpo.display_name, 'gpo_uuid': gpo.name, 'file_sys_path_cache': True})
|
||||
ldata = {'gpo_name': gpo.display_name, 'gpo_uuid': gpo.name, 'file_sys_path_cache': True}
|
||||
log('I11', ldata)
|
||||
continue
|
||||
ldata = dict({'gpo_name': gpo.display_name, 'gpo_uuid': gpo.name, 'file_sys_path': gpo.file_sys_path})
|
||||
ldata = {'gpo_name': gpo.display_name, 'gpo_uuid': gpo.name, 'file_sys_path': gpo.file_sys_path}
|
||||
log('I2', ldata)
|
||||
|
||||
except Exception as exc:
|
||||
if self.selected_dc != self.pdc_emulator_server:
|
||||
raise GetGPOListFail(exc)
|
||||
logdata = dict({'username': username, 'dc': self.selected_dc, 'exc': exc})
|
||||
logdata = {'username': username, 'dc': self.selected_dc, 'exc': exc}
|
||||
log('E17', logdata)
|
||||
|
||||
return gpos
|
||||
@@ -166,7 +166,7 @@ class smbcreds (smbopts):
|
||||
gpos = self.get_gpos(username)
|
||||
|
||||
while list_selected_dc:
|
||||
logdata = dict()
|
||||
logdata = {}
|
||||
logdata['username'] = username
|
||||
logdata['dc'] = self.selected_dc
|
||||
try:
|
||||
@@ -311,7 +311,7 @@ def expand_windows_var(text, username=None):
|
||||
'''
|
||||
Scan the line for percent-encoded variables and expand them.
|
||||
'''
|
||||
variables = dict()
|
||||
variables = {}
|
||||
variables['HOME'] = '/etc/skel'
|
||||
variables['HOMEPATH'] = '/etc/skel'
|
||||
variables['HOMEDRIVE'] = '/'
|
||||
|
@@ -27,8 +27,7 @@ def xdg_get_desktop(username, homedir = None):
|
||||
homedir = get_homedir(username)
|
||||
if not homedir:
|
||||
msgtext = message_with_code('E18')
|
||||
logdata = dict()
|
||||
logdata['username'] = username
|
||||
logdata = {}
|
||||
log('E18', logdata)
|
||||
raise Exception(msgtext)
|
||||
|
||||
|
Reference in New Issue
Block a user