samba-tool: Moved command definition to sambatool command
authorGiampaolo Lauria <lauria2@yahoo.com>
Mon, 1 Aug 2011 18:45:18 +0000 (14:45 -0400)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 9 Sep 2011 05:24:01 +0000 (15:24 +1000)
Moved subcommand definition from __init__.py to cmd_sambatool class

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/scripting/bin/samba-tool
source4/scripting/python/samba/netcmd/__init__.py

index ba792fb886a659375e6231d1da5a926ca419dd65..17183cea93c1083db43db8c3f41e45be645c8bf7 100755 (executable)
@@ -1,7 +1,8 @@
 #!/usr/bin/env python
 
 # Unix SMB/CIFS implementation.
-# Copyright (C) Amitay Isaacs <amitay@gmail.com> 211
+# Copyright (C) Amitay Isaacs <amitay@gmail.com> 2011
+# Copyright (C) Giampaolo Lauria <lauria2@yahoo.com> 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
@@ -24,29 +25,56 @@ sys.path.insert(0, "bin/python")
 
 from samba import netcmd
 from samba.netcmd import SuperCommand
-
+from samba.netcmd.netacl import cmd_acl
+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.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.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 = netcmd.commands
-
+    subcommands = {}
+    subcommands["acl"] = cmd_acl()
+    subcommands["dbcheck"] =  cmd_dbcheck()
+    subcommands["delegation"] = cmd_delegation()
+    subcommands["domain"] = cmd_domain()
+    subcommands["drs"] = cmd_drs()
+    subcommands["fsmo"] = cmd_fsmo()
+    subcommands["gpo"] = cmd_gpo()
+    subcommands["group"] = cmd_group()
+    subcommands["ldapcmp"] = cmd_ldapcmp()
+    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()
-
-    command = None
+    subcommand = None
     args = ()
 
     if len(sys.argv) > 1:
-        command = sys.argv[1]
+        subcommand = sys.argv[1]
         if len(sys.argv) > 2:
             args = sys.argv[2:]
 
     try:
-        retval = cmd._run("samba-tool", command, *args)
+        retval = cmd._run("samba-tool", subcommand, *args)
         sys.exit(retval)
     except Exception, e:
         cmd.show_command_error(e)
index 6d6d59ac187e62572f38a5c6711b1bd59a280555..a4a3397d80e53247e7ca2bd962e430faee18044a 100644 (file)
@@ -179,37 +179,3 @@ class CommandError(Exception):
         self.message = message
         self.inner_exception = inner_exception
         self.exception_info = sys.exc_info()
-
-
-
-commands = {}
-from samba.netcmd.netacl import cmd_acl
-commands["acl"] = cmd_acl()
-from samba.netcmd.fsmo import cmd_fsmo
-commands["fsmo"] = cmd_fsmo()
-from samba.netcmd.time import cmd_time
-commands["time"] = cmd_time()
-from samba.netcmd.user import cmd_user
-commands["user"] = cmd_user()
-from samba.netcmd.vampire import cmd_vampire
-commands["vampire"] = cmd_vampire()
-from samba.netcmd.spn import cmd_spn
-commands["spn"] = cmd_spn()
-from samba.netcmd.group import cmd_group
-commands["group"] = cmd_group()
-from samba.netcmd.rodc import cmd_rodc
-commands["rodc"] = cmd_rodc()
-from samba.netcmd.drs import cmd_drs
-commands["drs"] = cmd_drs()
-from samba.netcmd.gpo import cmd_gpo
-commands["gpo"] = cmd_gpo()
-from samba.netcmd.ldapcmp import cmd_ldapcmp
-commands["ldapcmp"] = cmd_ldapcmp()
-from samba.netcmd.testparm import cmd_testparm
-commands["testparm"] =  cmd_testparm()
-from samba.netcmd.dbcheck import cmd_dbcheck
-commands["dbcheck"] =  cmd_dbcheck()
-from samba.netcmd.delegation import cmd_delegation
-commands["delegation"] = cmd_delegation()
-from samba.netcmd.domain import cmd_domain
-commands["domain"] = cmd_domain()