示例#1
0
def makeService(config):
    config_file = os.path.abspath(config['config'])
    parser = ConfigLoader(config_file).parser

    parent_service = service.MultiService()

    gg_factory = None
    if parser.has_section('gg'):
        gg_service, gg_factory = getGGService(parser)
        parent_service.addService(gg_service)

    skype_factory = None
    if parser.has_section('skype'):
        skype_service, skype_factory = getSkypeService(parser)
        parent_service.addService(skype_service)

    jabber_factory = None
    if parser.has_section('jabber'):
        jabber_service, jabber_factory = getJabberService(parser)
        parent_service.addService(jabber_service)

    xml_service = getXMLRPCService(parser,
                                   gg_factory=gg_factory,
                                   skype_factory=skype_factory,
                                   jabber_factory=jabber_factory)
    parent_service.addService(xml_service)
    return parent_service
示例#2
0
def waitress_main(args=None):
    """
    Configure + start Plone behind waitress from the given PasteDeploy
    configuration
    Waitress - unlike uwsgi - expects us to do the
    PasteDeploy stuff on our own.
    """
    ini_filename = args[-1]
    config_loader = ConfigLoader(ini_filename)
    server_config = config_loader.get_context(SERVER)
    serve = server_config.create()
    app_config = config_loader.get_context(APP)
    zope_conf = app_config.local_conf['zope_conf']
    wsgiapp = make_wsgi_app(app_config.global_conf, zope_conf)
    serve(wsgiapp)
示例#3
0
文件: daemon.py 项目: erasche/pulsar
def load_app_configuration(ini_path, app_conf_path=None, app_name=None, local_conf=None, pulsar_root=PULSAR_ROOT_DIR):
    """
    """
    if ini_path and local_conf is None:
        local_conf = ConfigLoader(ini_path).app_context(app_name).config()
    local_conf = local_conf or {}
    if app_conf_path is None and "app_config" in local_conf:
        app_conf_path = absolute_config_path(local_conf["app_config"], pulsar_root)
    elif ini_path:
        # If not explicit app.yml file found - look next to server.ini -
        # be it in pulsar root, some temporary staging directory, or /etc.
        app_conf_path = __find_default_app_config(
            os.path.dirname(ini_path),
        )
    if app_conf_path:
        if yaml is None:
            raise Exception("Cannot load confiuration from file %s, pyyaml is not available." % app_conf_path)

        with open(app_conf_path, "r") as f:
            local_conf.update(yaml.load(f))

    return local_conf
示例#4
0
def __app_config(ini_path, app_name):
    config = ConfigLoader(ini_path).app_context(app_name).config()
    return config
示例#5
0
 def load(self):
     ini_path = self.ini_path
     app_name = self.app_name
     config = ConfigLoader(ini_path).app_context(app_name).config()
     return config
示例#6
0
            app_runner(execfile)(pyfile, _globals, dict(app=app, browser=browser))


def shell_runner(app, browser):
    ns = dict(app=app, browser=browser)
    interactive_shell = getattr(app, '__interact__', None)
    if interactive_shell is None:
        print ("The application %r doesn't have a specific __interact__ "
                "debugging method. Spawning a generic one." % app)
        interactive_shell = make_shell
    interactive_shell(banner="Python@ASD-project", **ns)


def runner(app, browser=None, pyfile=None):
    if pyfile is not None:
        return file_runner(app, browser, pyfile)
    shell_runner(app, browser)


parser = argparse.ArgumentParser()
parser.add_argument("ini", help="PythonPaste configuration file")
parser.add_argument("--app", help="Name of the app configuration section")
parser.add_argument("--file", help="python script to run")
parser.add_argument("--browser", help="Fake browser emulation", action="store_true")
args = parser.parse_args()
loader = ConfigLoader(args.ini)

app = args.app and loader.get_app(args.app) or loader.get_app()
browser = args.browser and Browser(app) or None
runner(app, browser, pyfile=args.file)
示例#7
0
def load_app_config(options):
    from paste.deploy.loadwsgi import ConfigLoader

    loader = ConfigLoader(path(options.app_ini).abspath())
    return loader.app_context().config()