本文整理汇总了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))
示例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)
示例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)
示例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)
示例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()
示例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)
示例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()
示例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)
示例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)
示例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)
示例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")