Merge branch 'ncep_14.4.1-n' of ssh://vlab.ncep.noaa.gov:29418/AWIPS2_Dev_Baseline into ncep_15.1.1-n
Former-commit-id: 4d904e6108b312a4e40a51265164827147804c76
This commit is contained in:
commit
ed7770ba84
1 changed files with 55 additions and 15 deletions
|
@ -1,15 +1,24 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
##
|
||||
# This script is used to extract PGEN products from EDEX.
|
||||
# It can be run in batch mode by specifying the "-l", "-t", "-d", "-st", "-n", and
|
||||
# "-p" options on the command line. Optionally, users can run it in interactive
|
||||
# It can be run in batch mode by specifying the "-l", "-type", "-tag", "-time", "-d", "-st", "-n",
|
||||
# and "-p" options on the command line. Optionally, users can run it in interactive
|
||||
# mode by invoking it with no argument.
|
||||
#
|
||||
# Users can override the default EDEX server and port name by specifying them
|
||||
# in the $DEFAULT_HOST and $DEFAULT_PORT shell environment variables.
|
||||
#
|
||||
# ??/?? R5250 A. Su PGEN - retrieveActivity command line interface does not work
|
||||
#
|
||||
# 03/18 R5801 A. Su PGEN - retrieveActivity command line interface does not work
|
||||
#
|
||||
# 07/02 R8536 P. Chowdhuri
|
||||
# PGEN - retrieveActivity should grab latest if -d option not provided
|
||||
#
|
||||
#
|
||||
##
|
||||
#
|
||||
|
||||
import os
|
||||
import logging
|
||||
|
@ -68,15 +77,21 @@ def __parseCommandLine():
|
|||
options = parser.parse_args()
|
||||
|
||||
options.interactive = False
|
||||
# R8536 In the beginning it isn't known if there are records to extract
|
||||
options.haverecords = False
|
||||
options.latestnotime = False
|
||||
if (options.label == None and options.type == None and
|
||||
options.reftime == None and options.subtype == None and
|
||||
options.tagId == None and
|
||||
options.fullpath == None and options.name == None):
|
||||
options.interactive = True
|
||||
# R8536 change If a value isn't there for the --time qualifier
|
||||
elif (options.reftime == None):
|
||||
options.latestnotime = True
|
||||
else:
|
||||
if (options.label == None and options.type == None and
|
||||
options.reftime == None and options.name == None):
|
||||
print "Must enter values for at least one of -type, -l, -d, or -n"
|
||||
print "Must enter values for at least one of -type, -tag, -time, -l, -d, or -n"
|
||||
exit(0)
|
||||
|
||||
logger.debug("Command-line arguments: " + str(options))
|
||||
|
@ -99,7 +114,7 @@ def main():
|
|||
app.mainloop()
|
||||
root.destroy()
|
||||
else:
|
||||
# Retrieve all activities abnd build a map of record using
|
||||
# Retrieve all activities and build a map of record using
|
||||
# type(subtype) as key.
|
||||
mu = ActivityUtil.ActivityUtil()
|
||||
activityMap = mu.getActivityMap()
|
||||
|
@ -111,12 +126,17 @@ def main():
|
|||
if ( options.subtype != None ) :
|
||||
reqtype = options.type + "(" + options.subtype + ")"
|
||||
|
||||
# Form the matching pattern for tag ID
|
||||
# Form the matching pattern for tag ID
|
||||
tagID = None
|
||||
if ( options.tagId != None):
|
||||
tagID = "*\." + options.tagId + "\.*"
|
||||
|
||||
records = []
|
||||
# R8536 change define the variable for data in the latest activity file
|
||||
latestrec = []
|
||||
# R8536 change Most recent time on the data isn't known here
|
||||
latestRefTime = None
|
||||
|
||||
for key in activityMap.iterkeys():
|
||||
recs = activityMap[key]
|
||||
for rec in recs:
|
||||
|
@ -126,27 +146,46 @@ def main():
|
|||
mu.stringMatcher(options.name, rec["activityName"] ) ):
|
||||
#Remove sec.msec from record's refTime
|
||||
dbRefTime = rec["dataTime.refTime"]
|
||||
if (latestRefTime == None):
|
||||
latestRefTime = dbRefTime;
|
||||
latestrec.append(rec)
|
||||
|
||||
dotIndex = dbRefTime.rfind(":")
|
||||
if ( dotIndex > 0 ):
|
||||
shortTime = dbRefTime[:dotIndex]
|
||||
else:
|
||||
shortTime = dbRefTime
|
||||
|
||||
#Replace the "_" with a whitespace in reftime.
|
||||
optionTime = options.reftime
|
||||
|
||||
if ( latestRefTime < dbRefTime ):
|
||||
latestRefTime = dbRefTime;
|
||||
latestrec[0] = rec
|
||||
|
||||
optionTime = options.reftime
|
||||
|
||||
if ( optionTime != None ):
|
||||
optionTime = optionTime.replace("_", " ")
|
||||
|
||||
if ( mu.stringMatcher( optionTime, shortTime ) ):
|
||||
records.append( rec )
|
||||
|
||||
#Replace the "_" with a whitespace in reftime.
|
||||
optionTime = optionTime.replace("_", " ");
|
||||
if ( mu.stringMatcher( optionTime, shortTime ) ):
|
||||
records.append( rec )
|
||||
elif ( options.latestnotime ):
|
||||
records=latestrec
|
||||
|
||||
# R8536 change if there are data records to write to files set the variable and write
|
||||
for rec in records:
|
||||
options.haverecords = True;
|
||||
pr = ProductRetriever.ProductRetriever(rec["dataURI"], rec["activityLabel"])
|
||||
if options.fullpath != None and options.fullpath.upper().startswith("Y"):
|
||||
pr.setFullpath(True)
|
||||
pr.getProducts()
|
||||
|
||||
logger.info("retrieveActivity is complete.")
|
||||
# R8536 change If there's data to write most recent activity to file when "-time" isn't specified
|
||||
if ( options.latestnotime and options.haverecords ):
|
||||
logger.info("Latest file(s) Extracted, -time unspecified")
|
||||
# R8536 change If there isn't activity data to write qualifier use could be improper (e.g. -tag "")
|
||||
elif ( not options.haverecords ):
|
||||
logger.info("Matching records weren't found, see qualifiers")
|
||||
else:
|
||||
logger.info("retrieveActivity is complete.")
|
||||
|
||||
#
|
||||
# Interactive GUI for PGEN activity retrieval
|
||||
|
@ -260,3 +299,4 @@ class RetrieveGui(Frame):
|
|||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue