def run( arguments, options={} ): import argparse p = argparse.ArgumentParser(description="Starts a web server that translates PAML files") p.add_argument("values", type=str, nargs="*") p.add_argument("-d", "--def", dest="var", type=str, action="append") args = p.parse_args(arguments) options.update(dict(_.split("=",1) for _ in args.var or "")) options.update(dict((_.split("=",1)[0].lower(), _.split("=",1)[1]) for _ in args.values or "" if not _.startswith("proxy:"))) # We can load defaults. This should be moved to a dedicated option. global PAMELA_DEFAULTS defaults_path = ".paml-defaults" if os.path.exists(defaults_path): with open(defaults_path) as f: PAMELA_DEFAULTS = json.load(f) processors = getProcessors() if "plain" in options: for v in options["plain"].split(","): del processors[v.strip()] files = getLocalFiles() comps = [files] proxies = [x[len("proxy:"):] for x in [x for x in args.values if x.startswith("proxy:")]] comps.extend(proxy.createProxies(proxies)) app = retro.Application(components=comps) retro.command( [_ for _ in args.values], app = app, port = int(options.get("port") or retro.DEFAULT_PORT) )
def run( arguments, options={} ): files = getLocalFiles() comps = [files] proxies = map(lambda x:x[len("proxy:"):],filter(lambda x:x.startswith("proxy:"),arguments)) comps.extend(proxy.createProxies(proxies)) app = retro.Application(components=comps) retro.command( arguments, app = app, sessions = False, port = int(options.get("port") or retro.DEFAULT_PORT) )