本文整理汇总了Python中samba.param.LoadParm.load方法的典型用法代码示例。如果您正苦于以下问题:Python LoadParm.load方法的具体用法?Python LoadParm.load怎么用?Python LoadParm.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类samba.param.LoadParm
的用法示例。
在下文中一共展示了LoadParm.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SambaOptions
# 需要导入模块: from samba.param import LoadParm [as 别名]
# 或者: from samba.param.LoadParm import load [as 别名]
class SambaOptions(optparse.OptionGroup):
"""General Samba-related command line options."""
def __init__(self, parser):
from samba.param import LoadParm
optparse.OptionGroup.__init__(self, parser, "Samba Common Options")
self.add_option("-s", "--configfile", action="callback",
type=str, metavar="FILE", help="Configuration file",
callback=self._load_configfile)
self.add_option("-d", "--debuglevel", action="callback",
type=int, metavar="DEBUGLEVEL", help="debug level",
callback=self._set_debuglevel)
self.add_option("--option", action="callback",
type=str, metavar="OPTION",
help="set smb.conf option from command line",
callback=self._set_option)
self.add_option("--realm", action="callback",
type=str, metavar="REALM", help="set the realm name",
callback=self._set_realm)
self._configfile = None
self._lp = LoadParm()
self.realm = None
def get_loadparm_path(self):
"""Return path to the smb.conf file specified on the command line."""
return self._configfile
def _load_configfile(self, option, opt_str, arg, parser):
self._configfile = arg
def _set_debuglevel(self, option, opt_str, arg, parser):
if arg < 0:
raise optparse.OptionValueError("invalid %s option value: %s" %
(opt_str, arg))
self._lp.set('debug level', str(arg))
def _set_realm(self, option, opt_str, arg, parser):
self._lp.set('realm', arg)
self.realm = arg
def _set_option(self, option, opt_str, arg, parser):
if arg.find('=') == -1:
raise optparse.OptionValueError(
"--option option takes a 'a=b' argument")
a = arg.split('=')
try:
self._lp.set(a[0], a[1])
except Exception as e:
raise optparse.OptionValueError(
"invalid --option option value %r: %s" % (arg, e))
def get_loadparm(self):
"""Return loadparm object with data specified on the command line."""
if self._configfile is not None:
self._lp.load(self._configfile)
elif os.getenv("SMB_CONF_PATH") is not None:
self._lp.load(os.getenv("SMB_CONF_PATH"))
else:
self._lp.load_default()
return self._lp
示例2: parametros
# 需要导入模块: from samba.param import LoadParm [as 别名]
# 或者: from samba.param.LoadParm import load [as 别名]
def parametros(fichero=False):
"""
Intento ser un poco cuidadoso con la forma en que obtenemos la configuración
"""
try:
lp = LoadParm()
lp.load_default() if fichero is False else lp.load(fichero)
return lp
except RuntimeError as e:
log.warning(e.message)
raise ConfiguracionException(e)
示例3: LoadParm
# 需要导入模块: from samba.param import LoadParm [as 别名]
# 或者: from samba.param.LoadParm import load [as 别名]
import ldb
from samba.ndr import ndr_pack, ndr_unpack
from samba.dcerpc import security
from samba.idmap import IDmapDB
from samba.auth import system_session
from samba.param import LoadParm
name='samba4-idmap'
description='Update local IDmap entries'
filter='(&(|(objectClass=sambaSamAccount)(objectClass=sambaGroupMapping))(sambaSID=*))'
attributes=['sambaSID', 'univentionSamba4SID', 'uidNumber', 'gidNumber']
modrdn='1'
### Globals
lp = LoadParm()
lp.load('/etc/samba/smb.conf')
sidAttribute='sambaSID'
if listener.configRegistry.is_false('connector/s4/mapping/sid', False):
sidAttribute='univentionSamba4SID'
def open_idmap():
global lp
listener.setuid(0)
try:
idmap = IDmapDB('/var/lib/samba/private/idmap.ldb', session_info=system_session(), lp=lp)
except ldb.LdbError:
univention.debug.debug(univention.debug.LISTENER, univention.debug.ERROR,
"%s: /var/lib/samba/private/idmap.ldb could not be opened" % name )
raise