[Zodb-checkins] CVS: ZODB3/zdaemon - sample.conf:1.1 schema.xml:1.1 zdctl.py:1.11

Guido van Rossum guido@python.org
Tue, 14 Jan 2003 17:20:13 -0500


Update of /cvs-repository/ZODB3/zdaemon
In directory cvs.zope.org:/tmp/cvs-serv10365

Modified Files:
	zdctl.py 
Added Files:
	sample.conf schema.xml 
Log Message:
Add schema support.

This is preliminary; for now, the schema only supports overriding
'program'.

Also started adding a 'show' command.  For now, only 'show python' is
implemented.



=== Added File ZODB3/zdaemon/sample.conf ===
# Sample config file for zdctl.py.

<zdctl>
  program sleep 100
</zdctl>


=== Added File ZODB3/zdaemon/schema.xml ===
<schema>

  <description>
    Schema for zdctl.
  </description>

  <sectiontype name="zdctl">
    <key name="program" datatype="string" required="yes" />
  </sectiontype>

  <section name="*" type="zdctl" attribute="zdctl" required="yes" />

</schema>


=== ZODB3/zdaemon/zdctl.py 1.10 => 1.11 ===
--- ZODB3/zdaemon/zdctl.py:1.10	Tue Jan 14 12:40:54 2003
+++ ZODB3/zdaemon/zdctl.py	Tue Jan 14 17:20:10 2003
@@ -46,6 +46,7 @@
     from os.path import dirname, abspath, normpath
     sys.path.append(dirname(dirname(normpath(abspath(sys.argv[0])))))
 
+import ZConfig
 from ZEO.runsvr import Options
 
 
@@ -74,20 +75,26 @@
     # Program (and arguments) for zdaemon
     program = None
 
+    def load_schema(self):
+        schemafile = os.path.join(self._dir, "schema.xml")
+        self.schema = ZConfig.loadSchema(schemafile)
+
     def load_configuration(self):
         Options.load_configuration(self) # Sets self.rootconf
         if not self.rootconf:
             self.usage("a configuration file is required; use -C")
         # XXX Should allow overriding more zdaemon options here
         if self.program is None:
-            self.program = self.rootconf.getlist("program")
+            program = self.rootconf.zdctl.program
+            if program:
+                self.program = program.split()
         if self.program is None:
             self.usage("no program specified in configuration")
 
 
 class ZDCmd(cmd.Cmd):
 
-    prompt = "(zdctl) "
+    prompt = "zdctl> "
 
     def __init__(self, options):
         self.options = options
@@ -155,6 +162,10 @@
         print "help          -- Print a list of available actions."
         print "help <action> -- Print help for <action>."
 
+    def do_EOF(self, arg):
+        print
+        return 1
+
     def do_start(self, arg):
         self.get_status()
         if not self.zd_up:
@@ -258,6 +269,43 @@
     def help_status(self):
         print "status [-l] -- Print status for the daemon process."
         print "               With -l, show raw status output as well."
+
+    def do_show(self, arg):
+        if not arg:
+            args = ["config"]
+        else:
+            args = arg.split()
+        methods = []
+        for arg in args:
+            try:
+                method = getattr(self, "show_" + arg)
+            except AttributeError:
+                self.help_show()
+                return
+            methods.append(method)
+        for method in methods:
+            method()
+
+    def show_config(self):
+        print "Show config"
+
+    def help_show(self):
+        print "show config -- show general configuration info"
+        print "show python -- show Python version and details"
+
+    def complete_show(self, text, *ignored):
+        options = ["config", "python"]
+        return [x for x in options if x.startswith(text)]
+
+    def show_python(self):
+        print "Version:   ", sys.version
+        print "Platform:  ", sys.platform
+        print "Executable:", sys.executable
+        print "Arguments: ", sys.argv
+        print "Directory: ", os.getcwd()
+        print "Path:"
+        for dir in sys.path:
+            print "    " + str(dir)
 
     def do_logreopen(self, arg):
         self.do_kill(str(signal.SIGUSR2))