当前位置: 首页>>代码示例>>Python>>正文


Python GraphDatabase.destroy方法代码示例

本文整理汇总了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')
开发者ID:MaxBo,项目名称:graphserver,代码行数:79,代码来源:process.py


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