本文整理汇总了Python中neubot.database.DATABASE.set_path方法的典型用法代码示例。如果您正苦于以下问题:Python DATABASE.set_path方法的具体用法?Python DATABASE.set_path怎么用?Python DATABASE.set_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neubot.database.DATABASE
的用法示例。
在下文中一共展示了DATABASE.set_path方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from neubot.database import DATABASE [as 别名]
# 或者: from neubot.database.DATABASE import set_path [as 别名]
def main(args):
''' Main function '''
try:
options, arguments = getopt.getopt(args[1:], 'f:nv')
except getopt.error:
sys.exit(USAGE)
database_path = system.get_default_database_path()
auto_discover = True
for name, value in options:
if name == '-f':
database_path = value
elif name == '-n':
auto_discover = False
elif name == '-v':
CONFIG['verbose'] = 1
if len(arguments) != 1 and len(arguments) != 2:
sys.exit(USAGE)
DATABASE.set_path(database_path)
CONFIG.merge_database(DATABASE.connection())
if len(arguments) == 2:
RUNNER_TESTS.update({arguments[0]: [arguments[1]]})
ctx = {'uri': arguments[1]}
else:
ctx = None
deferred = Deferred()
deferred.add_callback(lambda param: None)
RUNNER_CORE.run(arguments[0], deferred, auto_discover, ctx)
POLLER.loop()
示例2: main
# 需要导入模块: from neubot.database import DATABASE [as 别名]
# 或者: from neubot.database.DATABASE import set_path [as 别名]
def main(args):
''' Main function '''
try:
options, arguments = getopt.getopt(args[1:], 'f:n')
except getopt.error:
sys.exit('Usage: %s [-n] [-f database] test [negotiate_uri]' % args[0])
if len(arguments) != 1 and len(arguments) != 2:
sys.exit('Usage: %s [-n] [-f database] test [negotiate_uri]' % args[0])
database_path = system.get_default_database_path()
auto_rendezvous = True
for name, value in options:
if name == '-f':
database_path = value
elif name == '-n':
auto_rendezvous = False
DATABASE.set_path(database_path)
CONFIG.merge_database(DATABASE.connection())
if len(arguments) == 2:
RUNNER_TESTS.update({arguments[0]: [arguments[1]]})
ctx = {'uri': arguments[1]}
else:
ctx = None
RUNNER_CORE.run(arguments[0], lambda *args: None, auto_rendezvous, ctx)
POLLER.loop()
示例3: __create_empty
# 需要导入模块: from neubot.database import DATABASE [as 别名]
# 或者: from neubot.database.DATABASE import set_path [as 别名]
def __create_empty(path):
'''
This functions creates an empty Neubot database at @path,
jusing Neubot internals to do that.
'''
DATABASE.set_path(path)
connection = DATABASE.connection()
connection.commit()
connection.close()
示例4: main
# 需要导入模块: from neubot.database import DATABASE [as 别名]
# 或者: from neubot.database.DATABASE import set_path [as 别名]
def main(name, descr, args):
Eflag = False
lflag = False
try:
options, arguments = getopt.getopt(args[1:], "D:Ef:lVv", ["help"])
except getopt.GetoptError:
write_help(sys.stderr, name, descr)
sys.exit(1)
if arguments:
write_help(sys.stderr, name, descr)
sys.exit(1)
verbose = 0
for key, value in options:
if key == "-D":
# No shortcuts because it grows too confusing
CONFIG.register_property(value)
elif key == "-E":
Eflag = True
elif key == "-f":
DATABASE.set_path(value)
elif key == "--help":
write_help(sys.stdout, name, descr)
sys.exit(0)
elif key == "-l":
lflag = True
elif key == "-V":
sys.stdout.write(VERSION + "\n")
sys.exit(0)
elif key == "-v":
verbose = 1
DATABASE.connect()
CONFIG.merge_database(DATABASE.connection())
if not Eflag:
CONFIG.merge_environ()
CONFIG.merge_properties()
# Apply the setting after we've read database and environment
if verbose:
CONFIG['verbose'] = 1
if lflag:
CONFIG.print_descriptions(sys.stdout)
sys.exit(0)
示例5: main
# 需要导入模块: from neubot.database import DATABASE [as 别名]
# 或者: from neubot.database.DATABASE import set_path [as 别名]
def main(args):
try:
options, arguments = getopt.getopt(args[1:], "f:")
except getopt.GetoptError:
sys.stderr.write(USAGE)
sys.exit(1)
for key, value in options:
if key == "-f":
DATABASE.set_path(value)
DATABASE.connect()
if not arguments:
sys.stdout.write('%s\n' % DATABASE.path)
elif arguments[0] == "regen_uuid":
if DATABASE.readonly:
sys.exit('ERROR: readonly database')
table_config.update(DATABASE.connection(),
{"uuid": utils.get_uuid()}.iteritems())
elif arguments[0] == "prune":
if DATABASE.readonly:
sys.exit('ERROR: readonly database')
table_speedtest.prune(DATABASE.connection())
elif arguments[0] == "delete_all":
if DATABASE.readonly:
sys.exit('ERROR: readonly database')
table_speedtest.prune(DATABASE.connection(), until=utils.timestamp())
DATABASE.connection().execute("VACUUM;")
elif arguments[0] in ("show", "dump"):
d = { "config": table_config.dictionarize(DATABASE.connection()),
"speedtest": table_speedtest.listify(DATABASE.connection()) }
if arguments[0] == "show":
compat.json.dump(d, sys.stdout, indent=4)
elif arguments[0] == "dump":
compat.json.dump(d, sys.stdout)
else:
sys.stdout.write(USAGE)
sys.exit(0)
示例6: __main
# 需要导入模块: from neubot.database import DATABASE [as 别名]
# 或者: from neubot.database.DATABASE import set_path [as 别名]
def __main(args):
''' Initialize privacy settings '''
try:
options, arguments = getopt.getopt(args[1:], 'D:f:Pt')
except getopt.error:
sys.exit(USAGE)
if arguments:
sys.exit(USAGE)
settings = {}
database_path = system.get_default_database_path()
pflag = False
testmode = False
for name, value in options:
if name == '-D':
name, value = value.split('=', 1)
if not name.startswith("privacy."):
name = "privacy." + name
settings[name] = value
elif name == '-f':
database_path = value
elif name == '-P':
pflag = True
elif name == '-t':
testmode = True
if pflag:
sys.exit(print_policy())
DATABASE.set_path(database_path)
connection = DATABASE.connection()
if testmode:
sys.exit(test_settings(connection))
if settings:
if DATABASE.readonly:
sys.exit('ERROR: readonly database')
sys.exit(update_settings(connection, settings))
sys.exit(print_settings(connection, database_path))
示例7: main
# 需要导入模块: from neubot.database import DATABASE [as 别名]
# 或者: from neubot.database.DATABASE import set_path [as 别名]
def main(args):
''' Main function '''
try:
options, arguments = getopt.getopt(args[1:], 'f')
except getopt.error:
sys.exit('Usage: %s [-f database] test negotiate_uri' % args[0])
if len(arguments) != 2:
sys.exit('Usage: %s [-f database] test negotiate_uri' % args[0])
database_path = system.get_default_database_path()
for name, value in options:
if name == '-f':
database_path = value
DATABASE.set_path(database_path)
CONFIG.merge_database(DATABASE.connection())
run(arguments[0], arguments[1], lambda: None)
POLLER.loop()
示例8: main
# 需要导入模块: from neubot.database import DATABASE [as 别名]
# 或者: from neubot.database.DATABASE import set_path [as 别名]
def main():
Sflag = False
options, arguments = getopt.getopt(sys.argv[1:], "S")
for key, value in options:
if key == "-S":
Sflag = True
# don't clobber my local database
DATABASE.set_path(":memory:")
DATABASE.connect()
if Sflag:
server = ServerSpeedtest(POLLER)
server.configure({"speedtest.negotiate.daemonize": False})
server.listen(("127.0.0.1", 8080))
else:
speedtest_again()
POLLER.loop()