From 34452f236e06f00deb46a5bf2c6bc6080c90947a Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Thu, 5 Jul 2012 16:32:44 -0500 Subject: [PATCH] Issue #851 Cleaned up unnecessary Java imports in baselined tools/procedures. Change-Id: I49ad2815c2b524a63c115c1b2424b41831247d97 Former-commit-id: d3e0cd5af85731fc3f358472dd4a0d94153f5b02 [formerly d3e0cd5af85731fc3f358472dd4a0d94153f5b02 [formerly ff032c53a059f25558aabdc5b483c4cc59ad3f6e]] Former-commit-id: e71059c2b9adc5fe6cf131ab7101f9144b4c3a29 Former-commit-id: 473e6e9eb227c0ca1949e023fabf770899fa7acf --- .../gfe/userPython/gfeConfig/imageTest1.py | 2 ++ .../gfe/userPython/procedures/CheckTandTd.py | 9 +++---- .../userPython/procedures/CheckWindGust.py | 25 +++++++++---------- .../userPython/procedures/DiffFromClimo.py | 9 +++---- .../userPython/procedures/GenerateCyclone.py | 18 +++---------- .../procedures/ISC_Discrepancies.py | 4 +-- .../userPython/procedures/PlotSPCWatches.py | 8 ------ .../procedures/PopulateFromClimo.py | 12 +++------ .../gfe/userPython/procedures/TCMWindTool.py | 18 +++---------- .../gfe/userPython/smartTools/LimitValues.py | 25 ++++++++----------- .../gfe/userPython/utilities/SmartScript.py | 9 +++++++ 11 files changed, 53 insertions(+), 86 deletions(-) diff --git a/cave/build/static/common/cave/etc/gfe/userPython/gfeConfig/imageTest1.py b/cave/build/static/common/cave/etc/gfe/userPython/gfeConfig/imageTest1.py index 5c49987ef8..d5f022039f 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/gfeConfig/imageTest1.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/gfeConfig/imageTest1.py @@ -22,6 +22,8 @@ from gfeConfig import * import gfeConfig +HideConfigFile = 1 + # Defines the T as the displayable weather element Png_parms = ['T_SFC:_Fcst -1', 'Td_SFC:_Fcst -1', 'Wind_SFC:_Fcst -1'] Png_image = 'T' diff --git a/cave/build/static/common/cave/etc/gfe/userPython/procedures/CheckTandTd.py b/cave/build/static/common/cave/etc/gfe/userPython/procedures/CheckTandTd.py index 03166db00d..b82ca090d2 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/procedures/CheckTandTd.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/procedures/CheckTandTd.py @@ -43,7 +43,6 @@ VariableList = [("Check or Force:" , "Check Only", "radio", import SmartScript import TimeRange import AbsTime -from com.raytheon.uf.common.time import TimeRange as javaTR from numpy import * MODEL = "Fcst" @@ -63,11 +62,11 @@ class Procedure (SmartScript.SmartScript): # @return: time ranges at which WEName has data. # @rtype: Python list of Python TimeRange objects def getWEInventory(self, WEName): - # yesterday = time.time() - (2 * 24 * 3600) # two days ago - # later = time.time() + 10 * 24 * 3600 # 10 days from now - allTimes = javaTR.allTimes() + yesterday = self._gmtime() - (2 * 24 * 3600) # two days ago + later = self._gmtime() + 10 * 24 * 3600 # 10 days from now + allTimes = TimeRange.TimeRange(yesterday, later) parm = self.getParm(MODEL, WEName, LEVEL); - inv = parm.getGridInventory(allTimes) + inv = parm.getGridInventory(allTimes.toJavaObj()) trList = [] for gd in inv: tr = TimeRange.TimeRange(gd.getGridTime()) diff --git a/cave/build/static/common/cave/etc/gfe/userPython/procedures/CheckWindGust.py b/cave/build/static/common/cave/etc/gfe/userPython/procedures/CheckWindGust.py index b43332aa4f..db4759b9c2 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/procedures/CheckWindGust.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/procedures/CheckWindGust.py @@ -49,7 +49,6 @@ import SmartScript import time import TimeRange import AbsTime -from com.raytheon.uf.common.time import TimeRange as javaTR from numpy import * MODEL = "Fcst" @@ -61,11 +60,11 @@ class Procedure (SmartScript.SmartScript): def getWEInventory(self, WEName): - #yesterday = time.time() - (2 * 24 * 3600) # two days ago - #later = time.time() + 10 * 24 * 3600 # 10 days from now - allTimes = javaTR.allTimes() - parm = self.getParm(MODEL, WEName, LEVEL); - inv = parm.getGridInventory(allTimes) + yesterday = self._gmtime() - (2 * 24 * 3600) # two days ago + later = self._gmtime() + 10 * 24 * 3600 # 10 days from now + allTimes = TimeRange.TimeRange(yesterday, later) + parm = self.getParm(MODEL, WEName, LEVEL); + inv = parm.getGridInventory(allTimes.toJavaObj()) trList = [] for gd in inv: @@ -81,12 +80,12 @@ class Procedure (SmartScript.SmartScript): return [] lt = parm.getLockTable() jlok = lt.lockedByOther() - lbo = [] - for i in xrange(jlok.size()): - tr = jlok.get(i) - tr = TimeRange.TimeRange(tr) - lbo.append( tr ) - return lbo + lbo = [] + for i in xrange(jlok.size()): + tr = jlok.get(i) + tr = TimeRange.TimeRange(tr) + lbo.append( tr ) + return lbo def overlappingTRs(self, timeRange, trList): newTRList = [] @@ -116,7 +115,7 @@ class Procedure (SmartScript.SmartScript): endWindChill = 4 ## Last month to report wind chill # Get local edit area simply by using the baseline edit area - eaList = self.editAreaList() + eaList = self.editAreaList() siteID = self.getSiteID() if siteID in eaList: # make sure the edit area is there diff --git a/cave/build/static/common/cave/etc/gfe/userPython/procedures/DiffFromClimo.py b/cave/build/static/common/cave/etc/gfe/userPython/procedures/DiffFromClimo.py index 64af4c6994..100375ac6b 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/procedures/DiffFromClimo.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/procedures/DiffFromClimo.py @@ -42,8 +42,6 @@ import time import AbsTime import TimeRange -from com.raytheon.uf.common.time import TimeRange as javaTR - MODEL = "Fcst" LEVEL = "SFC" @@ -148,17 +146,16 @@ class Procedure (SmartScript.SmartScript): # @return: time ranges at which WEName has data. # @rtype: Python list of Python TimeRange objects def _getWEInventory(self, dbName, WEName, timeRange=None): - # yesterday = time.time() - (2 * 24 * 3600) # two days ago - # later = time.time() + 10 * 24 * 3600 # 10 days from now + # set up a timeRange if it is None if timeRange is None: - timeRange = javaTR.allTimes() + timeRange = TimeRange.allTimes() parm = self.getParm(dbName, WEName, LEVEL) if parm is None: print "PFC: dbName =", dbName print "PFC: WEName =", WEName print "PFC: parm is None" return [] - inv = parm.getGridInventory(timeRange) + inv = parm.getGridInventory(timeRange.toJavaObj()) if inv is None: self.statusBarMsg("inv is None","S") elif len(inv)==0: print self.statusBarMsg("PFC: len(inv)==0","S") trList = [] diff --git a/cave/build/static/common/cave/etc/gfe/userPython/procedures/GenerateCyclone.py b/cave/build/static/common/cave/etc/gfe/userPython/procedures/GenerateCyclone.py index 7c431bbaca..6e1ef8765e 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/procedures/GenerateCyclone.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/procedures/GenerateCyclone.py @@ -42,7 +42,6 @@ VariableList = [("ProductID:", "", "alphaNumeric"), import TimeRange import AbsTime -from com.raytheon.uf.common.time import TimeRange as javaTR import SmartScript @@ -608,15 +607,6 @@ class Procedure (SmartScript.SmartScript): return textList - # Retrieves a text product from the text database - def getTextProductFromDB(self, productID): - from com.raytheon.viz.gfe.product import TextDBUtil - - opMode = self.gfeOperatingMode()=="OPERATIONAL" - fullText = TextDBUtil.retrieveProduct(productID, opMode) - textList = fullText.splitlines(True) - return textList - # Reads decodes depression information using the specified product. def decodeDepressionInfo(self, textProduct): @@ -650,11 +640,11 @@ class Procedure (SmartScript.SmartScript): return fcstList def getWEInventory(self, modelName, WEName, level): - #yesterday = time.time() - (300 * 24 * 3600) # 300 days ago - #later = time.time() + 100 * 24 * 3600 # 100days from now - allTimes = javaTR.allTimes() + yesterday = self._gmtime() - (2 * 24 * 3600) # two days ago + later = self._gmtime() + 10 * 24 * 3600 # 10 days from now + allTimes = TimeRange.TimeRange(yesterday, later) parm = self.getParm(modelName, WEName, level); - inv = parm.getGridInventory(allTimes) + inv = parm.getGridInventory(allTimes.toJavaObj()) trList = [] for gd in inv: tr = TimeRange.TimeRange(gd.getGridTime()) diff --git a/cave/build/static/common/cave/etc/gfe/userPython/procedures/ISC_Discrepancies.py b/cave/build/static/common/cave/etc/gfe/userPython/procedures/ISC_Discrepancies.py index cc4ecce71b..db0d9e61dd 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/procedures/ISC_Discrepancies.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/procedures/ISC_Discrepancies.py @@ -42,11 +42,9 @@ import SmartScript import time import ProcessVariableList -from com.raytheon.viz.gfe.core import DataManager - class Procedure (SmartScript.SmartScript): def __init__(self, dbss): - self._dbss = DataManager.getCurrentInstance() + self._dbss = dbss SmartScript.SmartScript.__init__(self, self._dbss) def execute(self, editArea, timeRange, varDict): diff --git a/cave/build/static/common/cave/etc/gfe/userPython/procedures/PlotSPCWatches.py b/cave/build/static/common/cave/etc/gfe/userPython/procedures/PlotSPCWatches.py index 0f25dc0f79..f4567850cd 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/procedures/PlotSPCWatches.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/procedures/PlotSPCWatches.py @@ -44,14 +44,6 @@ import UFStatusHandler import JUtil from java.io import File from java.lang import System -from com.raytheon.uf.common.serialization import SerializationUtil -from com.raytheon.uf.common.localization import LocalizationFile -from com.raytheon.uf.common.localization import PathManagerFactory -from com.raytheon.uf.common.localization import LocalizationContext -from com.raytheon.uf.common.localization import LocalizationContext_LocalizationType as LocalizationType -from com.raytheon.uf.common.localization import LocalizationContext_LocalizationLevel as LocalizationLevel -from com.raytheon.uf.common.site.xml import CwaXML -from com.raytheon.uf.common.site.xml import AdjacentWfoXML PLUGIN_NAME = 'com.raytheon.viz.gfe' CATEGORY = 'GFE' diff --git a/cave/build/static/common/cave/etc/gfe/userPython/procedures/PopulateFromClimo.py b/cave/build/static/common/cave/etc/gfe/userPython/procedures/PopulateFromClimo.py index 0b3dcf506b..66be6465d9 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/procedures/PopulateFromClimo.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/procedures/PopulateFromClimo.py @@ -42,9 +42,6 @@ import time import AbsTime import TimeRange -from com.raytheon.uf.common.time import TimeRange as javaTR -from com.raytheon.uf.common.time import SimulatedTime as simulatedTime - MODEL = "Fcst" LEVEL = "SFC" @@ -64,14 +61,13 @@ class Procedure (SmartScript.SmartScript): # @return: time ranges at which WEName has data. # @rtype: Python list of Python TimeRange objects def _getWEInventory(self, dbName, WEName, timeRange=None): - # yesterday = time.time() - (2 * 24 * 3600) # two days ago - # later = time.time() + 10 * 24 * 3600 # 10 days from now + # set up a timeRange if it is None if timeRange is None: - timeRange = javaTR.allTimes() + timeRange = TimeRange.allTimes() parm = self.getParm(dbName, WEName, LEVEL) if parm is None: return [] - inv = parm.getGridInventory(timeRange) + inv = parm.getGridInventory(timeRange.toJavaObj()) if inv is None: self.statusBarMsg("inv is None","S") elif len(inv)==0: print self.statusBarMsg("PFC: len(inv)==0","S") trList = [] @@ -226,7 +222,7 @@ class Procedure (SmartScript.SmartScript): # Figure out what year it is - currentTime = AbsTime.AbsTime(simulatedTime.getSystemTime().getTime()).unixTime() + currentTime = self._gmtime().unixTime() jan01Tuple = (time.gmtime(currentTime)[0],1,1,0,0,0,0,0,0) # 01 Jan this year jan01Secs = time.mktime(jan01Tuple) # 01 Jan in seconds diff --git a/cave/build/static/common/cave/etc/gfe/userPython/procedures/TCMWindTool.py b/cave/build/static/common/cave/etc/gfe/userPython/procedures/TCMWindTool.py index 656346ee60..504da304cf 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/procedures/TCMWindTool.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/procedures/TCMWindTool.py @@ -56,7 +56,6 @@ VariableList = [("Product to\ndecode:", [], "check", import TimeRange import AbsTime -from com.raytheon.uf.common.time import TimeRange as javaTR import SmartScript @@ -615,15 +614,6 @@ class Procedure (SmartScript.SmartScript): f.close() return textList - # Retrieves a text product from the text database - def getTextProductFromDB(self, productID): - from com.raytheon.viz.gfe.product import TextDBUtil - - opMode = self.gfeOperatingMode()=="OPERATIONAL" - fullText = TextDBUtil.retrieveProduct(productID, opMode) - textList = fullText.splitlines(True) - return textList - def printFcst(self, f, baseTime): print "==============================================================" print "Time:", time.asctime(time.gmtime(f['validTime'])), @@ -639,11 +629,11 @@ class Procedure (SmartScript.SmartScript): print r, "kts:", f['radii'][r] def getWEInventory(self, modelName, WEName, level): - #yesterday = time.time() - (300 * 24 * 3600) # 300 days ago - #later = time.time() + 100 * 24 * 3600 # 100days from now - allTimes = javaTR.allTimes() + yesterday = self._gmtime() - (2 * 24 * 3600) # two days ago + later = self._gmtime() + 10 * 24 * 3600 # 10 days from now + allTimes = TimeRange.TimeRange(yesterday, later) parm = self.getParm(modelName, WEName, level); - inv = parm.getGridInventory(allTimes) + inv = parm.getGridInventory(allTimes.toJavaObj()) trList = [] for gd in inv: tr = TimeRange.TimeRange(gd.getGridTime()) diff --git a/cave/build/static/common/cave/etc/gfe/userPython/smartTools/LimitValues.py b/cave/build/static/common/cave/etc/gfe/userPython/smartTools/LimitValues.py index 84a8a48e1e..91f31f04da 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/smartTools/LimitValues.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/smartTools/LimitValues.py @@ -48,9 +48,6 @@ from numpy import * import ProcessVariableList import SmartScript -from com.raytheon.uf.common.dataplugin.gfe.db.objects import GFERecord_GridType as GridType - - toolName = 'LimitValues' class Tool (SmartScript.SmartScript): @@ -59,7 +56,6 @@ class Tool (SmartScript.SmartScript): def preProcessGrid(self,editArea,variableElement, variableElement_GridInfo,WEname): - wxType = variableElement_GridInfo.getGridType() # # Need a mask of the current edit area, so the # dialog can figure out the current max/min in @@ -81,10 +77,10 @@ class Tool (SmartScript.SmartScript): # setup valgrid with the grid that will be # limited (i.e. for vectors the speed) # - if wxType.equals(GridType.SCALAR): - valgrid=variableElement - if wxType.equals(GridType.VECTOR): + if type(variableElement) is list: (valgrid,dir)=variableElement + else: + valgrid=variableElement # # When checking for mins, need all areas outside the edit # area set to the max value for this element - so that the @@ -148,18 +144,17 @@ class Tool (SmartScript.SmartScript): # Main routine that reads in the variableElement and limits it to # the values set up via the dialog in the preProcessGrid routine # - def execute(self, variableElement, variableElement_GridInfo, varDict): + def execute(self, variableElement, varDict): "limit gridvalues between user-set limits" # # set val to the grid we will limit # (if it is a vector - get the speed) # - wxType = variableElement_GridInfo.getGridType() - if wxType.equals(GridType.SCALAR): - val=variableElement - if wxType.equals(GridType.VECTOR): + if type(variableElement) is list: val=variableElement[0] dir=variableElement[1] + else: + val=variableElement # # limit the values, max first, then min # @@ -170,9 +165,9 @@ class Tool (SmartScript.SmartScript): # put the trimmed values back # - if wxType.equals(GridType.SCALAR): - variableElement=valC - if wxType.equals(GridType.VECTOR): + if type(variableElement) is list: variableElement=(valC,dir) + else: + variableElement=valC return variableElement diff --git a/cave/build/static/common/cave/etc/gfe/userPython/utilities/SmartScript.py b/cave/build/static/common/cave/etc/gfe/userPython/utilities/SmartScript.py index 2018230417..86dc06e165 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/utilities/SmartScript.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/utilities/SmartScript.py @@ -2380,4 +2380,13 @@ class SmartScript(BaseTool.BaseTool): import JUtil return JUtil.javaStringListToPylist(self.__dataMgr.knownOfficeTypes()) + # Retrieves a text product from the text database + def getTextProductFromDB(self, productID): + from com.raytheon.viz.gfe.product import TextDBUtil + + opMode = self.gfeOperatingMode()=="OPERATIONAL" + fullText = TextDBUtil.retrieveProduct(productID, opMode) + textList = fullText.splitlines(True) + return textList +