• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python paster.get_appsettings函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyramid.paster.get_appsettings函数的典型用法代码示例。如果您正苦于以下问题:Python get_appsettings函数的具体用法?Python get_appsettings怎么用?Python get_appsettings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_appsettings函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        from sqlalchemy import create_engine

        engine = create_engine('sqlite://')
        try:
            # nosetest vs pycharm test runner, lets flex
            settings = get_appsettings('../tests.ini')
        except:
            settings = get_appsettings('tests.ini')
        self.config = testing.setUp(settings=settings)
        DBSession.configure(bind=engine)
        Base.metadata.create_all(engine)
        with transaction.manager:
            self.founder = User(username='founder', password='apass', email='[email protected]', activated=True,
                                active=True, firstname='founder1_firstname', lastname='founder1_lastname',
                                city='founder1_city', state='founder1_state', title='founder1_title')
            self.company = BaseCompany(name='testcompany', founded=2015, description='company_desc',
                                       startup_teamdescription='company_team_desc', website='company_website',
                                       linkedin='company_linkedin', twitterhandle='company_twitter',
                                       angelcoprofile='company_angellist')
            self.admin = User(username='admin', password='apass', email=settings.get('admin_mail'), activated=False,
                              groups='admin')
            DBSession.add(self.founder)
            DBSession.add(self.company)
            DBSession.add(self.admin)
            for k, v in Settings.settings.iteritems():
                if type(v) == dict:
                    DBSession.add(Settings(key=unicode(k), value=unicode(v['value'])))
                else:
                    if isinstance(v, basestring) and v.startswith('app_config.'):
                        v = settings.get(v[len('app_config.'):])
                    DBSession.add(Settings(key=unicode(k), value=unicode(v)))
            DBSession.flush()
            self.user_id = self.founder.user_id
        self.founders_created = []
开发者ID:umar93132,项目名称:portal,代码行数:35,代码来源:tests.py


示例2: 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


示例3: init

def init():
    global _inited
    if _inited:
        return
    rootdir = dirname(dirname(dirname(realpath(__file__))))
    if exists(join(rootdir, 'local.ini')):
        settings = get_appsettings(join(rootdir, 'local.ini'))
    else:
        settings = get_appsettings(join(rootdir, 'development.ini'))
    configure(settings)
    _inited = True
开发者ID:bastnic,项目名称:assembl,代码行数:11,代码来源:__init__.py


示例4: main

def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    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)
    Base.metadata.create_all(engine)
开发者ID:wildcardcorp,项目名称:factored,代码行数:12,代码来源:initializedb.py


示例5: test_the_test_2

    def test_the_test_2(self):
        """ Confirm that the .ini file has the expected shared secret in it.
            Confirm that I can patch the .ini file to provide an app that uses
            the secret from secret_file
        """
        settings1 = get_appsettings(test_ini)
        self.assertEqual(settings1['agent.secret'], 'sharedsecret')

        with patch('builtins.open',
                   filter_open(TestAgentAPI._ini_filter, pattern=r'test\.ini$', verbose=False)):
            settings2 = get_appsettings(test_ini)

        self.assertEqual(settings2.get('agent.secret', 'None'), 'None')
        self.assertEqual(settings2.get('agent.secretfile', 'None'), secret_file)
开发者ID:cedadev,项目名称:eos-db,代码行数:14,代码来源:test_agent_api.py


示例6: setUpClass

    def setUpClass(cls):
        try:
            cls.settings = get_appsettings('test.local.ini')
        except FileNotFoundError:
            cls.settings = get_appsettings('test.ini')

        cls.engine = engine_from_config(cls.settings, 'sqlalchemy.')
        cls.conn = cls.engine.connect()

        cls.settings.setdefault('mako.directories', 'pizzavolus:templates/')
        cls.settings.setdefault('mako.imports', '''
            from pizzavolus import date_fmt
            from datetime import datetime
        ''')
开发者ID:0xa,项目名称:PizzaVolus,代码行数:14,代码来源:__init__.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, options=options)

    settings = get_appsettings(config_uri, options=options)
    if 'DATABASE_URL' in os.environ:
        settings['sqlalchemy.url'] = os.environ['DATABASE_URL']

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
开发者ID:palindromed,项目名称:personal-site,代码行数:15,代码来源:initializedb.py


示例8: main

def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)

    config_uri = argv[1]

    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    Session = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
    Session.configure(bind=engine)
    db = Session()

    with transaction.manager:
        testing = db.query(Update).filter_by(status=UpdateStatus.testing,
                                             request=None)
        for update in testing:
            # If this release does not have any testing requirements, skip it
            if not update.release.mandatory_days_in_testing:
                print('%s doesn\'t have mandatory days in testing' % update.release.name)
                continue
            # If this has already met testing requirements, skip it
            if update.met_testing_requirements:
                continue
            if update.meets_testing_requirements:
                print('%s now meets testing requirements' % update.title)
                text = config.get('testing_approval_msg') % update.days_in_testing
                update.comment(db, text, author='bodhi')
开发者ID:Debjeeti20,项目名称:bodhi,代码行数:27,代码来源:approve_testing.py


示例9: 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)

        message1 = Message(msgid = 'c1', content = 'yoloswag1', timestamp = '5.11.2015')
        message2 = Message(msgid = 'c2', content = 'yoloswag2', timestamp = '5.11.2015')
        DBSession.add(message1)
        DBSession.add(message2)

        delmessage = DelMessage(msgid = 'c1', timestamp = '6.11.2015')
        DBSession.add(delmessage)

        DBSession.delete(model)
        DBSession.delete(message1)
        DBSession.delete(message2)
        DBSession.delete(delmessage)
开发者ID:citlab,项目名称:optimistic-failover,代码行数:27,代码来源:initializedb.py


示例10: setUp

    def setUp(self):
        """Set up the settings and the session"""

        self.settings = get_appsettings('configs/tests.ini', name='main')
        self.settings['askomics.upload_user_data_method'] = 'insert'
        self.request = testing.DummyRequest()
        self.request.session['username'] = 'jdoe'
        self.request.session['group'] = 'base'
        self.request.session['admin'] = False
        self.request.session['blocked'] = True

        # Files
        # Create the user dir if not exist
        self.temp_directory = self.settings['askomics.files_dir'] + '/upload/' + self.request.session['username']
        if not os.path.isdir(self.temp_directory):
            os.makedirs(self.temp_directory)
        # Set the upload dir
        self.request.session['upload_directory'] = self.temp_directory
        # Copy files if directory is empty
        if not os.listdir(self.temp_directory):
            files = ['people.tsv', 'instruments.tsv', 'play_instrument.tsv', 'transcript.tsv', 'qtl.tsv', 'small_data.gff3', 'turtle_data.ttl', 'bed_example.bed']
            for file in files:
                src = os.path.join(os.path.dirname(__file__), "..", "test-data") + '/' + file
                dst = self.request.session['upload_directory'] + '/' + file
                copyfile(src, dst)
开发者ID:askomics,项目名称:askomics,代码行数:25,代码来源:source_file_bed_test.py


示例11: 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


示例12: update

def update(argv=sys.argv):
    """
    Download the GeoIP database from the URL provided under the config key
    `geoip.city.source` and save it under the path provided by the config key
    `geoip.city.destination`.

    """
    if len(argv) != 2:
        usage(argv)

    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    source = settings['geoip.city.source']
    output = settings['geoip.city.destination']
    log.info("Downloading %s...", source)
    response = requests.get(source)
    log.info("Downloading done.")

    compressed = gzip.GzipFile(fileobj=StringIO(response.content))

    with open(output, "wb") as f:
        log.info("Writting to %s...", output)
        f.write(compressed.read())
        log.info("Writting done.")
开发者ID:dobrite,项目名称:notaliens.com,代码行数:25,代码来源:geoip.py


示例13: 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)
	cache.cache = cache.configure_cache(settings)

	config = Configurator(
		settings=settings,
		root_factory=RootFactory,
		locale_negotiator=locale_neg
	)
	config.add_route_predicate('vhost', VHostPredicate)
	config.add_view_predicate('vhost', VHostPredicate)

	mmgr = config.registry.getUtility(IModuleManager)
	mmgr.load('core')
	mmgr.load_enabled()

	rts = rt.configure(mmgr, config.registry)
	app = rts.app()
	rt.run(rts, app)
开发者ID:baloon11,项目名称:npui,代码行数:25,代码来源:rtd.py


示例14: run

    def run(self, argv):
        if len(argv) < 3:
            self.usage(argv)
        config_uri = argv[1]
        fromDate = argv[2]
        options = parse_vars(argv[3:])
        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:
            url = 'https://servicesenligne2.ville.montreal.qc.ca/api/infoneige/InfoneigeWebService?wsdl'
            client = Client(url)
            planification_request = client.factory.create('getPlanificationsForDate')
            planification_request.fromDate = fromDate
            planification_request.tokenString =  'ug33-b81ab488-c335-4021-9c52-26d6b8523301-e7aa002b-0d9d-4b5c-81ef-b012979cdafb-dab06588-1962-4b16-9942-a18054094f60-a4186179-d555-4fed-b35f-ec0c74da97a3-aa3b3766-4d26-42f0-888a-a6569a1dd745'
            response = client.service.GetPlanificationsForDate(planification_request)
            if response['responseStatus'] == 0:
                log.info('%s plannings returned', response['planifications']['count'])
                cartodb_client = CartoDBOAuth(settings['cartodb.key'], settings['cartodb.secret'], settings['cartodb.user'], settings['cartodb.password'], settings['cartodb.domain'])

                for result in response['planifications']['planification']:
                    '''
                    street_side_status = StreetSideHistory(
                        municipality_id = result['munid'],
                        street_side_id = result['coteRueId'],
                        state = result['etatDeneig'],
                        observed_on = result['dateMaj'],
                        )
                    DBSession.merge(street_side_status)
                    '''
                    if any(val in result for val in ['dateDebutPlanif', 'dateFinPlanif', 'dateDebutReplanif', 'dateFinReplanif']):
                        try:
                            result['dateDebutReplanif']
                        except AttributeError:
                            result['dateDebutReplanif'] = None
                        try:
                            result['dateFinReplanif']
                        except AttributeError:
                            result['dateFinReplanif'] = None
                        '''
                        print result
                        planning = Planning(
                            municipality_id = result['munid'],
                            street_side_id = result['coteRueId'],
                            planned_start_date = result['dateDebutPlanif'],
                            planned_end_date = result['dateFinPlanif'],
                            replanned_start_date = result['dateDebutReplanif'],
                            replanned_end_date = result['dateFinReplanif'],
                            modified_on = result['dateMaj'],
                            )
                        DBSession.merge(planning)
                        '''
                    #transaction.manager.commit()
                    cartodb_client.sql('UPDATE cote SET etat = %(etat)s WHERE cote_rue_id = %(cote_rue_id)d' %
                        {"etat": result['etatDeneig'], "cote_rue_id": result['coteRueId']})
            else:
                log.info('Status %s: %s', response['responseStatus'], response['responseDesc'])
开发者ID:VilledeMontreal,项目名称:DefiInfoNeige-Gagnant3,代码行数:60,代码来源:soap_client.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)
    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


示例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.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


示例17: ini_settings

def ini_settings(request, test_config_path) -> dict:
    """Load INI settings for test run from py.test command line.

    Example:

         py.test yourpackage -s --ini=test.ini


    :return: A dictionary representing the key/value pairs in an ``app`` section within the file represented by ``config_uri``
    """

    # This enables our INI inclusion mechanism
    # TODO: Don't use get_appsettings() from paster, but create a INI includer compatible version
    from websauna.utils.configincluder import monkey_patch_paster_config_parser
    monkey_patch_paster_config_parser()

    # Setup Python logging from the INI
    setup_logging(test_config_path)

    # Read [app] section
    config = get_appsettings(test_config_path)

    # To pass the config filename itself forward
    config["_ini_file"] = test_config_path

    return config
开发者ID:websauna,项目名称:websauna,代码行数:26,代码来源:fixtures.py


示例18: 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:
        user = User(username='admin', password='apass', email=settings.get('admin_mail'), activated=True,
                    groups='admin')
        DBSession.add(user)
        DBSession.flush()
        for k, v in Settings.settings.iteritems():
            if type(v) == dict:
                DBSession.add(Settings(key=unicode(k), value=unicode(v['value'])))
            else:
                if isinstance(v, basestring) and v.startswith('app_config.'):
                    v = settings.get(v[len('app_config.'):])
                DBSession.add(Settings(key=unicode(k), value=unicode(v)))

        DBSession.flush()
开发者ID:RaHus,项目名称:portal,代码行数:25,代码来源:initializedb.py


示例19: main

def main(argv=sys.argv):
    config_uri = argv[1]
    argv = argv[2:]

    parser = optparse.OptionParser(usage=USAGE, description=DESCRIPTION)
    parser.add_option('-t', '--title', dest='title', type='string')
    parser.add_option('-s', '--slug', dest='slug', type='string')

    options, args = parser.parse_args(argv)
    if options.title is None:
        parser.error('You must provide at least --title')

    slug = options.slug
    if slug is None:
        slug = options.title.lower().replace(' ', '_')

    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    with transaction.manager:
        board = Board(title=options.title, slug=slug)
        DBSession.add(board)
        DBSession.flush()
        print(("Successfully added %s (slug: %s)" %
               (board.title, board.slug)))
开发者ID:PNNutkung,项目名称:fanboi2,代码行数:26,代码来源:create_board.py


示例20: 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



注:本文中的pyramid.paster.get_appsettings函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python paster.setup_logging函数代码示例发布时间:2022-05-27
下一篇:
Python paster.get_app函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap