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": ...@@ -90,6 +90,17 @@ if sys.platform[:3].lower() == "win":
def string_list(arg): def string_list(arg):
return arg.split() 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): class ZopeCtlOptions(ZDOptions):
# Zope controller options. # Zope controller options.
# #
...@@ -266,18 +277,19 @@ class ZopeCmd(ZDCmd): ...@@ -266,18 +277,19 @@ class ZopeCmd(ZDCmd):
os.system(cmdline) os.system(cmdline)
def do_foreground(self, arg): def do_foreground(self, arg):
if WIN: program = self.options.program
# Adding arguments to the program is not supported on Windows local_additions = []
# and the runzope script doesn't put you in debug-mode either if not program.count('-X'):
ZDCmd.do_foreground(self, arg) local_additions += ['-X']
else: if not program.count('debug-mode=on'):
self.options.program[1:1] = ["-X", "debug-mode=on"] local_additions += ['debug-mode=on']
try: program[1:1] = local_additions
ZDCmd.do_foreground(self, arg) command = quote_command(program)
finally: try:
self.options.program.remove("-X") return os.system(command)
self.options.program.remove("debug-mode=on") finally:
for addition in local_additions: program.remove(addition)
def help_debug(self): def help_debug(self):
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"
......
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