def __init__(self, activeTable, activeTableMode, newRecords, offsetSecs=0.0, makeBackups=True, logger=None, atChangeLog=None): # activeTable - current activeTable records # activeTableMode - which table is being modified--OPERATIONAL or PRACTICE # newRecords - records to merge in to activeTable # inputIsGZIP (0,1) - remote input file is gzipped # offsetSecs - Number of seconds +/- current time # makeBackups (False, True) - make backups of previous table # logger - python logging object to send all logs to if logger is not None: self._log = logger else: self._log = self.__initLogging() # get our site siteid = siteConfig.GFESUITE_SITEID self._ourSite = self._get4ID(siteid) # create a dummy name to simplify the file access code in VTECTableUtil filePath = os.path.join(EDEXUtil.getEdexData(), "activetable", siteid) fileName = os.path.join(filePath, activeTableMode + ".tbl") # to ensure time calls are based on Zulu os.environ['TZ'] = "GMT0" self._time = time.time() + offsetSecs #present time self._makeBackups = makeBackups VTECTableUtil.VTECTableUtil.__init__(self, fileName) # get the SPC site id from the configuration file self._spcSite = JUtil.javaObjToPyVal( JavaVTECPartners.getInstance(siteid).getSpcSites("KWNS")) self._tpcSite = JUtil.javaObjToPyVal( JavaVTECPartners.getInstance(siteid).getTpcSites("KNHC")) self._siteFilter = self._getFilterSites() self._log.info("MergeVTEC Starting") self._log.info("localFN= " + self._activeTableFilename + " sites= " + repr(self._siteFilter)) #read table to merge otherTable = newRecords self._log.info("Remote Table size: %d", len(otherTable)) #read active table self._log.info("Active Table size: %d", len(activeTable)) #save a copy for later backup purposes oldActiveTable = copy.deepcopy(activeTable) #delete "obsolete" records from our table and the other table vts = VTECTableSqueeze.VTECTableSqueeze(self._time) activeTable, tossRecords = vts.squeeze(activeTable) self._log.info("Active Table squeezed size: %d", len(activeTable)) self._log.info("Other Table size: %d", len(otherTable)) otherTable, tossRecordsOther = vts.squeeze(otherTable) self._log.info("Other Table squeezed size: %d", len(otherTable)) #merge the tables updatedTable, toDelete, changes = self._mergeTable( activeTable, otherTable, atChangeLog) self._log.info("Updated Active Table size: %d", len(updatedTable)) updatedTable, tossRecordsMerged = vts.squeeze(updatedTable) self._log.info("Updated Active Table squeeze size: %d", len(updatedTable)) del vts if atChangeLog is not None: atChangeLog.info("Entries tossed after merge: " + self.printActiveTable(tossRecordsMerged, 1)) # determine final changes finalChanges = [] for rec in updatedTable: if rec['state'] != 'Existing': item = (rec['officeid'], rec['pil'], rec['phensig'], rec['xxxid']) if item not in finalChanges: finalChanges.append(item) changes = finalChanges if atChangeLog is not None: atChangeLog.info("Table Changes: " + str(changes)) self._updatedTable = [] self._purgedTable = [] self._changes = [] #notify the ifpServer of changes, save a backup copy if tossRecords or tossRecordsMerged or changes: self._log.debug("#tossRecords: %d", len(tossRecords)) self._log.debug("#tossRecordsMerged: %d", len(tossRecordsMerged)) self._log.debug("#changes: %d", len(changes)) # save lists for later retrieval self._updatedTable = updatedTable self._purgedTable.extend(tossRecords) self._purgedTable.extend(toDelete) self._purgedTable.extend( [rec for rec in tossRecordsMerged if rec in oldActiveTable]) self._changes = changes #save backup copy if self._makeBackups: oldActiveTable = self._convertTableToPurePython( oldActiveTable, siteid) self.saveOldActiveTable(oldActiveTable) pTime = getattr(VTECPartners, "VTEC_BACKUP_TABLE_PURGE_TIME", 168) self.purgeOldSavedTables(pTime) self._log.info("MergeVTEC Finished")
LocalizationType = LocalizationContext.LocalizationType LocalizationLevel = LocalizationContext.LocalizationLevel pathMgr = PathManagerFactory.getPathManager() ctx = pathMgr.getContext(LocalizationType.valueOf('EDEX_STATIC'), LocalizationLevel.valueOf('BASE')) DPATH = pathMgr.getFile(ctx, 'dissemination').getPath() f = open(DPATH + '/rcv_action2codes.txt') for line in f: codeSplit = line.split() ACTION_CODES[codeSplit[0]] = codeSplit[1] f.close() from com.raytheon.uf.edex.core import EDEXUtil dataDir = EDEXUtil.getEdexData() OUT_DIR = dataDir + 'outgoing' if not os.path.isdir(OUT_DIR): os.mkdir(OUT_DIR) INGEST_DIR = dataDir + 'manual' INGEST_ROUTE = 'handleoupFilePush' SITE_ID = EDEXUtil.getEdexSite() def process(oup, afosID, resp, ackMgr=None, test=False): _Logger.info("handleOUP.py received " + str(oup.getFilename())) wmoTypeString = "" userDateTimeStamp = "" msg = '' # WMO message type, aka bbb