mirror of
https://github.com/samba-team/samba.git
synced 2025-07-25 00:59:11 +03:00
python: Add convenience function for getting command line loadparm context
and default to using system smb.conf.
(This used to be commit b3afde0f00
)
This commit is contained in:
@ -23,9 +23,25 @@ from credentials import Credentials
|
||||
class SambaOptions(optparse.OptionGroup):
|
||||
def __init__(self, parser):
|
||||
optparse.OptionGroup.__init__(self, parser, "Samba Common Options")
|
||||
self.add_option("-s", "--configfile", type="string", metavar="FILE",
|
||||
help="Configuration file")
|
||||
self.add_option("-s", "--configfile", action="callback",
|
||||
type=str, metavar="FILE", help="Configuration file",
|
||||
callback=self._load_configfile)
|
||||
self._configfile = None
|
||||
|
||||
def get_loadparm_path(self):
|
||||
return self._configfile
|
||||
|
||||
def _load_configfile(self, option, opt_str, arg, parser):
|
||||
self._configfile = arg
|
||||
|
||||
def get_loadparm(self):
|
||||
import param
|
||||
lp = param.LoadParm()
|
||||
if self._configfile is None:
|
||||
lp.load_default()
|
||||
else:
|
||||
lp.load(self._configfile)
|
||||
return lp
|
||||
|
||||
class VersionOptions(optparse.OptionGroup):
|
||||
def __init__(self, parser):
|
||||
|
Reference in New Issue
Block a user