plane.time = sample_timestamp - plane.seen plane.reporter = args.reporter if args.db_conf and dbconn: plane.logToDB(dbconn, printQuery=args.debug) else: print(plane.to_JSON()) else: if args.debug: print("Dropped report " + plane.to_JSON()) samps_taken += 1 if args.db_conf and dbconn: dbconn.commit() t2 = time.time() if samps_taken < args.num_samps or args.num_samps < 0: if (t2 - t1) < args.boredom_threshold: time.sleep(args.boredom_threshold - (t2 - t1)) else: inputfile = pr.openFile(args.datafile) data = pr.readFromFile(inputfile) while data: for plane in data: if not plane.reporter: plane.reporter = args.reporter if dbconn: plane.logToDB(dbconn, printQuery=args.debug) else: print(plane.to_JSON()) if dbconn: dbconn.commit() data = pr.readFromFile(inputfile)
#! /usr/bin/env python3 # # import time import argparse import PlaneReport as pr parser = argparse.ArgumentParser( description="Read a bunch of VRS archive files (from unzipped daily archive) and convert them to our JSON format") parser.add_argument('filenames', metavar='N', nargs='+', help="A list of filenames to be opened") args = parser.parse_args() if not args.filenames: print("One or more files are needed!") exit(-1) for fn in args.filenames: fh = pr.openFile(fn) pos_reports = pr.readVRSFromFile(fh) for pl in pos_reports: print(pl.to_JSON()) fh.close()