def noshell(args=None): # This is a customized entry point for launching Zope without forking shell # scripts or other processes. options = zopectl.ZopeCtlOptions() # Realize arguments and set documentation which is used in the -h option options.realize(args, doc=__doc__) # Change the program to avoid warning messages script = os.path.join( options.configroot.softwarehome, 'Zope2', 'Startup', 'run.py') options.program = [options.python, script, '-C', options.configfile] # We use our own ZopeCmd set, that is derived from the original one. c = NoShellZopeCmd(options) # We need to apply a number of hacks to make things work: # We need to apply a number of hacks to make things work: # This puts amongst other things all the configured products directories # into the Products.__path__ so we can put those on the test path handlers.root_handler(options.configroot) # We need to apply the configuration in one more place import App.config App.config.setConfiguration(options.configroot) # The PYTHONPATH is not set, so all commands starting a new shell fail # unless we set it explicitly os.environ['PYTHONPATH'] = os.path.pathsep.join(sys.path) # Add the path to the zopeservice.py script, which is needed for some of the # Windows specific commands servicescript = os.path.join(options.configroot.instancehome, 'bin', 'zopeservice.py') options.servicescript = [options.python, servicescript] # If no command was specified we go into interactive mode. if options.args: c.onecmd(" ".join(options.args)) else: options.interactive = 1 if options.interactive: try: import readline except ImportError: pass print "program:", " ".join(options.program) c.do_status() c.cmdloop()
def main(args=None): # This is mainly a copy of zopectl.py's main function from Zope2.Startup options = zopectl.ZopeCtlOptions() # Realize arguments and set documentation which is used in the -h option options.realize(args, doc=__doc__) # We use our own ZopeCmd set, that is derived from the original one. c = AdjustedZopeCmd(options) # We need to apply a number of hacks to make things work: # This puts amongst other things all the configured products directories # into the Products.__path__ so we can put those on the test path handlers.root_handler(options.configroot) # We need to apply the configuration in one more place import App.config App.config.setConfiguration(options.configroot) # The PYTHONPATH is not set, so all commands starting a new shell fail # unless we set it explicitly os.environ['PYTHONPATH'] = os.path.pathsep.join(sys.path) # Add the path to the zopeservice.py script, which is needed for some of the # Windows specific commands servicescript = os.path.join(options.configroot.instancehome, 'bin', 'zopeservice.py') options.servicescript = [options.python, servicescript] # If no command was specified we go into interactive mode. if options.args: c.onecmd(" ".join(options.args)) else: options.interactive = 1 if options.interactive: try: import readline except ImportError: pass print "program:", " ".join(options.program) c.do_status() c.cmdloop() # Ideally we would return the exit code and let our caller deal with the exit code # return c._exitstatus # but zc.buildout doesnt let ./bin/instance set an exit code so lets just exit here # Also, if a run causes an exit code of 256, we get 0 when this process dies so force # to 1 or 0 sys.exit(c._exitstatus != 0)