[Zodb-checkins] SVN: zdaemon/trunk/src/zdaemon/ Accept duplicate command-line options to work with scripts that embed

Jim Fulton jim at zope.com
Wed Jan 10 13:27:07 EST 2007


Log message for revision 71890:
  Accept duplicate command-line options to work with scripts that embed
  configuration options, such as the name of the configuration file.
  

Changed:
  U   zdaemon/trunk/src/zdaemon/tests/tests.py
  U   zdaemon/trunk/src/zdaemon/zdctl.py
  U   zdaemon/trunk/src/zdaemon/zdoptions.py

-=-
Modified: zdaemon/trunk/src/zdaemon/tests/tests.py
===================================================================
--- zdaemon/trunk/src/zdaemon/tests/tests.py	2007-01-10 18:26:21 UTC (rev 71889)
+++ zdaemon/trunk/src/zdaemon/tests/tests.py	2007-01-10 18:27:06 UTC (rev 71890)
@@ -63,8 +63,29 @@
 
     """
     
+def allow_duplicate_arguments():
+    """
+    
+Wrapper scripts will often embed configuration arguments. This could
+cause a problem when zdaemon reinvokes itself, passing it's own set of
+configuration arguments.  To deal with this, we'll allow duplicate
+arguments that have the same values.
 
+    >>> open('conf', 'w').write(
+    ... '''
+    ... <runner>
+    ...   program sleep 10
+    ... </runner>
+    ... ''')
 
+    >>> system("./zdaemon -Cconf -Cconf -Cconf start")
+    . daemon process started, pid=21446
+
+    >>> system("./zdaemon -Cconf -Cconf -Cconf stop")
+    daemon process stopped
+
+"""
+
 def setUp(test):
     test.globs['_td'] = td = []
     here = os.getcwd()

Modified: zdaemon/trunk/src/zdaemon/zdctl.py
===================================================================
--- zdaemon/trunk/src/zdaemon/zdctl.py	2007-01-10 18:26:21 UTC (rev 71889)
+++ zdaemon/trunk/src/zdaemon/zdctl.py	2007-01-10 18:27:06 UTC (rev 71890)
@@ -223,7 +223,7 @@
                 args = [self.options.python, self.options.zdrun]
             else:
                 args = [self.options.python, sys.argv[0]]
-                os.environ['ZDAEMON_MODE'] = '1'
+                os.environ['DAEMON_MANAGER_MODE'] = '1'
                 
             args += self._get_override("-S", "schemafile")
             args += self._get_override("-C", "configfile")
@@ -605,7 +605,7 @@
     if args is None:
         args = sys.argv[1:]
 
-    if os.environ.get('ZDAEMON_MODE'):
+    if os.environ.get('DAEMON_MANAGER_MODE'):
         import zdaemon.zdrun
         return zdaemon.zdrun.main(args)
         

Modified: zdaemon/trunk/src/zdaemon/zdoptions.py
===================================================================
--- zdaemon/trunk/src/zdaemon/zdoptions.py	2007-01-10 18:26:21 UTC (rev 71889)
+++ zdaemon/trunk/src/zdaemon/zdoptions.py	2007-01-10 18:27:06 UTC (rev 71890)
@@ -246,6 +246,10 @@
                     self.usage("invalid value for %s %r: %s" % (opt, arg, msg))
             if name and arg is not None:
                 if getattr(self, name) is not None:
+                    if getattr(self, name) == arg:
+                        # Repeated option, but we don't mind because it
+                        # just reinforces what we have.
+                        continue
                     self.usage("conflicting command line option %r" % opt)
                 setattr(self, name, arg)
 



More information about the Zodb-checkins mailing list