parser = optparse.OptionParser() parser.add_option("-n", "--no-console", dest="console", action="store_false", default=True, help="Disable the Cymbeline interactive console") parser.add_option("-s", '--settings', dest='settings', help = 'The Settings database for cymbeline') (options,args) = parser.parse_args() from cymbeline.Bootstrap import bootstrap import shallot.Boot def user_bootstrap(gc): shallot.Boot.boot(gc, '/shallot/') bootstrap(user_bootstrap, ic_console = options.console, settings_db = options.settings) print "Heading out..." sys.exit()
def launch(): # Setup path to include the local directory cwd = os.getcwd() sys.path.append(cwd) # New fangled cymbelined launcher - no more ugly cymbeline.py hacks. parser = optparse.OptionParser() parser.add_option("-n", "--no-daemon", dest="console", action="store_true", default=False, help="Enable the interactive console (no daemon)") parser.add_option("-s", '--settings', dest='settings', help = 'The Settings database for cymbeline') parser.add_option("-l", '--log', dest='dolog', help='Enable logging') (options,args) = parser.parse_args() app = args[0] # pretend to parse app here # Parse .cymapp for file xmldoc = minidom.parse(app + ".cymapp") cymapp = xmldoc.getElementsByTagName('cymapp')[0] xmodule = cymapp.getElementsByTagName('module')[0] try: xsettings = cymapp.getElementsByTagName('settings')[0] except: xsettings = None # Try to read settings settings="" if options.settings: settings = options.settings elif xsettings: settings = xsettings.childNodes[0].data else: settings = 'db_settings' app = xmodule.childNodes[0].data print "Trying to launch '"+app+"'", if options.console: print " on the console." else: print " as a daemon." exec("import " + app + ".Boot") mod = sys.modules[app+".Boot"] fun = getattr(mod, 'boot') from cymbeline.Bootstrap import bootstrap try: if not options.console: createDaemon() except: print "Can't fork on this platform" bootstrap(fun, settings_db = settings, ic_console = options.console)