本文整理汇总了Python中graphserver.graphdb.GraphDatabase.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python GraphDatabase.destroy方法的具体用法?Python GraphDatabase.destroy怎么用?Python GraphDatabase.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphserver.graphdb.GraphDatabase
的用法示例。
在下文中一共展示了GraphDatabase.destroy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import destroy [as 别名]
def main():
from optparse import OptionParser
usage = """Usage: python gst_process <configuration file>
See the documentation for layout of the config file."""
parser = OptionParser(usage=usage)
parser.add_option("-b", "--import-base", action="store_true", help="imports GTFS and OSM data into the database", dest="import_base", default=False)
parser.add_option("-r", "--import-routes", action="store_true", help="imports routing data into the database", dest="import_routes", default=False)
parser.add_option("-i", "--import-all", action="store_true", help="imports GTFS, OSM and routing data into the database", dest="import_all", default=False)
parser.add_option("-c", "--calculate", action="store_true", help="calculates shortest paths", dest="calculate", default=False)
parser.add_option("-e", "--export", action="store_true", help="exports the calculted paths as CSV-files", dest="export", default=False)
(options, args) = parser.parse_args()
if DEBUG: print(options)
if len(args) != 1:
parser.print_help()
exit(-1)
try:
configuration, psql_connect_string = read_config(args[0])
except:
print(colored('ERROR: failed reading the configuration file', 'red'))
if DEBUG: raise
parser.print_help()
exit(-1)
valide = validate_input(configuration, psql_connect_string, options)
if not valide:
parser.print_help()
exit(-1)
graph = None
if options.import_base or options.import_all:
print('Importing base data...')
build_base_data(psql_connect_string, configuration['osm-data'], configuration['transit-feed'])
if options.import_routes or options.import_all:
print('Importing routing data...')
graph = GraphDatabase(psql_connect_string).incarnate()
build_route_data(graph, psql_connect_string, configuration['times'], configuration['points'], configuration['routes'])
if options.calculate:
print('Calculating shortest paths...')
# only create tables if some importing was done
create_tables = options.import_all or options.import_base or options.import_routes
if not graph: graph = GraphDatabase(psql_connect_string).incarnate()
start = time.time()
calculate_routes(graph, psql_connect_string, configuration, num_processes=configuration['parallel-calculations'])
cprint('total calculation time: %s' % utils.seconds_time_string(time.time() - start), attrs=['bold'])
try:
graph.destroy()
except:
pass
if options.export:
print('Exporting paths...')
export_results(psql_connect_string, configuration['results'], configuration['result-details'])
print('DONE')