本文整理匯總了Python中neubot.database.DATABASE.close方法的典型用法代碼示例。如果您正苦於以下問題:Python DATABASE.close方法的具體用法?Python DATABASE.close怎麽用?Python DATABASE.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類neubot.database.DATABASE
的用法示例。
在下文中一共展示了DATABASE.close方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from neubot.database import DATABASE [as 別名]
# 或者: from neubot.database.DATABASE import close [as 別名]
def main(args):
""" Main function """
if not system.has_enough_privs():
sys.exit('FATAL: you must be root')
common.main("agent", "Run in background, periodically run tests", args)
conf = CONFIG.copy()
privacy.complain_if_needed()
BACKEND.use_backend("neubot")
BACKEND.datadir_init()
# FIXME We're ignoring agent.api.{address,port} that are now
# deprecated and should be removed soon.
background_api.start_api()
if conf["agent.daemonize"]:
LOG.redirect()
system.go_background()
if conf["agent.use_syslog"]:
LOG.redirect()
#
# When we run as an agent we also save logs into
# the database, to easily access and show them via
# the web user interface.
#
LOG.use_database()
logging.info('%s for POSIX: starting up', utils_version.PRODUCT)
system.drop_privileges()
if os.getuid() == 0 or os.geteuid() == 0:
logging.error('agent: still running as root')
os._exit(1)
if conf["agent.rendezvous"]:
BACKGROUND_RENDEZVOUS.start()
POLLER.loop()
logging.info('%s for POSIX: shutting down', utils_version.PRODUCT)
LOG.writeback()
#
# Make sure that we do not leave the database
# in an inconsistent state.
#
DATABASE.close()
示例2: main
# 需要導入模塊: from neubot.database import DATABASE [as 別名]
# 或者: from neubot.database.DATABASE import close [as 別名]
def main(args):
''' Main() function '''
try:
options, arguments = getopt.getopt(args[1:], '')
except getopt.error:
sys.exit('usage: neubot background_win32')
if options or arguments:
sys.exit('usage: neubot background_win32')
# Read settings from database
CONFIG.merge_database(DATABASE.connection())
BACKEND.use_backend("neubot")
BACKEND.datadir_init()
#
# Save logs into the database, to easily access
# and show them via the web user interface.
#
LOG.use_database()
logging.info('%s for Windows: starting up', utils_version.PRODUCT)
# Complain if privacy settings are not OK
privacy.complain_if_needed()
background_api.start_api()
BACKGROUND_RENDEZVOUS.start()
__start_updater()
POLLER.loop()
logging.info('%s for Windows: shutting down', utils_version.PRODUCT)
LOG.writeback()
#
# Make sure that we do not leave the database
# in an inconsistent state.
#
DATABASE.close()