[Zope-Checkins] CVS: ZODB3/zdaemon - sample.conf:1.4 schema.xml:1.5 zdctl.py:1.21

Guido van Rossum guido@python.org
Tue, 21 Jan 2003 13:52:22 -0500


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

Modified Files:
	sample.conf schema.xml zdctl.py 
Log Message:
Add a configuration option to require -i before entering interactive mode.


=== ZODB3/zdaemon/sample.conf 1.3 => 1.4 ===
--- ZODB3/zdaemon/sample.conf:1.3	Tue Jan 21 13:19:38 2003
+++ ZODB3/zdaemon/sample.conf	Tue Jan 21 13:52:19 2003
@@ -11,4 +11,5 @@
   exit-codes	0,2
   # user has no default
   directory	/
+  default-to-interactive True
 </runner>


=== ZODB3/zdaemon/schema.xml 1.4 => 1.5 ===
--- ZODB3/zdaemon/schema.xml:1.4	Tue Jan 21 13:19:38 2003
+++ ZODB3/zdaemon/schema.xml	Tue Jan 21 13:52:19 2003
@@ -16,6 +16,7 @@
 	       default="0,2" />
     <key name="user" datatype="string" />
     <key name="directory" datatype="existing-directory" default="/" />
+    <key name="default-to-interactive" datatype="boolean" default="true" />
   </sectiontype>
 
   <section name="*" type="runner" attribute="runner" required="yes" />


=== ZODB3/zdaemon/zdctl.py 1.20 => 1.21 ===
--- ZODB3/zdaemon/zdctl.py:1.20	Tue Jan 21 13:19:38 2003
+++ ZODB3/zdaemon/zdctl.py	Tue Jan 21 13:52:19 2003
@@ -24,6 +24,7 @@
 -d/--daemon-- run as a proper daemon; fork a subprocess, close files etc.
 -f/--forever -- run forever (by default, exit when backoff limit is exceeded)
 -h/--help -- print this usage message and exit
+-i/--interactive -- start an interactive shell after executing commands
 -p/--program PROGRAM -- the program to run
 -s/--socket-name SOCKET -- Unix socket name for client (default "zdsock")
 -u/--user USER -- run as this user (or numeric uid)
@@ -31,10 +32,11 @@
 -z/--directory DIRECTORY -- directory to chdir to when using -d (default "/")
 action [arguments] -- see below
 
-Actions are commands like "start", "stop" and "status".  If no action
-is specified on the command line, a "shell" interpreting actions typed
-interactively is started.  Use the action "help" to find out about
-available actions.
+Actions are commands like "start", "stop" and "status".  If -i is
+specified or no action is specified on the command line, a "shell"
+interpreting actions typed interactively is started (unless the
+configuration option default_to_interactive is set to false).  Use the
+action "help" to find out about available actions.
 """
 
 from __future__ import nested_scopes
@@ -74,6 +76,9 @@
 
     def __init__(self):
         RunnerOptions.__init__(self)
+        self.add("interactive", None, "i", "interactive", flag=1)
+        self.add("default_to_interactive", "runner.default_to_interactive",
+                 default=1)
         self.add("program", "runner.program", "p:", "program=",
                  handler=string_list,
                  required="no program specified; use -p or -C")
@@ -83,6 +88,12 @@
     def realize(self, *args, **kwds):
         RunnerOptions.realize(self, *args, **kwds)
 
+        # Maybe the config file requires -i or positional args
+        if not self.args and not self.interactive:
+            if not self.default_to_interactive:
+                self.usage("either -i or an action argument is required")
+            self.interactive = 1
+
         # Where's python?
         if not self.python:
             self.python = sys.executable
@@ -356,7 +367,7 @@
     c = ZDCmd(options)
     if options.args:
         c.onecmd(" ".join(options.args))
-    else:
+    if options.interactive:
         print "program:", " ".join(options.program)
         c.do_status()
         c.cmdloop()