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


Python common.parse_vars方法代碼示例

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


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

示例1: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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 = get_engine(settings)
    Base.metadata.create_all(engine)

    session_factory = get_session_factory(engine)

    with transaction.manager:
        dbsession = get_tm_session(session_factory, transaction.manager)

        model = MyModel(name='one', value=1)
        dbsession.add(model) 
開發者ID:peereesook,項目名稱:peecp,代碼行數:20,代碼來源:initializedb.py

示例2: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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 = get_engine(settings)
    Base.metadata.create_all(engine)

    session_factory = get_session_factory(engine)

    with transaction.manager:
        dbsession = get_tm_session(session_factory, transaction.manager)
        # model = MyModel(name='one', value=1)
        # dbsession.add(model) 
開發者ID:aptise,項目名稱:peter_sslers,代碼行數:20,代碼來源:initializedb.py

示例3: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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 = get_engine(settings)
    Base.metadata.create_all(engine)

    session_factory = get_session_factory(engine)

    with transaction.manager:
        dbsession = get_tm_session(session_factory, transaction.manager)

        model = Customer(name='sample',
                         email='[email protected]',
                         contract_type='One Time',
                         customer_type='Direct')

        dbsession.add(model) 
開發者ID:RaHus,項目名稱:assignment_aa,代碼行數:24,代碼來源:initializedb.py

示例4: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
def main(argv=sys.argv):
    """Initialize database, optionally with settings from config uri."""
    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)
    if not settings.get('sqlalchemy.url'):
        try:
            settings['sqlalchemy.url'] = os.environ['MARS_DATABASE_URL']
        except KeyError:
            print('Required MARS_DATABASE_URL not set in global os environ.')
            sys.exit()
        try:
            settings['nasa_api_key'] = os.environ['NASA_API_KEY']
        except KeyError:
            print('Required NASA_API_KEY not set in global os environment.')
            sys.exit()
    populate_rovers_cameras() 
開發者ID:mars-street-view,項目名稱:mars-street-view,代碼行數:22,代碼來源:initializedb.py

示例5: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
def main(argv=sys.argv):
    if len(argv) < 4:
        usage(argv)
    username = argv[1]
    password = argv[2]
    config_uri = argv[3]
    options = parse_vars(argv[4:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    settings.update(options)

    engine = get_engine(settings)
    Base.metadata.create_all(engine)

    session_factory = get_session_factory(engine)

    with transaction.manager:
        dbsession = get_tm_session(session_factory, transaction.manager)

        user = User(name=username, role='editor')
        user.set_password(password)
        dbsession.add(user) 
開發者ID:mrdrozdov,項目名稱:papersummarize,代碼行數:24,代碼來源:add_user.py

示例6: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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 = get_engine(settings)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)

    session_factory = get_session_factory(engine)

    with transaction.manager:
        dbsession = get_tm_session(session_factory, transaction.manager) 
開發者ID:Pysearch,項目名稱:Pysearch2.0,代碼行數:18,代碼來源:initializedb.py

示例7: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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) 
開發者ID:jmercouris,項目名稱:pyramid_starter,代碼行數:15,代碼來源:initializedb.py

示例8: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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['sqlalchemy.url'] = os.environ.get('DATABASE_URL')

    engine = get_engine(settings)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)

    session_factory = get_session_factory(engine)

    tweet_list = []
    models = []
    with transaction.manager:
        dbsession = get_tm_session(session_factory, transaction.manager)

        HERE = os.path.dirname(__file__)

        with open(os.path.join(HERE, '../models/realdonaldtrump_short.json'), 'r', encoding='utf-8') as json_file:
            json_data = json.load(json_file)

        for tweet_item in json_data:
            one_tweet = html.unescape(tweet_item['text'])
            new_tweet = Tweet(
                tweet=one_tweet
            )
            models.append(new_tweet)
            tweet_list.append(one_tweet)

        # fourgrams(tweet_list)
        dbsession.add_all(models)
    # gen_markov() 
開發者ID:jjfeore,項目名稱:turingtweets,代碼行數:38,代碼來源:initializedb.py

示例9: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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:
        DBSession.execute("ALTER TABLE users MODIFY id INT AUTO_INCREMENT")
        model = User(first_name='Bruce', last_name='Wayne',
                     created_at=datetime.datetime.now())
        DBSession.add(model) 
開發者ID:web-masons,項目名稱:pyramid-zappa-api-boilerplate,代碼行數:17,代碼來源:initializedb.py

示例10: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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 = get_engine(settings)
    Base.metadata.create_all(engine)

    session_factory = get_session_factory(engine) 
開發者ID:FuelRats,項目名稱:EDDB_JsonAPI,代碼行數:14,代碼來源:initializedb.py

示例11: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = dict()
    options.update(defaults)
    options.update(parse_vars(argv[2:]))
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)

    engine = get_engine(settings)
    Base.metadata.create_all(engine)

    session_factory = get_session_factory(engine)

    with transaction.manager:
        dbsession = get_tm_session(session_factory, transaction.manager)

        with open(settings['default.users']) as f:
            users = []
            for i, line in enumerate(f):
                line = line.strip().split(',')
                if i == 0:
                    header = line
                    continue
                u = {k: v for k, v in zip(header, line)}
                users.append(u)

        added = 0

        for u in users:
            name = u['name']
            if dbsession.query(User).filter_by(name=name).count() == 0:
                new_user = User(name=name, role='editor')
                new_user.set_password(u['password'])
                dbsession.add(new_user)
                added += 1

        print("Added {} users. Skipped {}.".format(added, len(users) - added)) 
開發者ID:mrdrozdov,項目名稱:papersummarize,代碼行數:41,代碼來源:initialize_userdata.py

示例12: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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["sqlalchemy.url"] = os.environ["DATABASE_URL"]

    engine = get_engine(settings)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)

    session_factory = get_session_factory(engine)

    with transaction.manager:
        dbsession = get_tm_session(session_factory, transaction.manager)

        model = Job(
            city='Seattle',
            title='Windows UWP/Phone Developer, Seattle WA',
            company='Interloc Solutions',
            description="""Our Products & Technology group in Seattle has an immediate need for an experienced Windows developer (Windows 10/Windows Surface) to support our Informer mobile solution products. This position will contribute heavily to product builds, so prior mobile application development experience is essential. Experience with Windows 10/Windows Surface 3+ years demonstrated experience in .NET and C# development Strong knowledge of the .NET framework, C#, with component extensions Prior mobile application development SQLite (highly desired, but not required) Full SDLC experience, including release to operations and production This is a great opportunity to work with our progressive mobile team!""",
            url="www.interlocsolutions.com",
            language='C#'
            )
        dbsession.add(model) 
開發者ID:OctoJobs,項目名稱:Octojobs,代碼行數:30,代碼來源:initializedb.py

示例13: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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) 
開發者ID:JonnoFTW,項目名稱:TonsleyLEDManager,代碼行數:12,代碼來源:initializedb.py

示例14: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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)
    init_social(get_settings(app_settings), Base, DBSession)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine) 
開發者ID:python-social-auth,項目名稱:social-examples,代碼行數:13,代碼來源:initializedb.py

示例15: main

# 需要導入模塊: from pyramid.scripts import common [as 別名]
# 或者: from pyramid.scripts.common import parse_vars [as 別名]
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 = get_engine(settings)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)

    # EVERYTHING BEFORE THIS POINT IS NEEDED TO SET UP YOUR TABLES
    # ============ NOTHING AFTER THIS POINT IS NECESSARY AT ALL =========

    session_factory = get_session_factory(engine)

    with transaction.manager:
        dbsession = get_tm_session(session_factory, transaction.manager)

        expense = Expense(
            title='Really Expensive Pizza',
            price=5000,
            paid_date=datetime.datetime.now(),
            description="I know it's expensive, but dammit I want gold shavings on my pizza"
        )
        dbsession.add(expense) 
開發者ID:codefellows,項目名稱:expense_tracker_401d6,代碼行數:29,代碼來源:initializedb.py


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