mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-10-21 19:33:20 +03:00
Use util.paths in order to eliminate dependency on variable definitions
This commit is contained in:
@@ -32,7 +32,6 @@ import util.preg
|
|||||||
from util.logging import slogm
|
from util.logging import slogm
|
||||||
|
|
||||||
class samba_backend(applier_backend):
|
class samba_backend(applier_backend):
|
||||||
__default_policy_path = '/usr/share/local-policy/default'
|
|
||||||
|
|
||||||
def __init__(self, sambacreds, username, domain):
|
def __init__(self, sambacreds, username, domain):
|
||||||
self.storage = registry_factory('registry')
|
self.storage = registry_factory('registry')
|
||||||
|
@@ -31,15 +31,14 @@ from .envvars import read_envvars
|
|||||||
from .drives import read_drives
|
from .drives import read_drives
|
||||||
import util
|
import util
|
||||||
import util.preg
|
import util.preg
|
||||||
|
from util.paths import (
|
||||||
|
default_policy_path,
|
||||||
|
cache_dir,
|
||||||
|
local_policy_cache
|
||||||
|
)
|
||||||
from util.logging import slogm
|
from util.logging import slogm
|
||||||
|
|
||||||
global __default_policy_path
|
|
||||||
|
|
||||||
__default_policy_path = '/usr/share/local-policy/default'
|
|
||||||
__cache_dir = '/var/cache/gpupdate'
|
|
||||||
|
|
||||||
class gpt:
|
class gpt:
|
||||||
__default_policy_path = '/usr/share/local-policy/default'
|
|
||||||
__user_policy_mode_key = 'Software\\Policies\\Microsoft\\Windows\\System\\UserPolicyMode'
|
__user_policy_mode_key = 'Software\\Policies\\Microsoft\\Windows\\System\\UserPolicyMode'
|
||||||
|
|
||||||
def __init__(self, gpt_path, sid):
|
def __init__(self, gpt_path, sid):
|
||||||
@@ -127,7 +126,10 @@ class gpt:
|
|||||||
'''
|
'''
|
||||||
search_path = os.path.join(self._machine_path, 'Preferences', 'Shortcuts')
|
search_path = os.path.join(self._machine_path, 'Preferences', 'Shortcuts')
|
||||||
if 'user' == part:
|
if 'user' == part:
|
||||||
search_path = os.path.join(self._user_path, 'Preferences', 'Shortcuts')
|
try:
|
||||||
|
search_path = os.path.join(self._user_path, 'Preferences', 'Shortcuts')
|
||||||
|
except Exception as exc:
|
||||||
|
return None
|
||||||
if not search_path:
|
if not search_path:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -257,8 +259,7 @@ def lp2gpt():
|
|||||||
'''
|
'''
|
||||||
Convert local-policy to full-featured GPT.
|
Convert local-policy to full-featured GPT.
|
||||||
'''
|
'''
|
||||||
lppath = os.path.join(__default_policy_path, 'local.xml')
|
lppath = os.path.join(default_policy_path(), 'local.xml')
|
||||||
machinesettings = os.path.join(__default_policy_path, 'Machine')
|
|
||||||
|
|
||||||
# Load settings from XML PolFile
|
# Load settings from XML PolFile
|
||||||
polparser = GPPolParser()
|
polparser = GPPolParser()
|
||||||
@@ -266,7 +267,7 @@ def lp2gpt():
|
|||||||
polparser.pol_file = polfile
|
polparser.pol_file = polfile
|
||||||
|
|
||||||
# Create target default policy directory if missing
|
# Create target default policy directory if missing
|
||||||
destdir = os.path.join(__cache_dir, 'local-policy', 'Machine')
|
destdir = os.path.join(local_policy_cache(), 'Machine')
|
||||||
os.makedirs(destdir, exist_ok=True)
|
os.makedirs(destdir, exist_ok=True)
|
||||||
|
|
||||||
# Write PReg
|
# Write PReg
|
||||||
@@ -276,9 +277,9 @@ def get_local_gpt(sid):
|
|||||||
'''
|
'''
|
||||||
Convert default policy to GPT and create object out of it.
|
Convert default policy to GPT and create object out of it.
|
||||||
'''
|
'''
|
||||||
|
logging.debug(slogm('Re-caching Local Policy'))
|
||||||
lp2gpt()
|
lp2gpt()
|
||||||
gpt_dir = os.path.join(__cache_dir, 'local-policy')
|
local_policy = gpt(str(local_policy_cache()), sid)
|
||||||
local_policy = gpt(gpt_dir, sid)
|
|
||||||
local_policy.set_name('Local Policy')
|
local_policy.set_name('Local Policy')
|
||||||
|
|
||||||
return local_policy
|
return local_policy
|
||||||
|
@@ -34,6 +34,7 @@ from sqlalchemy.orm import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from util.logging import slogm
|
from util.logging import slogm
|
||||||
|
from util.paths import cache_dir
|
||||||
|
|
||||||
def mapping_factory(mapper_suffix):
|
def mapping_factory(mapper_suffix):
|
||||||
exec(
|
exec(
|
||||||
@@ -47,7 +48,7 @@ class mapped_id_{}(object):
|
|||||||
return eval('mapped_id_{}'.format(mapper_suffix))
|
return eval('mapped_id_{}'.format(mapper_suffix))
|
||||||
|
|
||||||
class sqlite_cache(cache):
|
class sqlite_cache(cache):
|
||||||
__cache_dir = 'sqlite:////var/cache/samba'
|
__cache_dir = 'sqlite:///{}'.format(cache_dir())
|
||||||
|
|
||||||
def __init__(self, cache_name):
|
def __init__(self, cache_name):
|
||||||
self.cache_name = cache_name
|
self.cache_name = cache_name
|
||||||
|
@@ -33,6 +33,7 @@ from sqlalchemy.orm import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from util.logging import slogm
|
from util.logging import slogm
|
||||||
|
from util.paths import cache_dir
|
||||||
from .registry import registry
|
from .registry import registry
|
||||||
|
|
||||||
class samba_preg(object):
|
class samba_preg(object):
|
||||||
@@ -78,7 +79,7 @@ class printer_entry(object):
|
|||||||
self.printer = pobj.to_json()
|
self.printer = pobj.to_json()
|
||||||
|
|
||||||
class sqlite_registry(registry):
|
class sqlite_registry(registry):
|
||||||
__registry_path = 'sqlite:////var/cache/samba'
|
__registry_path = 'sqlite:///{}'.format(cache_dir())
|
||||||
|
|
||||||
def __init__(self, db_name):
|
def __init__(self, db_name):
|
||||||
self.db_name = db_name
|
self.db_name = db_name
|
||||||
|
Reference in New Issue
Block a user