本文整理汇总了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()
示例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
示例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()
示例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()
示例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()
示例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()
示例7: db_teardown
def db_teardown():
return db.db_teardown()
示例8: _teardown
def _teardown():
db_teardown()
示例9: db_teardown
def db_teardown():
"""
Disconnects from the database.
"""
return db.db_teardown()
示例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