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

Backend improved with numbered log messages

This commit is contained in:
Игорь Чудов 2020-07-23 19:49:15 +04:00
parent 955d15622f
commit 3e2e90be5b
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC
2 changed files with 14 additions and 6 deletions

View File

@ -21,6 +21,8 @@ import logging
from util.windows import smbcreds
from .samba_backend import samba_backend
from .nodomain_backend import nodomain_backend
from util.logging import slogm
from messages import message_with_code
def backend_factory(dc, username, is_machine, no_domain = False):
'''
@ -36,17 +38,20 @@ def backend_factory(dc, username, is_machine, no_domain = False):
domain = sc.get_domain()
if domain:
logging.debug('Initialize Samba backend for domain: {}'.format(domain))
ldata = dict({'domain': domain})
logging.debug(slogm(message_with_code('I4'), ldata))
try:
back = samba_backend(sc, username, domain, is_machine)
except Exception as exc:
logging.error('Unable to initialize Samba backend: {}'.format(exc))
logdata = dict({'error': str(exc)})
logging.error(slogm(message_with_code('E7'), logdata))
else:
logging.debug('Initialize local backend with no domain')
logging.debug(slogm(message_with_code('I5')))
try:
back = nodomain_backend()
except Exception as exc:
logging.error('Unable to initialize no-domain backend: {}'.format(exc))
logdata = dict({'error': str(exc)})
logging.error(slogm(message_with_code('E8'), logdata))
return back

View File

@ -31,6 +31,7 @@ from util.util import (
from util.windows import get_sid
import util.preg
from util.logging import slogm
from messages import message_with_code
class samba_backend(applier_backend):
@ -57,7 +58,8 @@ class samba_backend(applier_backend):
self.sambacreds = sambacreds
self.cache_dir = self.sambacreds.get_cache_dir()
logging.debug(slogm('Cache directory is: {}'.format(self.cache_dir)))
logdata = dict({'cachedir': self.cache_dir})
logging.debug(slogm(message_with_code('I6'), logdata))
def retrieve_and_store(self):
'''
@ -86,7 +88,8 @@ class samba_backend(applier_backend):
# GPO named "Local Policy" has no entry by its nature so
# no reason to print warning.
if 'Local Policy' != gpo.name:
logging.warning(slogm('No SYSVOL entry assigned to GPO {}'.format(gpo.name)))
logdata = dict({'gponame': gpo.name})
logging.warning(slogm(message_with_code('W4'), logdata))
return False
return True