samba-tool: Move main command implementation to samba.netcmd.main, so it is accessibl...
authorJelmer Vernooij <jelmer@samba.org>
Thu, 13 Oct 2011 21:36:10 +0000 (23:36 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 13 Oct 2011 22:22:57 +0000 (00:22 +0200)
source4/scripting/bin/samba-tool
source4/scripting/python/samba/netcmd/__init__.py
source4/scripting/python/samba/netcmd/main.py [new file with mode: 0644]

index 9f06e8daae8ae9aa5eb7b282c073e9ab99a1500a..c4ea8141666ca70c771954d1800a911aa08f54d2 100755 (executable)
@@ -23,63 +23,21 @@ import sys
 # Find right direction when running from source tree
 sys.path.insert(0, "bin/python")
 
-from samba import netcmd
-from samba.netcmd import SuperCommand
-from samba.netcmd.dbcheck import cmd_dbcheck
-from samba.netcmd.delegation import cmd_delegation
-from samba.netcmd.domain import cmd_domain
-from samba.netcmd.drs import cmd_drs
-from samba.netcmd.dsacl import cmd_dsacl
-from samba.netcmd.fsmo import cmd_fsmo
-from samba.netcmd.gpo import cmd_gpo
-from samba.netcmd.group import cmd_group
-from samba.netcmd.ldapcmp import cmd_ldapcmp
-from samba.netcmd.ntacl import cmd_ntacl
-from samba.netcmd.rodc import cmd_rodc
-from samba.netcmd.spn import cmd_spn
-from samba.netcmd.testparm import cmd_testparm
-from samba.netcmd.time import cmd_time
-from samba.netcmd.user import cmd_user
-from samba.netcmd.vampire import cmd_vampire
-
-
-class cmd_sambatool(SuperCommand):
-    """samba-tool SuperCommand"""
-
-    subcommands = {}
-    subcommands["dbcheck"] =  cmd_dbcheck()
-    subcommands["delegation"] = cmd_delegation()
-    subcommands["domain"] = cmd_domain()
-    subcommands["drs"] = cmd_drs()
-    subcommands["dsacl"] = cmd_dsacl()
-    subcommands["fsmo"] = cmd_fsmo()
-    subcommands["gpo"] = cmd_gpo()
-    subcommands["group"] = cmd_group()
-    subcommands["ldapcmp"] = cmd_ldapcmp()
-    subcommands["ntacl"] = cmd_ntacl()
-    subcommands["rodc"] = cmd_rodc()
-    subcommands["spn"] = cmd_spn() 
-    subcommands["testparm"] =  cmd_testparm()
-    subcommands["time"] = cmd_time()
-    subcommands["user"] = cmd_user()
-    subcommands["vampire"] = cmd_vampire()
-
-
-if __name__ == '__main__':
-    cmd = cmd_sambatool()
-    subcommand = None
-    args = ()
-
-    if len(sys.argv) > 1:
-        subcommand = sys.argv[1]
-        if len(sys.argv) > 2:
-            args = sys.argv[2:]
-
-    try:
-        retval = cmd._run("samba-tool", subcommand, *args)
-    except SystemExit, e:
-        retval = -1
-    except Exception, e:
-        cmd.show_command_error(e)
-        retval = 1
-    sys.exit(retval)
+from samba.netcmd.main import cmd_sambatool
+cmd = cmd_sambatool()
+subcommand = None
+args = ()
+
+if len(sys.argv) > 1:
+    subcommand = sys.argv[1]
+    if len(sys.argv) > 2:
+        args = sys.argv[2:]
+
+try:
+    retval = cmd._run("samba-tool", subcommand, *args)
+except SystemExit, e:
+    retval = -1
+except Exception, e:
+    cmd.show_command_error(e)
+    retval = 1
+sys.exit(retval)
index 4d40b69d8873e6ebe29c7f341af5eae2ad5b999e..831ac6ba57bb5c77a8dd23aa129633a0e9d26f59 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 # Unix SMB/CIFS implementation.
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2009
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2009-2011
 # Copyright (C) Theresa Halloran <theresahalloran@gmail.com> 2011
 # Copyright (C) Giampaolo Lauria <lauria2@yahoo.com> 2011
 #
diff --git a/source4/scripting/python/samba/netcmd/main.py b/source4/scripting/python/samba/netcmd/main.py
new file mode 100644 (file)
index 0000000..6579632
--- /dev/null
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2011
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""The main samba-tool command implementation."""
+
+from samba.netcmd import SuperCommand
+from samba.netcmd.dbcheck import cmd_dbcheck
+from samba.netcmd.delegation import cmd_delegation
+from samba.netcmd.domain import cmd_domain
+from samba.netcmd.drs import cmd_drs
+from samba.netcmd.dsacl import cmd_dsacl
+from samba.netcmd.fsmo import cmd_fsmo
+from samba.netcmd.gpo import cmd_gpo
+from samba.netcmd.group import cmd_group
+from samba.netcmd.ldapcmp import cmd_ldapcmp
+from samba.netcmd.ntacl import cmd_ntacl
+from samba.netcmd.rodc import cmd_rodc
+from samba.netcmd.spn import cmd_spn
+from samba.netcmd.testparm import cmd_testparm
+from samba.netcmd.time import cmd_time
+from samba.netcmd.user import cmd_user
+from samba.netcmd.vampire import cmd_vampire
+
+
+class cmd_sambatool(SuperCommand):
+    """Main samba administration tool."""
+
+    subcommands = {}
+    subcommands["dbcheck"] =  cmd_dbcheck()
+    subcommands["delegation"] = cmd_delegation()
+    subcommands["domain"] = cmd_domain()
+    subcommands["drs"] = cmd_drs()
+    subcommands["dsacl"] = cmd_dsacl()
+    subcommands["fsmo"] = cmd_fsmo()
+    subcommands["gpo"] = cmd_gpo()
+    subcommands["group"] = cmd_group()
+    subcommands["ldapcmp"] = cmd_ldapcmp()
+    subcommands["ntacl"] = cmd_ntacl()
+    subcommands["rodc"] = cmd_rodc()
+    subcommands["spn"] = cmd_spn()
+    subcommands["testparm"] =  cmd_testparm()
+    subcommands["time"] = cmd_time()
+    subcommands["user"] = cmd_user()
+    subcommands["vampire"] = cmd_vampire()