def runFormatter(args): ############################################################################ # Import of FormatterRunner and loadConfig are nested in this function # because can only be run under Jep. This allows validateArgs to be called # from a pure Python environment ############################################################################ import FormatterRunner import loadConfig from com.raytheon.viz.gfe.core import DataManager LOGGER.info("TextFormatter Starting") LOGGER.info("CmdLine: " + str(sys.argv[1:])) # set default gfe config so no popup windows appear loadConfig.loadPreferences(args.configFile) dataMgr = DataManager.getInstance(None) forecasts = FormatterRunner.runFormatter( str(args.databaseID), dataMgr.getSiteID(), args.forecastList, args.varDict, args.vtecMode, args.userName, dataMgr, args.serverFile, args.editAreas, args.timeRanges, args.timePeriod, args.drt, args.vtecActiveTable, args.testMode, args.experimentalMode, args.serverOutputFile, args.startTime, args.endTime, args.language, args.outputFile, args.appendFile) LOGGER.info("Text Formatter Finished")
def __init__(self, conf="testIFPImage", baseTime=None, timeRange=None, usrTimeRange=None): self.site = LocalizationManager.getInstance().getCurrentSite() self._topo = 0 # import the config file self.config = __import__(conf) loadConfig.loadPreferences(self.config) self.baseTime = baseTime # Create GFEPainter first and get DataManager from painter self.viz = self.createPainter() self.dm = self.viz.getDataManager() LogStream.logEvent("Configuration File: ", conf) self.ipn = self.getConfig('Png_image', '') # user named time range specified? if usrTimeRange is not None: s_tr = self.dm.getSelectTimeRangeManager().getRange(usrTimeRange) if s_tr is None: s = usrTimeRange + " is not a valid time range name." LogStream.logProblem(s) raise ValueError(s) else: tr = TimeRange.TimeRange(s_tr.toTimeRange()) self.pngTimeRange = tr else: self.pngTimeRange = timeRange
def __init__(self, conf="testIFPImage", userName="", baseTime=None, timeRange=None, usrTimeRange=None): from com.raytheon.uf.viz.core.localization import LocalizationManager self.site = LocalizationManager.getInstance().getCurrentSite() self._topo = 0 # import the config file self.config = __import__(conf) loadConfig.loadPreferences(self.config) self.baseTime = baseTime # Create GFEPainter first and get DataManager from painter self.viz = self.createPainter() self.dm = self.viz.getDataManager(); LogStream.logEvent("Configuration File: ", conf) self.pgons = None self.imgParm = None self.ipn = self.getConfig('Png_image', '') # user named time range specified? if usrTimeRange is not None: s_tr = self.dm.getSelectTimeRangeManager().getRange(usrTimeRange) if s_tr is None: LogStream.logProblem(usrTimeRange, \ " is not a valid time range name.") sys.exit(1) else: tr = TimeRange.TimeRange(s_tr.toTimeRange()) self.pngTimeRange = tr else: self.pngTimeRange = timeRange
def main(): os.environ["TZ"] = 'EST5EDT' time.tzset() import _strptime _strptime._cache_lock.acquire() _strptime._TimeRE_cache = _strptime.TimeRE() _strptime._regex_cache = {} _strptime._cache_lock.release() from java.lang import System System.setProperty('user.name', 'GFETEST') from com.raytheon.uf.viz.core.localization import LocalizationManager from com.raytheon.uf.common.localization import LocalizationContext LocalizationLevel = LocalizationContext.LocalizationLevel LocalizationManager.registerContextName(LocalizationLevel.USER, 'GFETEST') import loadConfig loadConfig.loadPreferences("gfeConfig") from com.raytheon.viz.gfe.core import DataManager dm = DataManager.getInstance(None) import IToolInterface # have to add the user dir to the python path here since we just switched users # TODO look into switching it from the java from com.raytheon.uf.common.dataplugin.gfe.python import GfePyIncludeUtil for s in sys.path: if 'textUtilities' in s \ or 'textProducts' in s \ or 'combinations' in s: sys.path.remove(s) for s in str(GfePyIncludeUtil.getHeadlineIncludePath()).split(':'): sys.path.append(s) for s in str(GfePyIncludeUtil.getTextUtilitiesIncludePath()).split(':'): sys.path.append(s) for s in str(GfePyIncludeUtil.getTextProductsIncludePath()).split(':'): sys.path.append(s) for s in str(GfePyIncludeUtil.getCombinationsIncludePath()).split(':'): sys.path.append(s) # create output directory for products try: os.makedirs(OUTPUT_DIR) except OSError, e: if e.errno != errno.EEXIST: self.output("%s: '%s'" % (e.strerror, e.filename))
def __init__(self, procName, configFile, startTime, endTime, timeRange, editArea, mutableModel, varDict): # import the config file prefs = loadConfig.loadPreferences(configFile) LogStream.logEvent("Configuration File: ", configFile) if mutableModel is None: mutableModel = prefs.getString('mutableModel') else: prefs.setValue('mutableModel', mutableModel) self.__dataMgr = DataManagerUIFactory.getInstance(None) currentMutableModel = self.__dataMgr.getParmManager( ).getMutableDatabase() desiredMutableModel = self.__dataMgr.getParmManager( ).decodeDbString(mutableModel) if currentMutableModel != desiredMutableModel: DataManagerUIFactory.dispose(None) self.__dataMgr = DataManagerUIFactory.getInstance(None) # Create Time Range if startTime is not None and endTime is not None: start = self.decodeTimeStruct(startTime) end = self.decodeTimeStruct(endTime) self.__timeRange = TimeRange.TimeRange(start, end) elif timeRange is not None: self.__timeRange = TimeRange.TimeRange( self.__dataMgr.getSelectTimeRangeManager().getRange( timeRange).toTimeRange()) else: self.__timeRange = TimeRange.default() if editArea is not None: refID = ReferenceID(editArea) self.__editArea = \ self.__dataMgr.getRefManager().loadRefSet(refID) else: self.__editArea = self.__dataMgr.getRefManager().emptyRefSet() LogStream.logVerbose("varDict=", varDict) runner = ProcedureRunner(procName) errors = runner.getImportErrors() if len(errors) > 0: msg = "\n\t".join( ["Error importing the following procedures:"] + errors) LogStream.error(msg) runner.instantiate(procName, CLASS_NAME, **{'dbss': self.__dataMgr}) runner.run(self.__dataMgr, procName, CLASS_NAME, METHOD_NAME, varDict, self.__editArea, self.__timeRange)
def main(): os.environ["TZ"] = 'EST5EDT' import _strptime _strptime._cache_lock.acquire() _strptime._TimeRE_cache = _strptime.TimeRE() _strptime._regex_cache = {} _strptime._cache_lock.release() from java.lang import System System.setProperty('user.name', 'GFETEST') from com.raytheon.uf.viz.core.localization import LocalizationManager from com.raytheon.uf.common.localization import LocalizationContext_LocalizationLevel as LocalizationLevel LocalizationManager.registerContextName(LocalizationLevel.USER, 'GFETEST'); import loadConfig loadConfig.loadPreferences("gfeConfig") from com.raytheon.viz.gfe.core import DataManager dm = DataManager.getInstance(None) import IToolInterface # have to add the user dir to the python path here since we just switched users # TODO look into switching it from the java from com.raytheon.uf.common.dataplugin.gfe.python import GfePyIncludeUtil for s in str(GfePyIncludeUtil.getCombinationsIncludePath()).split(':'): sys.path.append(s) scriptDir = GfePyIncludeUtil.getIToolIncludePath() runner = IToolInterface.IToolInterface(scriptDir) runner.instantiate('TextProductTest', 'ITool', dbss=dm) processVariableList = ProcessVariableList.ProcessVariableList('TextProductTest', VariableList) varDict = processVariableList.varDict() if varDict is None or len(varDict) == 0: return runner.runITool('TextProductTest', 'ITool', 'execute', varDict=varDict)
def __init__(self, procName, host, port, userName, configFile, startTime, endTime, timeRange, editArea, mutableModel, varDict): # import the config file prefs = loadConfig.loadPreferences(configFile) LogStream.logEvent("Configuration File: ", configFile) if mutableModel is None: mutableModel = prefs.getString('mutableModel') else: prefs.setValue('mutableModel', mutableModel) self.__dataMgr = DataManager.getInstance(None) # Create Time Range if startTime is not None and endTime is not None: start = self.getAbsTime(startTime) end = self.getAbsTime(endTime) self.__timeRange = TimeRange.TimeRange(start, end) elif timeRange is not None: self.__timeRange = TimeRange.TimeRange( self.__dataMgr.getSelectTimeRangeManager().getRange( timeRange).toTimeRange()) else: self.__timeRange = TimeRange.default() if editArea is not None: refID = ReferenceID(editArea) self.__editArea = \ self.__dataMgr.getRefManager().loadRefSet(refID) else: self.__editArea = self.__dataMgr.getRefManager().emptyRefSet() LogStream.logVerbose("varDict=", varDict) runner = ProcedureRunner(procName) errors = runner.getImportErrors() if len(errors) > 0: print "Error importing the following procedures:\n" for s in errors: print s sys.exit(1) runner.instantiate(procName, CLASS_NAME, **{'dbss': self.__dataMgr}) runner.run(self.__dataMgr, procName, CLASS_NAME, METHOD_NAME, varDict, self.__editArea, self.__timeRange)
def __init__(self, procName, host, port, userName, configFile, startTime, endTime, timeRange, editArea, mutableModel, varDict): # import the config file prefs = loadConfig.loadPreferences(configFile) LogStream.logEvent("Configuration File: ", configFile) if mutableModel is None: mutableModel = prefs.getString('mutableModel') else: prefs.setValue('mutableModel', mutableModel) self.__dataMgr = DataManager.getInstance(None) # Create Time Range if startTime is not None and endTime is not None: start = self.getAbsTime(startTime) end = self.getAbsTime(endTime) self.__timeRange = TimeRange.TimeRange(start, end) elif timeRange is not None: self.__timeRange = TimeRange.TimeRange(self.__dataMgr.getSelectTimeRangeManager().getRange(timeRange).toTimeRange()); else: self.__timeRange = TimeRange.default() if editArea is not None: refID = ReferenceID(editArea) self.__editArea = \ self.__dataMgr.getRefManager().loadRefSet(refID) else: self.__editArea = self.__dataMgr.getRefManager().emptyRefSet() LogStream.logVerbose("varDict=",varDict) runner = ProcedureRunner(procName) errors = runner.getImportErrors() if len(errors) > 0: print "Error importing the following procedures:\n" for s in errors: print s sys.exit(1) runner.instantiate(procName, CLASS_NAME, **{'dbss':self.__dataMgr}) runner.run(self.__dataMgr, procName, CLASS_NAME, METHOD_NAME, varDict, self.__editArea, self.__timeRange)
#force VTEC mode to "E" if in EXPERIMENTAL mode and another vtecCode #is specified elif experimentalMode and vtecMode is not None: vtecMode = "E" #force into TEST mode, if vtec code is 'T' if vtecMode == "T": testMode = 1 experimentalMode = 0 elif vtecMode == "E": experimentalMode = 1 testMode = 0 # set default gfe config so no popup windows appear loadConfig.loadPreferences(configFile) # LOGGER.debug("Configuration File: " + configFile) dataMgr = DataManager.getInstance(None) forecasts = FormatterRunner.runFormatter( databaseID, dataMgr.getSiteID(), forecastList, cmdLineVarDict, vtecMode, userName, dataMgr, serverFile, editAreas, timeRanges, timePeriod, offsetTime, vtecActiveTable, testMode, experimentalMode, serverOutputFile, startTime, endTime, language, outputFile, appendFile) # Output of the forecasts is not needed as we can let formatterrunner do it, # LOGGER.info("Text:\n" + forecasts) LOGGER.info("Text Formatter Finished")