本文整理汇总了Python中pyramid.paster.bootstrap函数的典型用法代码示例。如果您正苦于以下问题:Python bootstrap函数的具体用法?Python bootstrap怎么用?Python bootstrap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bootstrap函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_app_from_commandline
def setup_app_from_commandline(self, argv):
if len(argv) < 2:
print >> sys.stderr, 'No configuration file specified.'
sys.exit(1)
bootstrap(argv[1])
self.app = default_app
return argv[:1] + argv[2:]
示例2: main
def main():
if len(sys.argv) != 2:
usage()
bootstrap(sys.argv[1])
Base.metadata.create_all()
示例3: main
def main(args=None):
"""The main routine."""
if args is None:
args = sys.argv[1:]
parser = argparse.ArgumentParser(description="Kinto commands")
subparsers = parser.add_subparsers(title='subcommands',
description='valid subcommands',
help='init/start/migrate')
parser_init = subparsers.add_parser('init')
parser_init.set_defaults(which='init')
parser_init.add_argument('--config_file', required=False,
help='Config file may be passed as argument')
parser_migrate = subparsers.add_parser('migrate')
parser_migrate.set_defaults(which='migrate')
parser_start = subparsers.add_parser('start')
parser_start.set_defaults(which='start')
args = vars(parser.parse_args())
if args['which'] == 'init':
if(args['config_file'] is None):
env = bootstrap('config/kinto.ini')
else:
config_file = format(args['config_file'])
env = bootstrap(config_file)
elif args['which'] == 'migrate':
env = bootstrap('config/kinto.ini')
cliquet.init_schema(env)
elif args['which'] == 'start':
pserve_argv = ['pserve', 'config/kinto.ini', '--reload']
pserve.main(pserve_argv)
示例4: quick_test
def quick_test(options):
bootstrap(production=False)
from runway.core.system.jobs.prune_logs import PruneLogsJob
j = PruneLogsJob()
j.perform_job(None)
return ""
示例5: take_action
def take_action(self, parsed_args):
config = parsed_args.config
bootstrap(config)
create_blog(raw_input)
import transaction
transaction.commit()
示例6: init_db
def init_db(args):
"""Create database tables and elasticsearch indices."""
# Force model creation using the MODEL_CREATE_ALL env var
os.environ['MODEL_CREATE_ALL'] = 'True'
# Start the application, triggering model creation
paster.setup_logging(args.config_uri)
paster.bootstrap(args.config_uri)
示例7: main
def main():
if len(sys.argv) != 2:
usage()
config_uri = sys.argv[1]
bootstrap(config_uri)
Base.metadata.create_all()
示例8: main
def main(argv=sys.argv): # pragma: no cover
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
bootstrap(config_uri)
setup_logging(config_uri)
processor()
示例9: bootstrap
def bootstrap(args):
"""
Bootstrap the application from the given arguments.
Returns a bootstrapped request object.
"""
paster.setup_logging(args.config_uri)
request = Request.blank('/', base_url=args.base)
paster.bootstrap(args.config_uri, request=request)
return request
示例10: __init__
def __init__(self, options):
self.options = options
self.imported = set()
self.layers = []
settings = {}
with open(".build/config.yaml") as f:
settings = yaml.load(f)
self.languages = settings["available_locale_names"]
# must be done only once we have loaded the project config
from c2cgeoportal.models import DBSession, Interface, Theme, Role
self.session = DBSession()
self._ = {}
self.metadata_service_url = \
'http://shop.geoportail.lu/Portail/inspire/webservices/getMD.jsp'
registry = bootstrap(self.options.app_config)['registry']
request = bootstrap(self.options.app_config)['request']
self.es_layer_index = get_index(request) + '_layers'
self.tdirs = registry.queryUtility(ITranslationDirectories, default=[])
self.tsf = TranslationStringFactory('geoportailv3-client')
self.interfaces = self.session.query(Interface).filter(
Interface.name.in_(options.interfaces)
).all()
self.public_theme = {}
self.public_group = {}
for interface in self.interfaces:
self.public_theme[interface.id] = []
self.public_group[interface.id] = []
for theme in self.session.query(Theme).filter_by(public=True).all():
self._add_theme(theme)
for role in self.session.query(Role).all():
for theme in self.session.query(Theme).all():
self._add_theme(theme, role)
ensure_index(
get_elasticsearch(request),
self.es_layer_index,
options.recreate_index
)
try:
helpers.bulk(actions=self.layers,
client=get_elasticsearch(request),
raise_on_error=True)
except (BulkIndexError, ConnectionTimeout) as e:
statuslog("\n %s" % e)
示例11: take_action
def take_action(self, parsed_args):
from pyramid.paster import bootstrap
from urakata.models import Scaffold, Session, Base
bootstrap(parsed_args.config)
# suppress logging
Base.metadata.bind.echo = False
header = [("name", "version", "repository", "utime")]
row = [(s.name, s.version, s.repository.name, s.utime) for s in Session.query(Scaffold)]
return header + [row]
示例12: main
def main():
if len(sys.argv) != 2:
usage()
bootstrap(sys.argv[1])
if shutil.which('convert') is None:
print('Error: ImageMagick not found ("convert" is not in $PATH)')
print('Try: sudo apt-get install imagemagick')
sys.exit(2)
create_logos()
示例13: sql
def sql(options):
bootstrap(production=False)
results = cli_f.sql(*options.vals)
for i, query in enumerate(results):
print("")
print(options.vals[i])
if query.returns_rows:
for row in query:
print(row)
print("")
return ""
示例14: main
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
os.environ['PYJASPER_SERVLET_URL'] = settings['jasper_url']
bootstrap(config_uri)
engine = engine_from_config(settings, 'sqlalchemy.')
other_engine = engine_from_config(settings, 'othersql.')
Base.metadata.bind = engine
OtherBase.metadata.bind = other_engine
from ..models.esppt_models import (
esNopModel,
esRegModel,
spptModel,
)
from ..views.es_reports import GenerateSppt
DBSession.configure(bind=engine)
q = DBSession.query(esNopModel, esRegModel).filter(
esNopModel.es_reg_id == esRegModel.id)
q = q.filter(esNopModel.email_sent == 0)
for r_nop, r_reg in q:
nop = get_nop(r_nop)
q = spptModel.get_by_nop_thn(nop, r_nop.tahun)
sppt = q.first()
if not sppt:
continue
nilai = thousand(sppt.pbb_yg_harus_dibayar_sppt)
g = GenerateSppt(nop, r_nop.tahun, r_reg.kode)
#USER_ID) updated menggunakan password dari user yang ada di reg.kode aagusti
sppt_file = g.sppt_file
e_filename = os.path.split(sppt_file)[-1]
f = open(sppt_file)
content = f.read()
f.close()
e_content = base64.encodestring(content)
e_subject = EMAIL_SUBJECT.format(nop=nop, tahun=r_nop.tahun)
e_body = EMAIL_BODY.format(nama_wp=sppt.nm_wp_sppt, nop=nop,
tahun=r_nop.tahun, nilai=nilai)
files = [(e_filename, e_content)]
print('To: {name} <{email}>'.format(name=sppt.nm_wp_sppt,
email=r_reg.email))
print('Subject: {s}'.format(s=e_subject))
print('Body: {s}'.format(s=e_body))
print('File: {s}'.format(s=e_filename))
r_nop.email_sent = 1
flush(r_nop)
send(r_reg.email, sppt.nm_wp_sppt, e_subject, e_body, files,
settings['email_pengirim'])
transaction.commit()
示例15: main
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
bootstrap(config_uri)
email = input('Input Email:')
password = getpass.getpass('Input Password:')
user = User(email=email)
set_password(user, password)
with transaction.manager:
DBSession.add(user)