def main(): global gQuitting global mqttc global args parser = argparse.ArgumentParser() parser.add_argument('-m', '--mqtt-host', help="MQTT broker hostname", default='127.0.0.1') parser.add_argument('-p', '--mqtt-port', type=int, help="MQTT broker port number", default=1883) parser.add_argument('-R', '--radar', help="MQTT radar topic to subscribe to", default='/adsb/radar/json') parser.add_argument('-P', '--prox', help="MQTT proximity topic to publish to", default='/adsb/proximity/json') parser.add_argument('-idb', '--imagedb', help="SQLite plane image database") parser.add_argument('-r', '--rlog-host', help="Remote logging host") parser.add_argument('-l', '--lat', type=float, help="Latitude of radar") parser.add_argument('-L', '--lon', type=float, help="Longitude of radar") parser.add_argument('-v', '--verbose', dest='verbose', action="store_true", help="Verbose output") parser.add_argument('-g', '--no-images', dest='no_images', action="store_true", help="Skipp image search") args = parser.parse_args() if bingconfig.key == None: if not args.no_images: print "You really need to specify a Bing API key or --no-images" sys.exit(1) bing.setKey(bingconfig.key) if not args.lat and not args.lon: print "You really need to tell me where you are located (--lat and --lon)" sys.exit(1) if not args.imagedb: print "You need to tell me where to store aircraft image info (--imagedb DB)" sys.exit(1) try: signal.signal(signal.SIGINT, signal_handler) if args.verbose: loggingInit(logging.DEBUG) else: loggingInit(logging.INFO) log.info("Proxclient started") mqttConnect() while not gQuitting: time.sleep(1) except Exception as e: log.error("Mainloop got exception: %s" % (e)) print traceback.format_exc() gQuitting = True log.info("MQTT disconnect") mqttc.disconnect();
def main(): global gQuitting global mqttc global options parser = OptionParser() parser.add_option('-m', '--mqtt-host', dest='mqtt_host', help="MQTT broker hostname", default='127.0.0.1') parser.add_option('-p', '--mqtt-port', dest='mqtt_port', type="int", help="MQTT broker port number", default=1883) parser.add_option('-t', '--mqtt-topic', dest='mqtt_topic', help="MQTT color topic", default="airlinecolor") parser.add_option('-d', '--max-distance', dest='max_distance', type="float", help="Max distance to light the LED (km)", default=10.0) parser.add_option('-v', '--verbose', dest='verbose', action="store_true", help="Verbose output") (options, args) = parser.parse_args() if bingconfig.key == None: print "You really need to specify a Bing API key, see bingconfig.py" sys.exit(1) bing.setKey(bingconfig.key) signal.signal(signal.SIGINT, signal_handler) imagecolor.loadColorData() try: signal.signal(signal.SIGINT, signal_handler) if options.verbose: loggingInit(logging.DEBUG) else: loggingInit(logging.INFO) log.info("Client started") mqttConnect() except Exception as e: log.error("Mainloop got exception: %s" % (e)) print traceback.format_exc() gQuitting = True log.debug("MQTT disconnect") mqttc.disconnect();
def main(): global gQuitting global mqttc global args parser = argparse.ArgumentParser() parser.add_argument('-m', '--mqtt-host', help="MQTT broker hostname", default='127.0.0.1') parser.add_argument('-p', '--mqtt-port', type=int, help="MQTT broker port number", default=1883) parser.add_argument('-R', '--radar', help="MQTT radar topic to subscribe to", default='/adsb/radar/json') parser.add_argument('-P', '--prox', help="MQTT proximity topic to publish to", default='/adsb/proximity/json') parser.add_argument('-idb', '--imagedb', help="SQLite plane image database") parser.add_argument('-r', '--rlog-host', help="Remote logging host") parser.add_argument('-l', '--lat', type=float, help="Latitude of radar") parser.add_argument('-L', '--lon', type=float, help="Longitude of radar") parser.add_argument('-v', '--verbose', dest='verbose', action="store_true", help="Verbose output") parser.add_argument('-g', '--no-images', dest='no_images', action="store_true", help="Skip image search") parser.add_argument('-o', '--logger', dest='log_host', help="Remote log host") args = parser.parse_args() if bingconfig.key == None: if not args.no_images: print "You really need to specify a Bing API key or --no-images" sys.exit(1) bing.setKey(bingconfig.key) if not args.lat and not args.lon: print "You really need to tell me where you are located (--lat and --lon)" sys.exit(1) if not args.imagedb: print "You need to tell me where to store aircraft image info (--imagedb DB)" sys.exit(1) try: signal.signal(signal.SIGINT, signal_handler) if args.verbose: loggingInit(logging.DEBUG, args.log_host) else: loggingInit(logging.INFO, args.log_host) log.info("Proxclient started") mqttConnect() while not gQuitting: time.sleep(1) except Exception as e: log.error("Mainloop got exception: %s" % (e)) print traceback.format_exc() gQuitting = True log.info("MQTT disconnect") mqttc.disconnect()
def main(): global gQuitting global mqttc global args parser = argparse.ArgumentParser() parser.add_argument('-m', '--mqtt-host', dest='mqtt_host', help="MQTT broker hostname", default='127.0.0.1') parser.add_argument('-p', '--mqtt-port', dest='mqtt_port', type=int, help="MQTT broker port number", default=1883) parser.add_argument('-t', '--mqtt-topic', dest='mqtt_topic', help="MQTT color topic", default="airlinecolor") parser.add_argument('-d', '--max-distance', dest='max_distance', type=float, help="Max distance to light the LED (km)", default=10.0) parser.add_argument('-v', '--verbose', dest='verbose', action="store_true", help="Verbose output") parser.add_argument('-l', '--logger', dest='log_host', help="Remote log host") args = parser.parse_args() if bingconfig.key == None: print "You really need to specify a Bing API key, see bingconfig.py" sys.exit(1) bing.setKey(bingconfig.key) signal.signal(signal.SIGINT, signal_handler) imagecolor.loadColorData() try: signal.signal(signal.SIGINT, signal_handler) if args.verbose: loggingInit(logging.DEBUG, args.log_host) else: loggingInit(logging.INFO, args.log_host) log.info("Client started") mqttConnect() except Exception as e: log.error("Mainloop got exception: %s" % (e)) print traceback.format_exc() gQuitting = True log.debug("MQTT disconnect") mqttc.disconnect()