from bbl import BBL from bbl_query import BBLQuery from multiprocessing import Process, Pool import pickle import traceback import sys def query_bbl(block): buildings = set() bbls = bblquery.get_bbls(BBL(borough, block, 1)) for idx, bbl in enumerate(sorted(bbls)): print "Running", idx, "of", len(bbls), "..." try: building = bblquery.query_bbl(bbl) except: traceback.print_exc() print "Error" + 10 + "!" buildings.add(building) pickle.dump(buildings, open('blocks/' + str(block), 'w')) try: borough = int(sys.argv[1]) except: borough = 3 bblquery = BBLQuery('localhost', 40002) blocks = bblquery.get_blocks(borough) pool = Pool(processes=32) pool.map(query_bbl, blocks)
#!/usr/bin/python import sys from bbl import BBL from bbl_query import BBLQuery try: borough = int(sys.argv[1]) block = int(sys.argv[2]) lot = int(sys.argv[3]) except: borough = 3 block = 3430 lot = 41 # Or 55, 53 #Another example: 1 1654 27 bblquery = BBLQuery('localhost', 40002) lots = list([lot]) for idx, lot in enumerate(sorted(lots)): print "Running", idx, "of", len(lots), "..." building = bblquery.query_bbl(BBL(borough, block, lot)) print building
#!/usr/bin/python import sys from bbl import BBL from bbl_query import BBLQuery try: borough = int(sys.argv[1]) block = int(sys.argv[2]) lot = int(sys.argv[3]) except: borough = 4 block = 3631 lot = 57 # Or 55, 53 #Another example: 1 1654 27 bblquery = BBLQuery('localhost', 40000) bbls = bblquery.get_bbls(BBL(borough, block, lot)) for idx, bbl in enumerate(sorted(bbls)): print "Running", idx, "of", len(bbls), "..." bblquery.query_bbl(bbl)