Commit 539a73ad authored by Chris Withers's avatar Chris Withers

Make "zopectl fg" work on Windows by borrowing from plone.recipe.zope2instance

parent 33cff5ce
......@@ -90,6 +90,17 @@ if sys.platform[:3].lower() == "win":
def string_list(arg):
return arg.split()
def quote_command(command):
print " ".join(command)
# Quote the program name, so it works even if it contains spaces
command = " ".join(['"%s"' % x for x in command])
if WIN:
# odd, but true: the windows cmd processor can't handle more than
# one quoted item per string unless you add quotes around the
# whole line.
command = '"%s"' % command
return command
class ZopeCtlOptions(ZDOptions):
# Zope controller options.
#
......@@ -266,17 +277,18 @@ class ZopeCmd(ZDCmd):
os.system(cmdline)
def do_foreground(self, arg):
if WIN:
# Adding arguments to the program is not supported on Windows
# and the runzope script doesn't put you in debug-mode either
ZDCmd.do_foreground(self, arg)
else:
self.options.program[1:1] = ["-X", "debug-mode=on"]
program = self.options.program
local_additions = []
if not program.count('-X'):
local_additions += ['-X']
if not program.count('debug-mode=on'):
local_additions += ['debug-mode=on']
program[1:1] = local_additions
command = quote_command(program)
try:
ZDCmd.do_foreground(self, arg)
return os.system(command)
finally:
self.options.program.remove("-X")
self.options.program.remove("debug-mode=on")
for addition in local_additions: program.remove(addition)
def help_debug(self):
print "debug -- run the Zope debugger to inspect your database"
......
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