[Zope-Checkins] SVN: Zope/trunk/src/Zope2/Startup/zopectl.py de-convolute-ize zopectl run and make providing the correct sys.argv to the run script more robust.

Chris Withers chris at simplistix.co.uk
Mon Apr 13 16:58:49 EDT 2009


Log message for revision 99160:
  de-convolute-ize zopectl run and make providing the correct sys.argv to the run script more robust.
  

Changed:
  U   Zope/trunk/src/Zope2/Startup/zopectl.py

-=-
Modified: Zope/trunk/src/Zope2/Startup/zopectl.py
===================================================================
--- Zope/trunk/src/Zope2/Startup/zopectl.py	2009-04-13 19:36:57 UTC (rev 99159)
+++ Zope/trunk/src/Zope2/Startup/zopectl.py	2009-04-13 20:58:49 UTC (rev 99160)
@@ -256,18 +256,16 @@
         print "debug -- run the Zope debugger to inspect your database"
         print "         manually using a Python interactive shell"
 
-    def do_run(self, arg):
-        tup = arg.split(' ')
-        if not arg:
+    def do_run(self, args):
+        if not args:
             print "usage: run <script> [args]"
             return
-        # remove -c and add script as sys.argv[0]
-        script = tup[0]
-        cmd = 'import sys; sys.argv.pop(); sys.argv.append(\'%s\');'  % script
-        if len(tup) > 1:
-            argv = tup[1:]
-            cmd += '[sys.argv.append(x) for x in %s];' % argv
-        cmd += 'import Zope2; app=Zope2.app(); execfile(\'%s\')' % script
+        # replace sys.argv
+        script = args.split(' ')[0]
+        cmd = (
+            "import sys; sys.argv[:]=%r.split(' ');"
+            "import Zope2; app=Zope2.app(); execfile(%r)"
+            ) % (args,script)
         cmdline = self.get_startup_cmd(self.options.python, cmd)
         self._exitstatus = os.system(cmdline)
 



More information about the Zope-Checkins mailing list