def __init__(self): """ Handle the FAA aircraft database files. """ # Build logger. self.__logger = asLog(config.ssrRegMongo['logMode']) self.__logger.log("AirSuck FAA database import starting...") # Master list of aircraft properties. self.__acList = {} # Master list of engine properties. self.__engList = {} try: #MongoDB config faaRegMongo = pymongo.MongoClient(config.ssrRegMongo['host'], config.ssrRegMongo['port']) mDB = faaRegMongo[config.ssrRegMongo['dbName']] tempCollName = "%s_tmp" % config.ssrRegMongo['coll'] # Set up the temporary colleciton. self.__mDBColl = mDB[tempCollName] # Nuke it if it exists. try: self.__mDBColl.drop() except: # Probably means it doesn't exist. We DGAF if it blows up. None except: tb = traceback.format_exc() self.__logger.log("Failed to connect to MongoDB:\n%s" % tb) raise
logger.log("%s went boom processing data.\n%s" % (self.__myName, tb)) # Close the connection. self.__disconnectSource() ####################### # Main execution body # ####################### # If I've been called for execution... if __name__ == "__main__": # Set up the logger. logger = asLog(config.aisConnSettings['logMode']) # If the AIS engine is enabled in config... if config.aisConnSettings['enabled'] == True: # ... and go. logger.log("AIS connector starting...") # Set up our AIS handler object. hAIS = handlerAIS(config.aisConnSettings['logMode'], enqueueOn) hAIS.setDebug(config.aisConnSettings['debug']) # Threading setup threadLock = threading.Lock() threadList = [] # Spin up our client threads.
except KeyboardInterrupt: self.__keepRunning = False raise KeyboardInterrupt except: tb = traceback.format_exc() logger.log("Worker blew up:\n%s" % tb) logger.log('Waiting 1 second before starting again.') time.sleep(1.0) if __name__ == "__main__": # Set up the logger. logger = asLog(config.ssrStateEngine['logMode']) logger.log("SSR state engine starting...") # Start up our ADS-B parser client = SubListener([config.connPub['qName']]) client.daemon = True # .. and go. client.start() try: while True: time.sleep(10) except KeyboardInterrupt: # Die nicely. quit()
line = "" # See if our watchdog is working. if self.__watchdogFail: logger.log("%s watchdog terminating readLines." % self.__myName) data = False break ####################### # Main execution body # ####################### # Set up the logger. logger = asLog(config.d1090ConnSettings['logMode']) # ... and go. logger.log("Dump1090 client connector starting...") # Set up our dump1090 handler. h1090 = handler1090(config.d1090ConnSettings['logMode']) h1090.setDebug(config.d1090ConnSettings['debug']) # Threading setup threadLock = threading.Lock() threadList = [] # Spin up our client threads. for thisName, connData in dump1909Srcs.iteritems(): logger.log("Spinning up thread for %s." % thisName)
raise IOError( "No configuration present. Please copy config/config.py to the airSuck folder and edit it." ) import sys import redis import pymongo import time import json import datetime import traceback from libAirSuck import asLog from pprint import pprint # Set up the logger. logger = asLog(config.stateMongo['logMode']) # Redis instance for queueing. rQ = redis.StrictRedis(host=config.stateRel['host'], port=config.stateRel['port']) #Delay this many seconds if the queue is empty to prevent #stupid amounts of CPU utilization. checkDelay = config.stateMongo['checkDelay'] #MongoDB config stateMongo = pymongo.MongoClient(config.stateMongo['host'], config.stateMongo['port']) mDB = stateMongo[config.stateMongo['dbName']] mDBColl = mDB[config.stateMongo['coll']]
except: tb = traceback.format_exc() logger.log("Failed to convert string to datetime:\n%s" %tb) return retVal # Decapsulate the JSON data. def dejsonify(msg): return json.loads(msg) # Insert records into specified mongo instance def serializeADSB(entry): mDBColl.insert(entry) # Set up the logger. logger = asLog(config.connMongo['logMode']) # If this mongo engine is enabled... if config.connMongo['enabled'] == True: # Limits? timeLimit = datetime.timedelta(seconds=config.connMongo['insertDelay']) # What time is it now? timeThen = datetime.datetime.now() timeNow = datetime.datetime.now() # Infinite f*****g loop. logger.log("Dumping connector data from queue to MongoDB.") while(keepRunning) : try: # Pull oldest entry from the queue.
# Print shutdown message. logger.log("airSuck server runner stopped.") return ####################### # Main execution body # ####################### # If this isn't being executed directly... if __name__ == "__main__": # Set up the logger. logger = asLog(config.airSuckSrvSettings['logMode']) # Log our startup. logger.log("Starting the airSuck server...") # If we're debugging... if config.airSuckSrvSettings['debug']: pprint(config.airSuckSrvSettings) # If the dump1090 connector should be run if config.airSuckSrvSettings['enabled']: # Set up the dump1090 handler. h1090 = handler1090(config.airSuckSrvSettings['logMode']) # Configure the dump1090 handler's debug mode based on our configured mode. h1090.setDebug(config.airSuckSrvSettings['debug'])
data.update({ 'shipTypeMeta': self.__asu.getAISShipType(aisWrapped['shipType']) }) # Enqueue processed state data. self.enqueueData(self.updateState(aisWrapped['mmsi'], data)) def run(self): for work in self.__psObj.listen(): self.worker(work) if __name__ == "__main__": # Set up the logger. logger = asLog(config.aisStateEngine['logMode']) # If we're enabled in config... if config.aisStateEngine['enabled'] == True: logger.log("AIS state engine starting...") # Start up our AIS parser client = SubListener([config.connPub['qName']]) client.daemon = True # .. and go. client.start() try: while True: time.sleep(10)
dump1090Sock.close() except KeyboardInterrupt: quit() except: tb = traceback.format_exc() logger.log("Failed to connect to %s:%s\n%s" %(dump1090Dst["host"], dump1090Dst["port"], tb)) logger.log("Sleeping %s sec" %dump1090Dst["reconnectDelay"]) time.sleep(dump1090Dst["reconnectDelay"]) # Start up. if __name__ == "__main__": # Set up the logger. logger = asLog('stdout') # Start up redis, create our threaded client, and start it. r = redis.Redis(host=config.connPub['host'], port=config.connPub['port']) client = SubListener(r, [config.connPub['qName']]) client.daemon = True client.start() try: while True: time.sleep(10) except KeyboardInterrupt: # Die nicely. quit() except Exception: tb = traceback.format_exc() logger.log("Unexpected exception\n%s" %tb)