summaryrefslogtreecommitdiffstats
path: root/source4/scripting/python/samba/getopt.py
Commit message (Expand)AuthorAgeFilesLines
* s4:scripting/python: add '-V' as alias for '--version'Stefan Metzmacher2012-10-081-1/+1
* s4-python: Remove env from non-executable samba scripts.Andreas Schneider2012-03-131-2/+0
* samba.getopt: Keep exception message when setting a lp option fails.Jelmer Vernooij2011-10-191-4/+5
* samba-tool: Improve getopt.py error handlingGiampaolo Lauria2011-10-191-4/+5
* samba-tool: Improve getopt.py error handlingGiampaolo Lauria2011-10-191-1/+5
* samba-tool: Improve getopt.py error handlingGiampaolo Lauria2011-10-191-2/+1
* samba-tool: Improve getopt.py error handlingGiampaolo Lauria2011-10-191-0/+3
* samba.getopt: Refactor parsing of --kerberos argument into separate function.Jelmer Vernooij2011-10-131-13/+16
* samba.getopt: Allow --kerberos=auto, and fix exception name if an unknownJelmer Vernooij2011-10-121-1/+4
* s4-s3-upgrade Improve samba-tool domain samba3upgrade behaviourAndrew Bartlett2011-09-131-0/+2
* s4-python: Fix some formatting issues.Jelmer Vernooij2011-09-131-8/+15
* samba-tools: more reasonable defaults for samba-tool commandsAndrew Tridgell2010-12-081-1/+10
* samba.getopt: Fix missing import of sys.Jelmer Vernooij2010-11-281-8/+14
* s4-samba-tool: fixed "-k no" for disabling kerberos authAndrew Tridgell2010-11-281-2/+4
* s4-getopt.py: Make Anonymous creds when no credentialsKamen Mazdrashki2010-10-031-2/+7
* s4-net: added --ipaddress option to net commandsAndrew Tridgell2010-09-251-0/+7
* s4-python: python is not always in /usr/binAndrew Tridgell2010-06-241-1/+1
* s4-python: added --realm option to python scriptsAndrew Tridgell2010-04-211-1/+7
* s4-python: accept --option arguments in python cmdline parsingAndrew Tridgell2010-04-211-10/+17
* Support --version in python scripts.Jelmer Vernooij2010-04-091-0/+8
* s4-python: rename samba.glue to samba._glue to indicate it's private.Jelmer Vernooij2010-04-081-2/+2
* s4-python: added --debuglevel to our python scriptsAndrew Tridgell2010-04-021-0/+10
* s4:getopt.py - set the password callback only when no password has been providedMatthias Dieter Wallnöfer2010-02-121-4/+6
* Comparison tool for LDAP servers (using Ldb)Zahari Zahariev2010-01-131-0/+52
* Use CommandError exception to deal with problems during net commands.Jelmer Vernooij2009-12-291-7/+7
* Remove unnecessary imports.Jelmer Vernooij2009-07-191-1/+1
* Add helper object Hostconfig to make it easier to get to e.g. theJelmer Vernooij2008-08-011-0/+4
* Add docstrings to samba3 and getopt modules.Jelmer Vernooij2008-05-231-0/+15
* Also look in the environment for smb.conf path.Jelmer Vernooij2008-04-141-4/+6
* Fix and test python scripts and kerberosAndrew Bartlett2008-03-281-3/+12
* python: Support --no-pass.Jelmer Vernooij2008-01-241-0/+6
* python: Add convenience function for getting command line loadparm contextJelmer Vernooij2008-01-231-2/+18
* r26629: python: Improve documentation in various places.Jelmer Vernooij2007-12-291-8/+8
* r26628: python: Add more documentation, simplify code in Samba3 module.Jelmer Vernooij2007-12-291-1/+1
* r26618: Implement -W option support.Jelmer Vernooij2007-12-281-1/+7
* r26616: Support parsing of user data in SAmba 3 tdbsam.Jelmer Vernooij2007-12-271-1/+1
* r26614: Fix options parsing for credentials in Python.Jelmer Vernooij2007-12-271-6/+18
* r26088: Import some native-python python modules and move original python swi...Jelmer Vernooij2007-12-211-0/+46
class="hl num">1]) assert not path.exists(f) open(f, 'w').write(content) assert path.isfile(f) and not path.islink(f) return f def join(self, *parts): return path.join(self.path, *parts) def __del__(self): self.rmtree() class TempHome(TempDir): def __init__(self): super(TempHome, self).__init__() self.__home = os.environ['HOME'] os.environ['HOME'] = self.path def rmtree(self): os.environ['HOME'] = self.__home super(TempHome, self).rmtree() class ExceptionNotRaised(Exception): """ Exception raised when an *expected* exception is *not* raised during a unit test. """ msg = 'expected %s' def __init__(self, expected): self.expected = expected def __str__(self): return self.msg % self.expected.__name__ def raises(exception, callback, *args, **kw): """ Tests that the expected exception is raised; raises ExceptionNotRaised if test fails. """ raised = False try: callback(*args, **kw) except exception, e: raised = True if not raised: raise ExceptionNotRaised(exception) return e def getitem(obj, key): """ Works like getattr but for dictionary interface. Use this in combination with raises() to test that, for example, KeyError is raised. """ return obj[key] def setitem(obj, key, value): """ Works like setattr but for dictionary interface. Use this in combination with raises() to test that, for example, TypeError is raised. """ obj[key] = value def delitem(obj, key): """ Works like delattr but for dictionary interface. Use this in combination with raises() to test that, for example, TypeError is raised. """ del obj[key] def no_set(obj, name, value='some_new_obj'): """ Tests that attribute cannot be set. """ raises(AttributeError, setattr, obj, name, value) def no_del(obj, name): """ Tests that attribute cannot be deleted. """ raises(AttributeError, delattr, obj, name) def read_only(obj, name, value='some_new_obj'): """ Tests that attribute is read-only. Returns attribute. """ # Test that it cannot be set: no_set(obj, name, value) # Test that it cannot be deleted: no_del(obj, name) # Return the attribute return getattr(obj, name) def is_prop(prop): return type(prop) is property class ClassChecker(object): __cls = None __subcls = None def __get_cls(self): if self.__cls is None: self.__cls = self._cls assert inspect.isclass(self.__cls) return self.__cls cls = property(__get_cls) def __get_subcls(self): if self.__subcls is None: self.__subcls = self.get_subcls() assert inspect.isclass(self.__subcls) return self.__subcls subcls = property(__get_subcls) def get_subcls(self): raise NotImplementedError( self.__class__.__name__, 'get_subcls()' ) def check_TypeError(value, type_, name, callback, *args, **kw): """ Tests a standard TypeError raised with `errors.raise_TypeError`. """ e = raises(TypeError, callback, *args, **kw) assert e.value is value assert e.type is type_ assert e.name == name assert type(e.name) is str assert str(e) == ipalib.errors.TYPE_FORMAT % (name, type_, value) return e def get_api(**kw): """ Returns (api, home) tuple. This function returns a tuple containing an `ipalib.plugable.API` instance and a `TempHome` instance. """ home = TempHome() api = ipalib.create_api(mode='unit_test') api.env.in_tree = True for (key, value) in kw.iteritems(): api.env[key] = value return (api, home) def create_test_api(**kw): """ Returns (api, home) tuple. This function returns a tuple containing an `ipalib.plugable.API` instance and a `TempHome` instance. """ home = TempHome() api = ipalib.create_api(mode='unit_test') api.env.in_tree = True for (key, value) in kw.iteritems(): api.env[key] = value return (api, home) class PluginTester(object): __plugin = None def __get_plugin(self): if self.__plugin is None: self.__plugin = self._plugin assert issubclass(self.__plugin, Plugin) return self.__plugin plugin = property(__get_plugin) def register(self, *plugins, **kw): """ Create a testing api and register ``self.plugin``. This method returns an (api, home) tuple. :param plugins: Additional \*plugins to register. :param kw: Additional \**kw args to pass to `create_test_api`. """ (api, home) = create_test_api(**kw) api.register(self.plugin) for p in plugins: api.register(p) return (api, home) def finalize(self, *plugins, **kw): (api, home) = self.register(*plugins, **kw) api.finalize() return (api, home) def instance(self, namespace, *plugins, **kw): (api, home) = self.finalize(*plugins, **kw) o = api[namespace][self.plugin.__name__] return (o, api, home)