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

Python db.db_teardown函数代码示例

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

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



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

示例1: main

def main():
    _monkey_patch()

    cli_opts = [
        cfg.StrOpt('timestamp', default=None,
                   help='Will delete data older than ' +
                   'this timestamp. (default 48 hours). ' +
                   'Example value: 2015-03-13T19:01:27.255542Z'),
        cfg.StrOpt('action-ref', default='',
                   help='action-ref to delete executions for.')
    ]
    do_register_cli_opts(cli_opts)
    config.parse_args()

    # Get config values
    timestamp = cfg.CONF.timestamp
    action_ref = cfg.CONF.action_ref
    username = cfg.CONF.database.username if hasattr(cfg.CONF.database, 'username') else None
    password = cfg.CONF.database.password if hasattr(cfg.CONF.database, 'password') else None

    # Connect to db.
    db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port,
             username=username, password=password)

    if not timestamp:
        now = datetime.now()
        timestamp = now - timedelta(days=DEFAULT_TIMEDELTA_DAYS)
    else:
        timestamp = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')

    # Purge models.
    _purge_executions(timestamp=timestamp, action_ref=action_ref)

    # Disconnect from db.
    db_teardown()
开发者ID:Kailashkatheth1,项目名称:st2,代码行数:35,代码来源:purge_executions.py


示例2: _drop_db

    def _drop_db(cls):
        cls._drop_collections()

        if cls.db_connection is not None:
            cls.db_connection.drop_database(cfg.CONF.database.db_name)

        db_teardown()
        cls.db_connection = None
开发者ID:nzlosh,项目名称:st2,代码行数:8,代码来源:base.py


示例3: main

def main():
    _parse_config()
    if CONF.verbose:
        _setup_logging()
        output = logging.getLogger(__name__).info
    else:
        output = pprint.pprint
    _setup_db()
    _refire_trigger_instance(trigger_instance_id=CONF.trigger_instance_id,
                             log_=logging.getLogger(__name__))
    output('Trigger re-fired')
    db_teardown()
开发者ID:Kailashkatheth1,项目名称:st2,代码行数:12,代码来源:trigger_re_fire.py


示例4: main

def main():
    config.parse_args()

    # Connect to db.
    username = cfg.CONF.database.username if hasattr(cfg.CONF.database, 'username') else None
    password = cfg.CONF.database.password if hasattr(cfg.CONF.database, 'password') else None
    db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port,
             username=username, password=password)

    # Migrate rules.
    migrate_rules()

    # Disconnect from db.
    db_teardown()
开发者ID:Kailashkatheth1,项目名称:st2,代码行数:14,代码来源:migrate_rules_to_include_pack.py


示例5: main

def main():
    _monkey_patch()

    cli_opts = [
        cfg.BoolOpt("sensors", default=False, help="diff sensor alone."),
        cfg.BoolOpt("actions", default=False, help="diff actions alone."),
        cfg.BoolOpt("rules", default=False, help="diff rules alone."),
        cfg.BoolOpt("all", default=False, help="diff sensors, actions and rules."),
        cfg.BoolOpt("verbose", default=False),
        cfg.BoolOpt(
            "simple",
            default=False,
            help="In simple mode, tool only tells you if content is missing."
            + "It doesn't show you content diff between disk and db.",
        ),
        cfg.StrOpt("pack-dir", default=None, help="Path to specific pack to diff."),
    ]
    do_register_cli_opts(cli_opts)
    config.parse_args()

    username = cfg.CONF.database.username if hasattr(cfg.CONF.database, "username") else None
    password = cfg.CONF.database.password if hasattr(cfg.CONF.database, "password") else None

    # Connect to db.
    db_setup(
        cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port, username=username, password=password
    )

    # Diff content
    pack_dir = cfg.CONF.pack_dir or None
    content_diff = not cfg.CONF.simple

    if cfg.CONF.all:
        _diff_sensors(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        _diff_actions(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        _diff_rules(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        return

    if cfg.CONF.sensors:
        _diff_sensors(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    if cfg.CONF.actions:
        _diff_actions(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    if cfg.CONF.rules:
        _diff_rules(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    # Disconnect from db.
    db_teardown()
开发者ID:azamsheriff,项目名称:st2,代码行数:49,代码来源:diff-db-disk.py


示例6: main

def main():
    monkey_patch()

    cli_opts = [
        cfg.BoolOpt('sensors', default=False,
                    help='diff sensor alone.'),
        cfg.BoolOpt('actions', default=False,
                    help='diff actions alone.'),
        cfg.BoolOpt('rules', default=False,
                    help='diff rules alone.'),
        cfg.BoolOpt('all', default=False,
                    help='diff sensors, actions and rules.'),
        cfg.BoolOpt('verbose', default=False),
        cfg.BoolOpt('simple', default=False,
                    help='In simple mode, tool only tells you if content is missing.' +
                         'It doesn\'t show you content diff between disk and db.'),
        cfg.StrOpt('pack-dir', default=None, help='Path to specific pack to diff.')
    ]
    do_register_cli_opts(cli_opts)
    config.parse_args()

    username = cfg.CONF.database.username if hasattr(cfg.CONF.database, 'username') else None
    password = cfg.CONF.database.password if hasattr(cfg.CONF.database, 'password') else None

    # Connect to db.
    db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port,
             username=username, password=password)

    # Diff content
    pack_dir = cfg.CONF.pack_dir or None
    content_diff = not cfg.CONF.simple

    if cfg.CONF.all:
        _diff_sensors(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        _diff_actions(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        _diff_rules(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        return

    if cfg.CONF.sensors:
        _diff_sensors(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    if cfg.CONF.actions:
        _diff_actions(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    if cfg.CONF.rules:
        _diff_rules(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    # Disconnect from db.
    db_teardown()
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:49,代码来源:diff-db-disk.py


示例7: db_teardown

def db_teardown():
    return db.db_teardown()
开发者ID:jspittman,项目名称:st2,代码行数:2,代码来源:service_setup.py


示例8: _teardown

def _teardown():
    db_teardown()
开发者ID:Kailashkatheth1,项目名称:st2,代码行数:2,代码来源:rulesengine.py


示例9: db_teardown

def db_teardown():
    """
    Disconnects from the database.
    """
    return db.db_teardown()
开发者ID:lyandut,项目名称:st2,代码行数:5,代码来源:database_setup.py


示例10: tearDownClass

 def tearDownClass(cls):
     cls.drop_collections()
     if DbTestCase.db_connection is not None:
         DbTestCase.db_connection.drop_database(cfg.CONF.database.db_name)
     db_teardown()
     DbTestCase.db_connection = None
开发者ID:bjoernbessert,项目名称:st2,代码行数:6,代码来源:base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python action.ActionDB类代码示例发布时间:2022-05-27
下一篇:
Python db.db_setup函数代码示例发布时间: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