Commit a79042a1 authored by Chris Withers's avatar Chris Withers

de-convolute-ize zopectl run and make providing the correct sys.argv to the run script more robust.

parent bb3ba109
...@@ -256,18 +256,16 @@ class ZopeCmd(ZDCmd): ...@@ -256,18 +256,16 @@ class ZopeCmd(ZDCmd):
print "debug -- run the Zope debugger to inspect your database" print "debug -- run the Zope debugger to inspect your database"
print " manually using a Python interactive shell" print " manually using a Python interactive shell"
def do_run(self, arg): def do_run(self, args):
tup = arg.split(' ') if not args:
if not arg:
print "usage: run <script> [args]" print "usage: run <script> [args]"
return return
# remove -c and add script as sys.argv[0] # replace sys.argv
script = tup[0] script = args.split(' ')[0]
cmd = 'import sys; sys.argv.pop(); sys.argv.append(\'%s\');' % script cmd = (
if len(tup) > 1: "import sys; sys.argv[:]=%r.split(' ');"
argv = tup[1:] "import Zope2; app=Zope2.app(); execfile(%r)"
cmd += '[sys.argv.append(x) for x in %s];' % argv ) % (args,script)
cmd += 'import Zope2; app=Zope2.app(); execfile(\'%s\')' % script
cmdline = self.get_startup_cmd(self.options.python, cmd) cmdline = self.get_startup_cmd(self.options.python, cmd)
self._exitstatus = os.system(cmdline) self._exitstatus = os.system(cmdline)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment