本文整理汇总了Python中pyramid.paster.setup_logging函数的典型用法代码示例。如果您正苦于以下问题:Python setup_logging函数的具体用法?Python setup_logging怎么用?Python setup_logging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup_logging函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main(argv=sys.argv):
# Usage and configuration
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
config = Configurator(settings=settings)
config.include('pyramid_sqlalchemy')
# Make the database with schema and default data
with transaction.manager:
metadata.create_all()
root = RootFolder(name='',
title='Moonbase Demo',
__acl__=[
['Allow', ['paul'], 'view']
]
)
Session.add(root)
f1 = root['f1'] = Folder(
title='Folder 1',
__acl__=[
['Allow', ['shane'], 'view']
]
)
f1['da'] = Document(title='Document 1A')
开发者ID:pauleveritt,项目名称:moonbase,代码行数:27,代码来源:initializedb.py
示例2: 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)
mkdir(settings['static_files'])
# Create Ziggurat tables
alembic_ini_file = 'alembic.ini'
if not os.path.exists(alembic_ini_file):
alembic_ini = ALEMBIC_CONF.replace('{{db_url}}',
settings['sqlalchemy.url'])
f = open(alembic_ini_file, 'w')
f.write(alembic_ini)
f.close()
bin_path = os.path.split(sys.executable)[0]
alembic_bin = os.path.join(bin_path, 'alembic')
command = '%s upgrade head' % alembic_bin
os.system(command)
os.remove(alembic_ini_file)
# Insert data
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
init_model()
create_schemas(engine)
Base.metadata.create_all(engine)
initial_data.insert()
transaction.commit()
开发者ID:aagusti,项目名称:opensipkd-inventory,代码行数:28,代码来源:initializedb.py
示例3: bootstrap_script
def bootstrap_script(argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
return settings
开发者ID:timfreund,项目名称:canaria,代码行数:7,代码来源:__init__.py
示例4: main
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
#with transaction.manager:
# model = MyModel(name='one', value=1)
# DBSession.add(model)
with transaction.manager:
with open('agencies.csv','r') as f:
agencies = f.read().split('\n')
for agency in agencies:
if agency.strip() != '':
# agencyid, shortname, longname, type, description, websiteurl
parts = agency.split('\t')
agency_type = AgencyTypes.get_from_code(DBSession, parts[3])
a = Agencies(
agency_code = parts[1],
agency_name = parts[2],
type_id = agency_type.id,
description = parts[4],
website = parts[5],
)
DBSession.add(a)
transaction.commit()
开发者ID:n8felton,项目名称:mc911feedwatcher,代码行数:32,代码来源:initializedb.py
示例5: main
def main(argv=sys.argv):
global logger, settings, ca, ri, aws_access, aws_secret, thekey
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
# TODO: need to add settings to define where the files will be
logger = logging.getLogger('scripts')
# make configurable?
site_blacklist = set(['MedPass', 'Bridge'])
print "# Stack to site info generated by build_ini_info script"
stackmap = tools.parse_sites()
for stack, sites in stackmap.items():
clean = set(sites) - site_blacklist
print "stacks.%s = %s" % (stack, ', '.join(clean))
print "# RDS to site info generated by build_ini_info script"
rdsmap = tools.parse_rds()
# dbs.a4.gentivalink = a4-css-sup-cleanup-rds
for stack, sites in rdsmap.items():
for site, rdses in sites.items():
for rds in rdses:
print "dbs.%s.%s = %s" % (stack, site, rds)
开发者ID:robottaway,项目名称:warmachine,代码行数:30,代码来源:build_ini_info.py
示例6: main
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)
with transaction.manager:
model2 = Genre(id = 0,name='HipHop', info='Nigger ma fucker',year_of_found = 1990)
DBSession.add(model2)
model = Genre(id = 1,name='GlitchHop', info='Nu vaaassheee',year_of_found = 2014, parent_genre = model2)
DBSession.add(model)
model3 = Genre(id = 2,name='Grime', info='Zhostkiy rap',year_of_found = 2006, parent_genre = model2)
DBSession.add(model3)
model4 = Genre(id = 3,name='Dark Grime', info='Tyomniy Zhostkiy rap',year_of_found = 2009, parent_genre = model3)
DBSession.add(model4)
music1 = Music(author = 'Simplex_Method', title = 'Of Literal Data', year = 2015,genre = model3)
DBSession.add(music1)
开发者ID:LZIM-94,项目名称:Web-Music-Library,代码行数:27,代码来源:initializedb.py
示例7: main
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, name="testscaffold", options=options)
engine = get_engine(settings)
session_factory = get_session_factory(engine)
dbsession = get_tm_session(session_factory, transaction.manager)
with transaction.manager:
user = User(user_name="admin", email="[email protected]")
UserService.set_password(user, "admin")
admin_object = Group(group_name="Administrators")
group_permission = GroupPermission(perm_name="root_administration")
dbsession.add(admin_object)
admin_object.permissions.append(group_permission)
admin_object.users.append(user)
test_group = Group(group_name="Other group")
dbsession.add(test_group)
for x in range(1, 25):
user = User(user_name="test{}".format(x), email="foo{}@localhost".format(x))
UserService.set_password(user, "test")
test_group.users.append(user)
开发者ID:ergo,项目名称:testscaffold,代码行数:28,代码来源:initializedb.py
示例8: __call__
def __call__(self, argv=sys.argv):
self.configure_parser()
args = self.parser.parse_args(argv[1:])
if self.requires_config:
self.config_uri = args.config_uri
setup_logging(self.config_uri)
self.run(args)
开发者ID:cdunklau,项目名称:paildocket,代码行数:7,代码来源:management.py
示例9: 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)
engine = engine_from_config(settings, 'sqlalchemy.', echo=False)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
# populate databases
with transaction.manager:
print('\ninit_setpoint_interpolations:\n')
init_setpoint_interpolations(DBSession)
print('\ninit_parameter_types:\n')
init_parameter_types(DBSession)
print('\ninit_device_types:\n')
init_device_types(DBSession)
print('\ninit_periphery_controllers:\n')
DBSession.flush()
init_periphery_controllers(DBSession)
DBSession.flush()
print('\ninit_parameters:\n')
init_parameters(DBSession)
print('\ninit_devices:\n')
init_devices(DBSession)
print('\ninit_field_settings:\n')
init_field_settings(DBSession)
print('\ninit_regulators:\n')
DBSession.flush()
init_regulators(DBSession)
init_log_diagrams(DBSession)
开发者ID:AlexanderLang,项目名称:OpenAutomatedFarm,代码行数:33,代码来源:initialize_db.py
示例10: 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)
engine = engine_from_config(settings, "sqlalchemy.")
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
user = User()
user.set_password("wolfvo8491")
user.user_name = "wolfv"
user.email = "[email protected]"
user.status = 1 # Not verified yet
DBSession.add(user)
with transaction.manager:
user = User()
user.user_name = "wolf"
user.email = "[email protected]"
user.set_password("wolf")
user.status = 1
DBSession.add(user)
user = User()
user.user_name = "peter"
user.email = "[email protected]"
user.set_password("p")
user.status = 1
DBSession.add(user)
开发者ID:wolfv,项目名称:privatizer,代码行数:33,代码来源:initializedb.py
示例11: main
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
if config_uri not in ["jenkins.ini"]:
print "You are not initialising using a testing URI"
print "Edit init_testingdb.py if you really want to do this"
sys.exit(0)
setup_logging(config_uri)
settings = get_appsettings(config_uri)
engine = engine_from_config(settings, "sqlalchemy.")
meta.Session.configure(bind=engine)
Base.metadata.bind = engine
# Create Everythin
print "Dropping Tables"
Base.metadata.drop_all(engine)
print "Creating Tables"
Base.metadata.create_all(engine)
# We also want any alembic scripts to be executed
alembic_cfg = Config(config_uri) # TODO: WARNING RELATIVE PATH
command.stamp(alembic_cfg, "head")
DBSession = meta.Session()
# DBSession.configure(bind=engine)
populateData.init_data(DBSession)
populateUser()
populatedata()
开发者ID:rzvcs,项目名称:cogent-house,代码行数:30,代码来源:init_testingdb.py
示例12: listuserinfo
def listuserinfo():
arguments = listuserparser.parse_args()
if not arguments.config or not arguments.username:
listuserparser.print_usage()
else:
config_uri = arguments.config
setup_logging(config_uri)
try:
settings = get_appsettings(config_uri, 'factored')
except LookupError:
settings = get_appsettings(config_uri, 'main')
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
session = DBSession()
users = session.query(User).filter_by(
username=arguments.username).all()
if len(users) > 0:
user = users[0]
print 'username:%s, secret: %s' % (
user.username, user.secret)
print 'bar code url:', get_barcode_image(user.username,
user.secret,
settings['appname'])
else:
print '"%s" user not found' % arguments.username
开发者ID:zombified,项目名称:factored,代码行数:25,代码来源:users.py
示例13: main
def main(argv=sys.argv): #pragma NOCOVER
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
password = hashlib.md5('secret'.encode()).hexdigest()
user = User(name='distractionbike', password_md5=password)
DBSession.add(user)
user2 = User(name='otherguy', password_md5=password)
DBSession.add(user2)
journal = Journal(name='distractionbike')
DBSession.add(journal)
post = Post(journal_name='distractionbike',
title='First Post',
lede='Why do we love first posts so much?',
text='This is the <i>very first post</i>.')
DBSession.add(post)
post.add_comment(text='Yay!', user_id='ezra')
开发者ID:joelburton,项目名称:okarchive,代码行数:26,代码来源:initializedb.py
示例14: main
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
#Delete old data
Base.metadata.drop_all(engine)
#Create data
Base.metadata.create_all(engine)
with transaction.manager:
nb_sensors = 5
nb_readings = 500
minutes_between_readings = 10;
for i in range(nb_sensors):
sensor = Sensor(id=i+1,type='Moisture')
DBSession.add(sensor)
first_dttm = datetime.datetime.now()
for j in range(nb_readings,0,-1):
reading = Reading(
sensor_id=sensor.id,
timestamp=first_dttm - datetime.timedelta(minutes=minutes_between_readings*j),
value=random.randrange(1023)
)
DBSession.add(reading)
开发者ID:sebthauvette,项目名称:test,代码行数:30,代码来源:initializedb.py
示例15: main
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
connect_string = settings['sqlalchemy.url']\
.replace('DBUser', os.environ['DBUSER'])\
.replace('DBPassword', os.environ['DBPASSWORD'])
settings['sqlalchemy.url'] = connect_string
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
store_data = json.loads(open('emporium/scripts/store_data.json').
read())
suppliers = {}
for item in store_data['suppliers']:
supplier = Supplier(name=item['name'], tax_id=item['tax_id'])
suppliers[supplier.name] = supplier
DBSession.add(supplier)
for item in store_data['bargains']:
bargain = Bargain(
sku=item['sku'],
price=item['price'],
supplier=suppliers[item['supplier_name']]
)
bargain.info = item['info']
DBSession.add(bargain)
开发者ID:isthmian,项目名称:tb_python,代码行数:32,代码来源:initializedb.py
示例16: main
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
model = RasPi()
model.uuid = '11:22:33:44:55:66'
model.description = "Testing Pi"
model.url = "http://www.facebook.com"
model.orientation = 0
model.browser = True
model.lastseen = datetime.now()
DBSession.add(model)
tag = Tags()
tag.uuid = '11:22:33:44:55:66'
tag.tag = 'test'
DBSession.add(tag)
User = UserModel()
User.email = '[email protected]'
User.AccessLevel = 2
DBSession.add(User)
DBSession.flush()
开发者ID:PeterGrace,项目名称:pi_director,代码行数:31,代码来源:initializedb.py
示例17: main
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
user = User(email='[email protected]', password='test', admin=True)
DBSession.add(user)
site = Site(name='asd', key='80d621df066348e5938a469730ae0cab')
DBSession.add(site)
site.api_keys.append(SiteAPIKey(key='GIKfxIcIHPbM0uX9PrQ1To29Pb2on0pa'))
site.users.append(user)
aspect_ratio_1_1 = SiteAspectRatio(width=1, height=1)
aspect_ratio_3_1 = SiteAspectRatio(width=3, height=1)
site.aspect_ratios.append(aspect_ratio_1_1)
site.aspect_ratios.append(aspect_ratio_3_1)
from alembic.config import Config
from alembic import command
alembic_cfg = Config("alembic.ini")
command.stamp(alembic_cfg, "head")
开发者ID:matslindh,项目名称:kimochi,代码行数:28,代码来源:initializedb.py
示例18: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
setup_logging(global_config['__file__'])
config.add_renderer('jsonp', JSONP(param_name='callback'))
config.add_renderer('ujson', factory='app.renderers.UjsonRenderer')
config.add_static_view('static', 'static', cache_max_age=3600)
# initialise a connection to mongo on startup and store the client
# in the registry which will be injected into each request
conf = appConfig(config.registry.settings.get('app.config'))
config.registry.app_config = conf.app_config
config.registry.app_config['mongodb']['client'] = init_mongodb_connection(config.registry.app_config['mongodb'])
config.add_route('home', '/')
config.add_route('health-check', '/health-check')
config.add_route('network-stats', '/stats/{code}/{explore}')
config.add_route('network-build', '/network/{code}/{explore}')
config.add_route('network-build-status', '/network/{code}/{explore}/status')
config.add_route('entity-data', '/entity/{code}/data')
config.add_route('entity-build', '/entity/{code}/{id}')
config.add_route('entity-build-status', '/entity/{code}/{id}/status')
config.add_route('convert-graph', '/convert/{code}')
config.scan()
return config.make_wsgi_app()
开发者ID:MLR-au,项目名称:esrc-cnex,代码行数:28,代码来源:__init__.py
示例19: main
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
application_pdf_doc_type = DocumentTypes.add(
name="Adobe PDF",
description="Adobe PDF file",
mime_type="application/pdf",
)
system_owner = Users.add(
first="SYSTEM",
last="USERS",
email="[email protected]",
password="password",
)
default_scraper = Scrapers.add(
name="Default Scraper",
description="CivicDocs.IO loads with a single, defualt scraper.",
owner_id=system_owner.id,
)
print("DEFAULT SCRAPER ID:\r\n{0}\r\n".format(default_scraper.id))
开发者ID:civicdocs,项目名称:civicdocs.io,代码行数:31,代码来源:initializedb.py
示例20: main
def main(argv=sys.argv):
if len(argv) < 3:
usage(argv)
config_uri = argv[1]
json_path = argv[2]
options = parse_vars(argv[3:])
setup_logging(config_uri)
# Configure the application, so we can access the registry.
env = bootstrap(config_uri, options=options)
# Generate a DBSession using the sessionmaker:
DBSession = env['registry']['db_sessionmaker']()
# The SQLAlchemy engine is accessible as the session's bind.
engine = DBSession.bind
Base.metadata.create_all(engine)
json_data = json.load(open(json_path))
with transaction.manager:
for kitten_data in json_data:
kitten = Kitten(source_url=kitten_data['source_url'],
credit=kitten_data['credit'])
r = requests.get(kitten_data['download_url'])
if r.headers['content-type'] == 'image/jpeg':
kitten.file_extension = '.jpeg'
elif r.headers['content-type'] == 'image/png':
kitten.file_extension = '.png'
kitten.file_data = r.content
DBSession.add(kitten)
# Not strictly necessary, as everything gets unwound when main returns anyway.
# But it's a good habit to keep.
env['closer']()
开发者ID:inklesspen,项目名称:worstkittenwar-test_demo,代码行数:29,代码来源:initializedb.py
注:本文中的pyramid.paster.setup_logging函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论