當前位置: 首頁>>代碼示例>>Python>>正文


Python paster.get_app方法代碼示例

本文整理匯總了Python中pyramid.paster.get_app方法的典型用法代碼示例。如果您正苦於以下問題:Python paster.get_app方法的具體用法?Python paster.get_app怎麽用?Python paster.get_app使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyramid.paster的用法示例。


在下文中一共展示了paster.get_app方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: boot_frontend

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def boot_frontend(config, debug=False):
    """
    Boot a Pyramid WSGI application as Twisted component
    """

    http_port = int(config.get('config-web', 'http_port'))
    websocket_uri = unicode(config.get('wamp', 'listen'))

    # https://stackoverflow.com/questions/13122519/serving-pyramid-application-using-twistd/13138610#13138610
    config = resource_filename('kotori.frontend', 'development.ini')
    application = get_app(config, 'main')

    # https://twistedmatrix.com/documents/13.1.0/web/howto/web-in-60/wsgi.html
    resource = WSGIResource(reactor, reactor.getThreadPool(), application)

    reactor.listenTCP(http_port, Site(resource)) 
開發者ID:daq-tools,項目名稱:kotori,代碼行數:18,代碼來源:server.py

示例2: command

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def command(config):  # pragma: no cover
    app = get_app(abspath(config), name='senic_hub')
    setup_logging(config)

    devices_path = app.registry.settings['devices_path']
    scan_interval_seconds = int(app.registry.settings.get(
        'device_scan_interval_seconds', DEFAULT_SCAN_INTERVAL_SECONDS))

    # install Ctrl+C handler
    def sigint_handler(*args):
        logger.info('Stopping...')
        sys.exit(0)
    signal.signal(signal.SIGINT, sigint_handler)

    while True:
        now = datetime.utcnow()
        discover_and_merge_devices(devices_path, now)

        next_scan = now + timedelta(seconds=scan_interval_seconds)
        logging.info("Next device discovery run scheduled for %s", next_scan)
        time.sleep(scan_interval_seconds) 
開發者ID:getsenic,項目名稱:senic-hub,代碼行數:23,代碼來源:device_discovery.py

示例3: main

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def main():
    ''' Indexes app data loaded to elasticsearch '''

    import argparse
    parser = argparse.ArgumentParser(
        description="Index data in Elastic Search", epilog=EPILOG,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    parser.add_argument('--item-type', action='append', help="Item type")
    parser.add_argument('--record', default=False, action='store_true', help="Record the xmin in ES meta")
    parser.add_argument('--app-name', help="Pyramid app name in configfile")
    parser.add_argument('config_uri', help="path to configfile")
    args = parser.parse_args()

    logging.basicConfig()
    options = {
        'embed_cache.capacity': '5000',
        'indexer': 'true',
    }
    app = get_app(args.config_uri, args.app_name, options)

    # Loading app will have configured from config file. Reconfigure here:
    logging.getLogger('snovault').setLevel(logging.DEBUG)
    return run(app, args.item_type, args.record) 
開發者ID:ENCODE-DCC,項目名稱:snovault,代碼行數:26,代碼來源:es_index_data.py

示例4: main

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def main():
    import argparse
    parser = argparse.ArgumentParser(
        description="Create Elasticsearch mapping", epilog=EPILOG,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    parser.add_argument('--item-type', action='append', help="Item type")
    parser.add_argument('--app-name', help="Pyramid app name in configfile")
    parser.add_argument(
        '--dry-run', action='store_true', help="Don't post to ES, just print")
    parser.add_argument('config_uri', help="path to configfile")
    args = parser.parse_args()

    logging.basicConfig()
    app = get_app(args.config_uri, args.app_name)

    # Loading app will have configured from config file. Reconfigure here:
    logging.getLogger('snovault').setLevel(logging.DEBUG)

    return run(app, args.item_type, args.dry_run) 
開發者ID:ENCODE-DCC,項目名稱:snovault,代碼行數:22,代碼來源:create_mapping.py

示例5: setUp

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def setUp(self):
        """set up the test
        """
        import transaction
        from pyramid import paster, testing
        from webtest import TestApp
        from stalker import db
        from stalker.db.session import DBSession

        testing.setUp()
        import os
        import stalker_pyramid
        app = paster.get_app(
            os.path.join(
                os.path.dirname(
                    stalker_pyramid.__path__[0],
                ),
                'testing.ini'
            ).replace('\\', '/')
        )

        self.test_app = TestApp(app)

        # patch DBSession commit, to let the db.init() work
        # with its calls to DBSession.commit()
        _orig_commit = DBSession.commit
        DBSession.commit = transaction.commit
        db.setup(app.registry.settings)
        db.init()
        # restore DBSession.commit
        DBSession.commit = _orig_commit

        from stalker import User
        self.admin = User.query.filter(User.name == 'admin').first() 
開發者ID:eoyilmaz,項目名稱:stalker_pyramid,代碼行數:36,代碼來源:testing.py

示例6: internal_app

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def internal_app(configfile, app_name=None, username=''):
    from pyramid import paster
    app = paster.get_app(configfile, app_name)
    if not username:
        username = 'IMPORT'
    environ = {
        'HTTP_ACCEPT': 'application/json',
        'REMOTE_USER': username,
    }
    return TestApp(app, environ) 
開發者ID:ENCODE-DCC,項目名稱:snovault,代碼行數:12,代碼來源:import_data.py

示例7: main

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def main():
    import argparse
    parser = argparse.ArgumentParser(
        description="Move attachment blobs to S3", epilog=EPILOG,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    parser.add_argument('--app-name', help="Pyramid app name in configfile")
    parser.add_argument('--abort', action='store_true', help="Rollback transaction")
    parser.add_argument('config_uri', help="path to configfile")
    args = parser.parse_args()

    logging.basicConfig()
    app = get_app(args.config_uri, args.app_name)
    # Loading app will have configured from config file. Reconfigure here:
    logging.getLogger('snovault').setLevel(logging.DEBUG)

    raised = False
    try:
        run(app)
    except:
        raised = True
        raise
    finally:
        if raised or args.abort:
            transaction.abort()
            logger.info('Rolled back.')
        else:
            transaction.commit() 
開發者ID:ENCODE-DCC,項目名稱:snovault,代碼行數:30,代碼來源:migrate_attachments_aws.py

示例8: internal_app

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def internal_app(configfile, app_name=None, username=None, accept_json=True):
    from webtest import TestApp
    from pyramid import paster
    app = paster.get_app(configfile, app_name)
    if not username:
        username = 'IMPORT'
    environ = {
        'REMOTE_USER': username,
    }
    if accept_json:
        environ['HTTP_ACCEPT'] = 'application/json'
    return TestApp(app, environ) 
開發者ID:ENCODE-DCC,項目名稱:snovault,代碼行數:14,代碼來源:profile.py

示例9: internal_app

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def internal_app(configfile, app_name=None, username='TEST', accept='text/html'):
    from pyramid import paster
    from webtest import TestApp
    app = paster.get_app(configfile, app_name)
    environ = {
        'HTTP_ACCEPT': accept,
        'REMOTE_USER': username,
    }
    return TestApp(app, environ) 
開發者ID:ENCODE-DCC,項目名稱:snovault,代碼行數:11,代碼來源:check_rendering.py

示例10: internal_app

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def internal_app(configfile, app_name=None, username=None):
    from webtest import TestApp
    from pyramid import paster
    app = paster.get_app(configfile, app_name)
    if not username:
        username = 'IMPORT'
    environ = {
        'HTTP_ACCEPT': 'application/json',
        'REMOTE_USER': username,
    }
    return TestApp(app, environ) 
開發者ID:ENCODE-DCC,項目名稱:snovault,代碼行數:13,代碼來源:es_index_listener.py

示例11: main

# 需要導入模塊: from pyramid import paster [as 別名]
# 或者: from pyramid.paster import get_app [as 別名]
def main(config):
    log_format = '%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s'
    logging.basicConfig(level=logging.INFO, format=log_format)

    # TODO: remove too verbose logging messages like this
    logger.info("--- Start ----")

    # urllib3 logger is very verbose so we hush it down
    logging.getLogger("urllib3.connectionpool").setLevel(logging.CRITICAL)

    app = get_app(abspath(config), name='senic_hub')

    config_path = app.registry.settings['nuimo_app_config_path']

    ha_api_url = app.registry.settings['homeassistant_api_url']
    ble_adapter_name = app.registry.settings['bluetooth_adapter_name']

    nuimo_apps = {}
    queues = {}
    processes = {}
    # creating initial nuimo apps:
    update_from_config_file(config_path, queues, nuimo_apps, processes, ha_api_url, ble_adapter_name)

    if platform.system() == 'Linux':
        watch_config_thread = Thread(
            target=watch_config_changes,
            args=(config_path, queues, nuimo_apps, processes, ha_api_url, ble_adapter_name),
            daemon=True)
        watch_config_thread.start()
    elif not queues:
        logger.error("No Nuimos configured and can't watch config for changes!")

    try:
        with open(config_path, 'r') as f:
            config = yaml.load(f)
        for mac_addr in config['nuimos']:
            components = config['nuimos'][mac_addr].get('components', [])
            app = NuimoApp(ha_api_url, ble_adapter_name, mac_addr, components)
            ipc_queue = Queue()
            queues[mac_addr] = ipc_queue
            nuimo_apps[mac_addr] = components
            processes[mac_addr] = Process(target=app.start, args=(ipc_queue,))
            processes[mac_addr].start()

    except FileNotFoundError as e:
        logger.error(e)

    while True:
        try:
            time.sleep(1)
        except KeyboardInterrupt:
            logger.info("Received SIGINT, stopping all nuimo apps...")
            break

    for mac_addr in queues.keys():
        queues[mac_addr].put({'method': 'stop'})
        processes[mac_addr].join()

    os.system('systemctl restart bluetooth')

    logger.info("Stopped all nuimo apps") 
開發者ID:getsenic,項目名稱:senic-hub,代碼行數:63,代碼來源:__main__.py


注:本文中的pyramid.paster.get_app方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。