Omaha #4604 - Removed files packaged by NCEP CLI RPM
Change-Id: I8da4049c60a5d9e9372b1919d65be6e0329e03fb Former-commit-id: dfc0d8210cdb2fc5ca6d40e327292aae1c8f4afc
This commit is contained in:
parent
58ed937654
commit
368a4a2b2d
10 changed files with 0 additions and 1644 deletions
|
@ -1,34 +0,0 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
##
|
||||
##############################################################################
|
||||
# This script allows users to query point data database from EDEX.
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 05/20/2013 Chin Chen Initial Creation.
|
||||
##############################################################################
|
||||
|
||||
# this allows you to run this script from outside of ./bin
|
||||
path_to_script=`readlink -f $0`
|
||||
RUN_FROM_DIR=`dirname $path_to_script`
|
||||
|
||||
BASE_AWIPS_DIR=`dirname $RUN_FROM_DIR`
|
||||
|
||||
# get the base environment
|
||||
source ${RUN_FROM_DIR}/setup.env
|
||||
|
||||
# setup the environment needed to run the the Python
|
||||
export LD_LIBRARY_PATH=${BASE_AWIPS_DIR}/src/lib:${PYTHON_INSTALL}/lib
|
||||
export PYTHONPATH=${RUN_FROM_DIR}/src:$PYTHONPATH
|
||||
|
||||
# execute the ifpInit Python module
|
||||
_PYTHON="${PYTHON_INSTALL}/bin/python"
|
||||
_MODULE="${RUN_FROM_DIR}/src/gpd/gpd.py"
|
||||
|
||||
# quoting of '$@' is used to prevent command line interpretation
|
||||
#$_PYTHON $_MODULE -h ${DEFAULT_HOST} -p ${DEFAULT_PORT} "$@"
|
||||
$_PYTHON $_MODULE "$@"
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
# This software was developed and / or modified by Raytheon Company,
|
||||
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
#
|
||||
# U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
# This software product contains export-restricted data whose
|
||||
# export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
# to non-U.S. persons whether in the United States or abroad requires
|
||||
# an export license or other authorization.
|
||||
#
|
||||
# Contractor Name: Raytheon Company
|
||||
# Contractor Address: 6825 Pine Street, Suite 340
|
||||
# Mail Stop B8
|
||||
# Omaha, NE 68106
|
||||
# 402.291.0100
|
||||
#
|
||||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
##############################################################################
|
||||
# This script allows users to extract PGEN products from EDEX.
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 06/08/12 #674 dgilling Initial Creation.
|
||||
##############################################################################
|
||||
|
||||
# this allows you to run this script from outside of ./bin
|
||||
path_to_script=`readlink -f $0`
|
||||
RUN_FROM_DIR=`dirname $path_to_script`
|
||||
|
||||
BASE_AWIPS_DIR=`dirname $RUN_FROM_DIR`
|
||||
|
||||
# get the base environment
|
||||
source ${RUN_FROM_DIR}/setup.env
|
||||
|
||||
# setup the environment needed to run the the Python
|
||||
export LD_LIBRARY_PATH=${BASE_AWIPS_DIR}/src/lib:${PYTHON_INSTALL}/lib
|
||||
export PYTHONPATH=${RUN_FROM_DIR}/src:$PYTHONPATH
|
||||
|
||||
# execute the ifpInit Python module
|
||||
_PYTHON="${PYTHON_INSTALL}/bin/python"
|
||||
_MODULE="${RUN_FROM_DIR}/src/pgen/retrieveActivity.py"
|
||||
|
||||
# quoting of '$@' is used to prevent command line interpretation
|
||||
#$_PYTHON $_MODULE -h ${DEFAULT_HOST} -p ${DEFAULT_PORT} "$@"
|
||||
$_PYTHON $_MODULE "$@"
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
##
|
||||
# This script is used to send GPD request to EDEX.
|
||||
#
|
||||
# Users can override the default EDEX server and port name by specifying them
|
||||
# in the $DEFAULT_HOST and $DEFAULT_PORT shell environment variables.
|
||||
#
|
||||
# 5/22/2013 Chin J. Chen
|
||||
##
|
||||
import os
|
||||
from dynamicserialize.dstypes.gov.noaa.nws.ncep.common.dataplugin.gpd.query import GenericPointDataReqMsg
|
||||
from ufpy import ThriftClient
|
||||
|
||||
|
||||
class GpdCliRequestHandler:
|
||||
""" Request Activity to EDEX."""
|
||||
|
||||
def __init__(self):
|
||||
self.host = os.getenv("DEFAULT_HOST", "localhost")
|
||||
self.port = os.getenv("DEFAULT_PORT", "9581")
|
||||
self.client = ThriftClient.ThriftClient(self.host, self.port)
|
||||
|
||||
def getGpdProdInfo(self, prodName, reqType):
|
||||
req = GenericPointDataReqMsg()
|
||||
req.setReqType(reqType)
|
||||
req.setProductName(prodName)
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
|
||||
def getGpdProduct(self, refTime,prodName , reqType,querySpecifiedProductVersion=None,versionNum=None ):
|
||||
req = GenericPointDataReqMsg()
|
||||
req.setReqType(reqType)
|
||||
req.setRefTime(refTime)
|
||||
req.setProductName(prodName)
|
||||
if (querySpecifiedProductVersion!= None and versionNum !=None):
|
||||
req.setQuerySpecifiedProductVersion(querySpecifiedProductVersion)
|
||||
req.setProductVersion(versionNum)
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
|
||||
|
||||
def getGpdStationProduct(self, stnId, refTime,prodName , reqType,querySpecifiedProductVersion=None,versionNum=None ):
|
||||
req = GenericPointDataReqMsg()
|
||||
req.setReqType(reqType)
|
||||
req.setStnId(stnId)
|
||||
req.setRefTime(refTime)
|
||||
req.setProductName(prodName)
|
||||
if (querySpecifiedProductVersion!= None and versionNum !=None):
|
||||
req.setQuerySpecifiedProductVersion(querySpecifiedProductVersion)
|
||||
req.setProductVersion(versionNum)
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
|
||||
def getGpdMovingProduct(self, slat, slon, refTime,prodName , reqType,querySpecifiedProductVersion=None,versionNum=None ):
|
||||
req = GenericPointDataReqMsg()
|
||||
req.setReqType(reqType)
|
||||
req.setSlon(slon)
|
||||
req.setSlat(slat)
|
||||
req.setRefTime(refTime)
|
||||
req.setProductName(prodName)
|
||||
if (querySpecifiedProductVersion!= None and versionNum !=None):
|
||||
req.setQuerySpecifiedProductVersion(querySpecifiedProductVersion)
|
||||
req.setProductVersion(versionNum)
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
|
||||
def storeGpdGempakProduct(self, gpdGempak, prodName, maxNumLevel,versionNum):
|
||||
req = GenericPointDataReqMsg()
|
||||
req.setReqType("STORE_GPD_PRODUCT_FROM_GEMPAK_TBL")
|
||||
req.setGpdDataString(gpdGempak)
|
||||
req.setProductName(prodName)
|
||||
req.setProductVersion(versionNum)
|
||||
req.setMaxNumLevel(maxNumLevel)
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
|
||||
def storeGpdXmlProduct(self, gpdXml):
|
||||
req = GenericPointDataReqMsg()
|
||||
req.setReqType("STORE_GPD_PRODUCT_FROM_XML")
|
||||
req.setGpdDataString(gpdXml)
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
|
||||
def storeGpdProductInfo(self, gpdXml):
|
||||
req = GenericPointDataReqMsg()
|
||||
req.setReqType("STORE_GPD_PRODUCT_INFO_FROM_XML")
|
||||
req.setGpdDataString(gpdXml)
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
'''
|
||||
def purgeGpdProd(self, prodName, refTime=None, all=None):
|
||||
req = GenericPointDataReqMsg()
|
||||
if(all == "yes"):
|
||||
req.setReqType("PURGE_GPD_PRODUCT_ALLTIME")
|
||||
else:
|
||||
req.setReqType("PURGE_GPD_PRODUCT_ONETIME")
|
||||
if(refTime!=None):
|
||||
req.setRefTime(refTime)
|
||||
else:
|
||||
return "reference time required for purging"
|
||||
req.setProductName(prodName)
|
||||
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
'''
|
||||
def purgeGpdExpired(self):
|
||||
req = GenericPointDataReqMsg()
|
||||
req.setReqType("PURGE_GPD_EXPIRED_PRODUCT")
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
|
||||
def purgeGpdAll(self):
|
||||
req = GenericPointDataReqMsg()
|
||||
req.setReqType("PURGE_GPD_ALL_PRODUCTS")
|
||||
resp = self.client.sendRequest(req)
|
||||
return resp
|
||||
|
||||
|
|
@ -1,693 +0,0 @@
|
|||
##
|
||||
# This script is used to query Generic Point Data database from EDEX.
|
||||
#
|
||||
# 5/22/2013 Chin J. Chen
|
||||
##
|
||||
import io
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
import GpdCliRequestHandler
|
||||
from ufpy import UsageArgumentParser
|
||||
from dynamicserialize.dstypes.gov.noaa.nws.ncep.common.dataplugin.gpd.query import GenericPointDataReqMsg
|
||||
from dynamicserialize.dstypes.java.util import Date
|
||||
|
||||
logger = None
|
||||
parser = None
|
||||
USAGE_MESSAGE = \
|
||||
"""
|
||||
<To query product information in XML format, result saved at optional filePath >
|
||||
gpd qix --p prodName --f filePath
|
||||
<To query and list product information in XML format >
|
||||
gpd qixl --p prodName
|
||||
<To query a product (all stations) in XML format, optional version number, result saved at optional filePath >
|
||||
gpd qpx --p prodName --t referenceTime [--f filePath --v versionNum]
|
||||
<To query and list a product (all stations) in XML format, optional version number >
|
||||
gpd qpxl --p prodName --t referenceTime [--v versionNum]
|
||||
<To query a station product (single station) in XML format,optional version number, result saved at optional filePath >
|
||||
gpd qsx --p prodName --t referenceTime --id stationId [--f filePath --v versionNum]
|
||||
<To query and list a station product (single station) in XML format, optional version number >
|
||||
gpd qsxl --p prodName --t referenceTime --id stationId [--v versionNum]
|
||||
<To query a moving product in XML format, optional version number result saved at optional filePath >
|
||||
gpd qmx --p prodName --t referenceTime --slat latitude --slon longitude [--f filePath --v versionNum]
|
||||
<To query and list a moving product in XML format,optional version number >
|
||||
gpd qmxl --p prodName --t referenceTime --slat latitude --slon longitude [--v versionNum]
|
||||
<To query product information in Gempak format, result saved at filePath >
|
||||
<To store product XML file at filePath to EDEX server database>
|
||||
gpd spx --f filePath
|
||||
<To store product GEMPAK file at filePath to EDEX server database>
|
||||
gpd spg --f filePath --p prodName [--v versionNum]
|
||||
<To query product information in Gempak format result saved at filePath>
|
||||
gpd qig --p prodName --f filePath
|
||||
<To query and list product information in Gempak format >
|
||||
gpd qigl --p prodName
|
||||
<To query a product (all stations) in Gempak format, optional version number, result saved at filePath >
|
||||
gpd qpg --p prodName --t referenceTime [--f filePath --v versionNum]
|
||||
<To query and list a product (all stations) in Gempak format, optional version number >
|
||||
gpd qpgl --p prodName --t referenceTime [--v versionNum]
|
||||
<To query a station product (single station) in Gempak format,optional version number, result saved at optional filePath >
|
||||
gpd qsg --p prodName --t referenceTime --id stationId [--f filePath --v versionNum]
|
||||
<To query and list a station product (single station) in Gempak format, optional version number >
|
||||
gpd qsgl --p prodName --t referenceTime --id stationId [--v versionNum]
|
||||
<To query a moving product in Gempak format, optional version number result saved at optional filePath >
|
||||
gpd qmg --p prodName --t referenceTime --slat latitude --slon longitude [--f filePath --v versionNum]
|
||||
<To query and list a moving product in Gempak format, optional version number >
|
||||
gpd qmgl --p prodName --t referenceTime --slat latitude --slon longitude [--v versionNum]
|
||||
<To purge expired products from DB and HDF5>
|
||||
gpd pe
|
||||
<To purge all products from DB and HDF5>
|
||||
gpd pa
|
||||
<To print this usage>
|
||||
gpd u
|
||||
#######
|
||||
NOTE: referenceTime string format yyyy-mm-dd HH:MM:SS, for example "2013-05-21 20:30:00"
|
||||
filePath - required when saving Gempak table or XML file
|
||||
filePath - optional when querying, if not provided, result will be saved at current directory
|
||||
versionNum - optional, if not provided, latest version is returned
|
||||
#######
|
||||
"""
|
||||
SUBCOMMAND_MESSAGE = \
|
||||
"""
|
||||
qix: To query product information, result saved at optional filePath
|
||||
qixl: To query and list product information
|
||||
qpx: To query a product (all stations), result saved at optional filePath
|
||||
qpxl: To query and list a product (all stations)
|
||||
qsx: To query a station product, result saved at optional filePath
|
||||
qsxl: To query and list a station product
|
||||
qmx: To query a moving product, result saved at optional filePath
|
||||
qmxl: To query and print a moving product
|
||||
spx: To store product XML file to EDEX server database
|
||||
spg: To store product GEMPAk table file to EDEX server database
|
||||
qig: To query product information, result saved at optional filePath
|
||||
qigl: To query and list product information
|
||||
qpg: To query a product (all stations), result saved at optional filePath
|
||||
qpgl: To query and list a product (all stations)
|
||||
qsg: To query a station product, result saved at optional filePath
|
||||
qsgl: To query and list a station product
|
||||
qmg: To query a moving product, result saved at optional filePath
|
||||
qmgl: To query and print a moving product
|
||||
pe: To purge expired products
|
||||
pa: To purge all products
|
||||
u: To print usage
|
||||
"""
|
||||
def __initLogger():
|
||||
global logger
|
||||
logger = logging.getLogger("gpd")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(logging.INFO)
|
||||
# Uncomment line below to enable debug-level logging
|
||||
ch.setLevel(logging.DEBUG)
|
||||
formatter = logging.Formatter("\n%(asctime)s %(name)s %(levelname)s: %(message)s", "%H:%M:%S")
|
||||
ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
|
||||
def __parseCommandLine():
|
||||
global parser
|
||||
parser = UsageArgumentParser.UsageArgumentParser(prog='gpd',description="Query or store point data database from EDEX.")#, usage=USAGE_MESSAGE)
|
||||
#parser.add_argument("-u", action="help",
|
||||
# help="show usage")
|
||||
|
||||
subparsers = parser.add_subparsers(help=USAGE_MESSAGE)
|
||||
|
||||
#to print usage
|
||||
parser_usage = subparsers.add_parser('u')
|
||||
parser_usage.set_defaults(func=__printUsage)
|
||||
|
||||
#To update/replace product information
|
||||
#parser_saveinfo = subparsers.add_parser('si')
|
||||
#parser_saveinfo.add_argument("--f", dest="filePath", action="store",required=True,
|
||||
# help=":target file path for return product")
|
||||
#parser_saveinfo.set_defaults(func=__saveProdInfo)
|
||||
|
||||
#To save a GPD product in XML format
|
||||
parser_saveprod_xml = subparsers.add_parser('spx')
|
||||
parser_saveprod_xml.add_argument("--f", dest="filePath", action="store",required=True,
|
||||
help=":target file path for return product")
|
||||
parser_saveprod_xml.set_defaults(func=__saveProdXml)
|
||||
|
||||
#To save a GPD product in GEMPAk table format
|
||||
parser_saveprod_gempak = subparsers.add_parser('spg')
|
||||
parser_saveprod_gempak.add_argument("--f", dest="filePath", action="store",required=True,
|
||||
help=":target file path for return product")
|
||||
parser_saveprod_gempak.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_saveprod_gempak.add_argument("--l", dest="maxNumLevel", action="store",required=True,
|
||||
help=":max number of level for product")
|
||||
parser_saveprod_gempak.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_saveprod_gempak.set_defaults(func=__saveProdGempak)
|
||||
|
||||
#To query product information
|
||||
parser_infoXml = subparsers.add_parser('qix')
|
||||
parser_infoXml.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_infoXml.add_argument("--f", dest="filePath", action="store",
|
||||
help=":target file path for return product")
|
||||
parser_infoXml.set_defaults(func=__getProdInfoXml)
|
||||
|
||||
parser_info_printXml = subparsers.add_parser('qixl')
|
||||
parser_info_printXml.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
#parser_info_printXml.add_argument("--f", dest="filePath", action="store",
|
||||
# help=":target file path for return product")
|
||||
parser_info_printXml.set_defaults(func=__getPrintProdInfoXml)
|
||||
|
||||
parser_infoGempak = subparsers.add_parser('qig')
|
||||
parser_infoGempak.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_infoGempak.add_argument("--f", dest="filePath", action="store",
|
||||
help=":target file path for return product")
|
||||
parser_infoGempak.set_defaults(func=__getProdInfoGempak)
|
||||
|
||||
parser_info_printGempak = subparsers.add_parser('qigl')
|
||||
parser_info_printGempak.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_info_printGempak.set_defaults(func=__getPrintProdInfoGempak)
|
||||
|
||||
#To query a station product (single station)
|
||||
parser_stnProdXml = subparsers.add_parser('qsx')
|
||||
parser_stnProdXml.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_stnProdXml.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_stnProdXml.add_argument("--id", dest="stnId", action="store",required=True,
|
||||
help=":station id of a product")
|
||||
parser_stnProdXml.add_argument("--f", dest="filePath", action="store",
|
||||
help=":target file path for return product")
|
||||
parser_stnProdXml.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_stnProdXml.set_defaults(func=__getStnProdXml)
|
||||
|
||||
parser_stnProdXml_print = subparsers.add_parser('qsxl')
|
||||
parser_stnProdXml_print.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_stnProdXml_print.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_stnProdXml_print.add_argument("--id", dest="stnId", action="store",required=True,
|
||||
help=":station id of a product")
|
||||
parser_stnProdXml_print.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_stnProdXml_print.set_defaults(func=__getPrintStnProdXml)
|
||||
|
||||
|
||||
parser_stnProdGempak = subparsers.add_parser('qsg')
|
||||
parser_stnProdGempak.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_stnProdGempak.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_stnProdGempak.add_argument("--id", dest="stnId", action="store",required=True,
|
||||
help=":station id of a product")
|
||||
parser_stnProdGempak.add_argument("--f", dest="filePath", action="store",
|
||||
help=":target file path for return product")
|
||||
parser_stnProdGempak.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_stnProdGempak.set_defaults(func=__getStnProdGempak)
|
||||
|
||||
parser_stnProdGempak_print = subparsers.add_parser('qsgl')
|
||||
parser_stnProdGempak_print.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_stnProdGempak_print.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_stnProdGempak_print.add_argument("--id", dest="stnId", action="store",required=True,
|
||||
help=":station id of a product")
|
||||
parser_stnProdGempak_print.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_stnProdGempak_print.set_defaults(func=__getPrintStnProdGempak)
|
||||
|
||||
#To query a moving product
|
||||
parser_movingProdXml = subparsers.add_parser('qmx')
|
||||
parser_movingProdXml.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_movingProdXml.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_movingProdXml.add_argument("--slat", dest="slat", type=float, action="store",required=True,
|
||||
help=":latitude of a moving product")
|
||||
parser_movingProdXml.add_argument("--slon", dest="slon", type=float, action="store",required=True,
|
||||
help=":longitude of a moving product")
|
||||
parser_movingProdXml.add_argument("--f", dest="filePath", action="store",
|
||||
help=":target file path for return product")
|
||||
parser_movingProdXml.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_movingProdXml.set_defaults(func=__getMovingProdXml)
|
||||
|
||||
parser_movingProdXml_print = subparsers.add_parser('qmxl')
|
||||
parser_movingProdXml_print.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_movingProdXml_print.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_movingProdXml_print.add_argument("--slat", dest="slat", type=float, action="store",required=True,
|
||||
help=":latitude of a moving product")
|
||||
parser_movingProdXml_print.add_argument("--slon", dest="slon", type=float, action="store",required=True,
|
||||
help=":longitude of a moving product")
|
||||
parser_movingProdXml_print.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_movingProdXml_print.set_defaults(func=__getPrintMovingProdXml)
|
||||
|
||||
|
||||
parser_movingProdGempak = subparsers.add_parser('qmg')
|
||||
parser_movingProdGempak.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_movingProdGempak.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_movingProdGempak.add_argument("--slat", dest="slat", type=float, action="store",required=True,
|
||||
help=":latitude of a moving product")
|
||||
parser_movingProdGempak.add_argument("--slon", dest="slon", type=float, action="store",required=True,
|
||||
help=":longitude of a moving product")
|
||||
parser_movingProdGempak.add_argument("--f", dest="filePath", action="store",
|
||||
help=":target file path for return product")
|
||||
parser_movingProdGempak.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_movingProdGempak.set_defaults(func=__getMovingProdGempak)
|
||||
|
||||
parser_movingProdGempak_print = subparsers.add_parser('qmgl')
|
||||
parser_movingProdGempak_print.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_movingProdGempak_print.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_movingProdGempak_print.add_argument("--slat", dest="slat", type=float, action="store",required=True,
|
||||
help=":latitude of a moving product")
|
||||
parser_movingProdGempak_print.add_argument("--slon", dest="slon", type=float, action="store",required=True,
|
||||
help=":longitude of a moving product")
|
||||
parser_movingProdGempak_print.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_movingProdGempak_print.set_defaults(func=__getPrintMovingProdGempak)
|
||||
|
||||
|
||||
#To query a product
|
||||
parser_prodXml = subparsers.add_parser('qpx')
|
||||
parser_prodXml.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_prodXml.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_prodXml.add_argument("--f", dest="filePath", action="store",
|
||||
help=":target file path for return product")
|
||||
parser_prodXml.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_prodXml.set_defaults(func=__getProdXml)
|
||||
|
||||
|
||||
parser_prodGempak = subparsers.add_parser('qpg')
|
||||
parser_prodGempak.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_prodGempak.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_prodGempak.add_argument("--f", dest="filePath", action="store",
|
||||
help=":target file path for return product")
|
||||
parser_prodGempak.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
parser_prodGempak.set_defaults(func=__getProdGempak)
|
||||
|
||||
parser_prodXml_print = subparsers.add_parser('qpxl')
|
||||
parser_prodXml_print.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_prodXml_print.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_prodXml_print.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
|
||||
parser_prodXml_print.set_defaults(func=__getPrintProdXml)
|
||||
|
||||
parser_prodGempak_print = subparsers.add_parser('qpgl')
|
||||
parser_prodGempak_print.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
help=":name of a Generic Point Data product")
|
||||
parser_prodGempak_print.add_argument("--t", dest="refTime", action="store",required=True,
|
||||
help=":reference time of a product")
|
||||
parser_prodGempak_print.add_argument("--v", dest="versionNum", action="store",
|
||||
help=":product version")
|
||||
|
||||
parser_prodGempak_print.set_defaults(func=__getPrintProdGempak)
|
||||
|
||||
|
||||
'''
|
||||
#parser_purge_prod = subparsers.add_parser('pp')
|
||||
#parser_purge_prod.add_argument("--p", dest="prodName", action="store",required=True,
|
||||
# help=":name of a Generic Point Data product")
|
||||
#parser_purge_prod.add_argument("--t", dest="refTime", action="store",
|
||||
# help=":reference time of a product")
|
||||
#parser_purge_prod.add_argument("--all", dest="all", action="store",
|
||||
# help=":yes")
|
||||
#parser_purge_prod.set_defaults(func=__purgeProd)
|
||||
'''
|
||||
|
||||
parser_purge_expired = subparsers.add_parser('pe')
|
||||
parser_purge_expired.set_defaults(func=__purgeExpired)
|
||||
|
||||
parser_purge_all = subparsers.add_parser('pa')
|
||||
parser_purge_all.set_defaults(func=__purgeAll)
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
#logger.debug("Command-line arguments: " + str(options))
|
||||
return options
|
||||
|
||||
def __convertTimeToDate(refTime):
|
||||
struct_time = time.strptime(refTime, "%Y-%m-%d %H:%M:%S")
|
||||
#print "returned tuple: %s " % struct_time
|
||||
#print "timeZone " + str(time.timezone) + " altimezone " + str(time.altzone)
|
||||
milsec = (time.mktime(struct_time)-time.altzone) * 1000
|
||||
date= Date()
|
||||
date.setTime(milsec)
|
||||
#print "time in msec: %s" % str(date.getTime())
|
||||
return date
|
||||
|
||||
def __createFilenameStringXml(name, refTime):
|
||||
filename = name + '@'+ refTime.replace(" ","@")+".xml"
|
||||
return filename
|
||||
|
||||
def __createFilenameStringGempak(name, refTime):
|
||||
filename = name + '@'+ refTime.replace(" ","@")+".gempak"
|
||||
return filename
|
||||
|
||||
def __getPrintProdInfoXml(options):
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
prodInfo = req.getGpdProdInfo(options.prodName, "GET_GPD_PRODUCT_INFO_XML")
|
||||
if(prodInfo != None):
|
||||
print(prodInfo)
|
||||
else:
|
||||
print("Query failed!")
|
||||
|
||||
def __getProdInfoXml(options):
|
||||
#if options.prodName == None:
|
||||
# parser.print_help()
|
||||
# return None
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
prodInfo = req.getGpdProdInfo(options.prodName,"GET_GPD_PRODUCT_INFO_XML")
|
||||
if(prodInfo != None):
|
||||
if(options.filePath == None):
|
||||
f = open(options.prodName+"Info.xml",'w')
|
||||
else:
|
||||
f = open(options.filePath,'w')
|
||||
f.write(prodInfo)
|
||||
return prodInfo
|
||||
else:
|
||||
print("Query failed!")
|
||||
return None
|
||||
|
||||
def __getPrintProdInfoGempak(options):
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
prodInfo = req.getGpdProdInfo(options.prodName, "GET_GPD_PRODUCT_INFO_GEMPAK_TBL")
|
||||
if(prodInfo != None):
|
||||
print(prodInfo)
|
||||
else:
|
||||
print("Query failed!")
|
||||
|
||||
def __getProdInfoGempak(options):
|
||||
#if options.prodName == None:
|
||||
# parser.print_help()
|
||||
# return None
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
prodInfo = req.getGpdProdInfo(options.prodName,"GET_GPD_PRODUCT_INFO_GEMPAK_TBL")
|
||||
if(prodInfo != None):
|
||||
if(options.filePath == None):
|
||||
f = open(options.prodName+"Info.gempak",'w')
|
||||
else:
|
||||
f = open(options.filePath,'w')
|
||||
f.write(prodInfo)
|
||||
return prodInfo
|
||||
else:
|
||||
print("Query failed!")
|
||||
return None
|
||||
|
||||
#===========================================================================
|
||||
# print ("GPD Report::::::::::::::")
|
||||
# print str("Report Name: "+ prodInfo.getName())
|
||||
# print str("Master Level Name = " + prodInfo.getMasterLevel().getName())
|
||||
# print str("Master Level Description = " + prodInfo.getMasterLevel().getDescription())
|
||||
# print str("Master Level Type = " + prodInfo.getMasterLevel().getType())
|
||||
# print str("Master Level Unit String = " + prodInfo.getMasterLevel().getUnitString())
|
||||
# print ("Max NUmber of Level = " + str(prodInfo.getMaxNumberOfLevel()))
|
||||
# print ("Parameters:")
|
||||
# parmLst =prodInfo.getParameterLst()
|
||||
# i = 1
|
||||
# for parm in parmLst:
|
||||
# print ("Parameter "+ str(i)+ ": Abbreviation="+ str(parm.getAbbreviation())+ " Unit="+str(parm.getUnitString())+ " Name =" + str(parm.getName()))
|
||||
# i=i+1
|
||||
#===========================================================================
|
||||
|
||||
def __getStnProdXml(options):
|
||||
#if options.prodName == None or options.refTime == None or options.stnId == None:
|
||||
# parser.print_help()
|
||||
# return None
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
|
||||
if(options.versionNum == None):
|
||||
stnProd = req.getGpdStationProduct(options.stnId, date,options.prodName,"GET_GPD_STATION_PRODUCT_XML")
|
||||
else:
|
||||
stnProd = req.getGpdStationProduct(options.stnId, date,options.prodName, "GET_GPD_STATION_PRODUCT_XML", True, int(options.versionNum))
|
||||
if(stnProd!=None):
|
||||
if(options.filePath == None):
|
||||
filename = __createFilenameStringXml((options.prodName+'@'+options.stnId),options.refTime)
|
||||
else:
|
||||
filename = options.filePath
|
||||
f = open(filename,'w')
|
||||
f.write(stnProd)
|
||||
return stnProd
|
||||
else:
|
||||
print("Query failed!")
|
||||
return None
|
||||
def __getPrintStnProdXml(options):
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
|
||||
if(options.versionNum == None):
|
||||
stnProd = req.getGpdStationProduct(options.stnId, date,options.prodName,"GET_GPD_STATION_PRODUCT_XML")
|
||||
else:
|
||||
stnProd = req.getGpdStationProduct(options.stnId, date,options.prodName, "GET_GPD_STATION_PRODUCT_XML",True, int(options.versionNum))
|
||||
if(stnProd != None):
|
||||
print(stnProd)
|
||||
else:
|
||||
print("Query failed!")
|
||||
|
||||
def __getStnProdGempak(options):
|
||||
#if options.prodName == None or options.refTime == None or options.stnId == None:
|
||||
# parser.print_help()
|
||||
# return None
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
|
||||
if(options.versionNum == None):
|
||||
stnProd = req.getGpdStationProduct(options.stnId, date,options.prodName,"GET_GPD_STATION_PRODUCT_GEMPAK_TBL")
|
||||
else:
|
||||
stnProd = req.getGpdStationProduct(options.stnId, date,options.prodName, "GET_GPD_STATION_PRODUCT_GEMPAK_TBL", True, int(options.versionNum))
|
||||
if(stnProd!=None):
|
||||
if(options.filePath == None):
|
||||
filename = __createFilenameStringGempak((options.prodName+'@'+options.stnId),options.refTime)
|
||||
else:
|
||||
filename = options.filePath
|
||||
f = open(filename,'w')
|
||||
f.write(stnProd)
|
||||
return stnProd
|
||||
else:
|
||||
print("Query failed!")
|
||||
return None
|
||||
def __getPrintStnProdGempak(options):
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
|
||||
if(options.versionNum == None):
|
||||
stnProd = req.getGpdStationProduct(options.stnId, date,options.prodName,"GET_GPD_STATION_PRODUCT_GEMPAK_TBL")
|
||||
else:
|
||||
stnProd = req.getGpdStationProduct(options.stnId, date,options.prodName, "GET_GPD_STATION_PRODUCT_GEMPAK_TBL",True, int(options.versionNum))
|
||||
if(stnProd != None):
|
||||
print(stnProd)
|
||||
else:
|
||||
print("Query failed!")
|
||||
|
||||
def __getMovingProdXml(options):
|
||||
#if options.prodName == None or options.refTime == None or options.slat == None or options.slon == None:
|
||||
# parser.print_help()
|
||||
# return None
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
if(options.versionNum == None):
|
||||
stnProd = req.getGpdMovingProduct(options.slat, options.slon, date,options.prodName,"GET_GPD_MOVING_PRODUCT_XML")
|
||||
else:
|
||||
stnProd = req.getGpdMovingProduct(options.slat, options.slon, date,options.prodName, "GET_GPD_MOVING_PRODUCT_XML",True, int(options.versionNum))
|
||||
if(stnProd!=None):
|
||||
if(options.filePath == None):
|
||||
filename = __createFilenameStringXml((options.prodName+'@'+str(options.slat)+'#'+str(options.slon)),options.refTime)
|
||||
else:
|
||||
filename = options.filePath
|
||||
f = open(filename,'w')
|
||||
f.write(stnProd)
|
||||
return stnProd
|
||||
else:
|
||||
print("Query failed!")
|
||||
return None
|
||||
def __getPrintMovingProdXml(options):
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
if(options.versionNum == None):
|
||||
stnProd = req.getGpdMovingProduct(options.slat, options.slon, date,options.prodName,"GET_GPD_MOVING_PRODUCT_XML")
|
||||
else:
|
||||
stnProd = req.getGpdMovingProduct(options.slat, options.slon, date,options.prodName, "GET_GPD_MOVING_PRODUCT_XML", True, int(options.versionNum))
|
||||
if(stnProd != None):
|
||||
print(stnProd)
|
||||
else:
|
||||
print("Query failed!")
|
||||
|
||||
def __getMovingProdGempak(options):
|
||||
#if options.prodName == None or options.refTime == None or options.slat == None or options.slon == None:
|
||||
# parser.print_help()
|
||||
# return None
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
if(options.versionNum == None):
|
||||
stnProd = req.getGpdMovingProduct(options.slat, options.slon, date,options.prodName,"GET_GPD_MOVING_PRODUCT_GEMPAK_TBL")
|
||||
else:
|
||||
stnProd = req.getGpdMovingProduct(options.slat, options.slon, date,options.prodName, "GET_GPD_MOVING_PRODUCT_GEMPAK_TBL",True, int(options.versionNum))
|
||||
if(stnProd!=None):
|
||||
if(options.filePath == None):
|
||||
filename = __createFilenameStringGempak((options.prodName+'@'+str(options.slat)+'#'+str(options.slon)),options.refTime)
|
||||
else:
|
||||
filename = options.filePath
|
||||
f = open(filename,'w')
|
||||
f.write(stnProd)
|
||||
return stnProd
|
||||
else:
|
||||
print("Query failed!")
|
||||
return None
|
||||
def __getPrintMovingProdGempak(options):
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
if(options.versionNum == None):
|
||||
stnProd = req.getGpdMovingProduct(options.slat, options.slon, date,options.prodName,"GET_GPD_MOVING_PRODUCT_GEMPAK_TBL")
|
||||
else:
|
||||
stnProd = req.getGpdMovingProduct(options.slat, options.slon, date,options.prodName, "GET_GPD_MOVING_PRODUCT_GEMPAK_TBL", True, int(options.versionNum))
|
||||
if(stnProd != None):
|
||||
print(stnProd)
|
||||
else:
|
||||
print("Query failed!")
|
||||
|
||||
def __getProdXml(options):
|
||||
#if options.prodName == None or options.refTime == None:
|
||||
# parser.print_help()
|
||||
# return None
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
if(options.versionNum == None):
|
||||
prod = req.getGpdProduct( date,options.prodName,"GET_GPD_PRODUCT_XML")
|
||||
else:
|
||||
prod = req.getGpdProduct( date,options.prodName,"GET_GPD_PRODUCT_XML", True, int(options.versionNum))
|
||||
if(prod != None):
|
||||
if(options.filePath == None):
|
||||
filename = __createFilenameStringXml(options.prodName,options.refTime)
|
||||
else:
|
||||
filename = options.filePath
|
||||
f = open(filename,'w')
|
||||
f.write(prod)
|
||||
return prod
|
||||
else:
|
||||
print("Query failed!")
|
||||
return None
|
||||
|
||||
def __getPrintProdXml(options):
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
if(options.versionNum == None):
|
||||
prod = req.getGpdProduct( date,options.prodName,"GET_GPD_PRODUCT_XML")
|
||||
else:
|
||||
prod = req.getGpdProduct( date,options.prodName,"GET_GPD_PRODUCT_XML", True, int(options.versionNum))
|
||||
if(prod != None):
|
||||
print(prod)
|
||||
else:
|
||||
print("Query failed!")
|
||||
|
||||
def __getProdGempak(options):
|
||||
#if options.prodName == None or options.refTime == None:
|
||||
# parser.print_help()
|
||||
# return None
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
if(options.versionNum == None):
|
||||
prod = req.getGpdProduct( date,options.prodName,"GET_GPD_PRODUCT_GEMPAK_TBL")
|
||||
else:
|
||||
prod = req.getGpdProduct( date,options.prodName,"GET_GPD_PRODUCT_GEMPAK_TBL", True, int(options.versionNum))
|
||||
if(prod != None):
|
||||
if(options.filePath == None):
|
||||
filename = __createFilenameStringGempak(options.prodName,options.refTime)
|
||||
else:
|
||||
filename = options.filePath
|
||||
f = open(filename,'w')
|
||||
f.write(prod)
|
||||
return prod
|
||||
else:
|
||||
print("Query failed!")
|
||||
return None
|
||||
|
||||
def __getPrintProdGempak(options):
|
||||
date = __convertTimeToDate(options.refTime)
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
if(options.versionNum == None):
|
||||
prod = req.getGpdProduct( date,options.prodName,"GET_GPD_PRODUCT_GEMPAK_TBL")
|
||||
else:
|
||||
prod = req.getGpdProduct( date,options.prodName,"GET_GPD_PRODUCT_GEMPAK_TBL", True, int(options.versionNum))
|
||||
if(prod != None):
|
||||
print(prod)
|
||||
else:
|
||||
print("Query failed!")
|
||||
|
||||
#def __purgeProd(options):
|
||||
# req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
# req.purgeGpdProd(options.prodName,options.refTime, option.all)
|
||||
|
||||
def __purgeExpired(options):
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
req.purgeGpdExpired()
|
||||
|
||||
def __purgeAll(options):
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
req.purgeGpdAll()
|
||||
|
||||
def __printUsage(options):
|
||||
print(USAGE_MESSAGE)
|
||||
|
||||
|
||||
def __saveProdXml(options):
|
||||
# read in XML from input file
|
||||
xmlfile = io.open(options.filePath, 'rb')
|
||||
gpdXML = xmlfile.read()
|
||||
xmlfile.close()
|
||||
|
||||
# Store GPD report to EDEX
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
result = req.storeGpdXmlProduct(gpdXML)
|
||||
if result==None:
|
||||
print("Store action failed!")
|
||||
else:
|
||||
print(result)
|
||||
|
||||
def __saveProdGempak(options):
|
||||
# read in XML from input file
|
||||
gpkfile = io.open(options.filePath, 'rb')
|
||||
gpdGempak = gpkfile.read()
|
||||
gpkfile.close()
|
||||
|
||||
# Store GPD report to EDEX
|
||||
req= GpdCliRequestHandler.GpdCliRequestHandler()
|
||||
maxNumLevel = options.maxNumLevel
|
||||
|
||||
if(options.versionNum == None):
|
||||
result = req.storeGpdGempakProduct(gpdGempak,options.prodName,int(maxNumLevel),0)
|
||||
else:
|
||||
result = req.storeGpdGempakProduct(gpdGempak,options.prodName,int(maxNumLevel),int(options.versionNum))
|
||||
|
||||
if result==None:
|
||||
print("Store action failed!")
|
||||
else:
|
||||
print(result)
|
||||
|
||||
def main():
|
||||
__initLogger()
|
||||
#logger.info("Starting Query report.")
|
||||
options = __parseCommandLine()
|
||||
#vars(options)
|
||||
options.func(options)
|
||||
#logger.info("queried report name: " + options.prodName)
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,175 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
##
|
||||
# This script is a collection of utility function to be used for extracting PGEN
|
||||
# products from EDEX and to store PGEN activities to EDEX.
|
||||
#
|
||||
# Users can override the default EDEX server and port name by specifying them
|
||||
# in the $DEFAULT_HOST and $DEFAULT_PORT shell environment variables.
|
||||
#
|
||||
##
|
||||
|
||||
import os
|
||||
import re
|
||||
import xml.etree.ElementTree as ET
|
||||
import lib.CommHandler as CH
|
||||
|
||||
class ActivityUtil:
|
||||
|
||||
#
|
||||
# Sends a CatalogQuery to the EDEX uEngine to get a list of
|
||||
# PGEN Activity Types, Subtypes, Labels, refTimes, and associated
|
||||
# dataURIs in the pgen database tables.
|
||||
#
|
||||
def getActivityMap(self):
|
||||
script='''import CatalogQuery
|
||||
query = CatalogQuery.CatalogQuery("pgen")
|
||||
query.addReturnedField("activityType")
|
||||
query.addReturnedField("activitySubtype")
|
||||
query.addReturnedField("activityLabel")
|
||||
query.addReturnedField("dataTime.refTime")
|
||||
query.addReturnedField("activityName")
|
||||
query.addReturnedField("dataURI")
|
||||
return query.execute()'''
|
||||
|
||||
service = '/services/pyproductjaxb'
|
||||
host = os.getenv("DEFAULT_HOST", "localhost")
|
||||
port = os.getenv("DEFAULT_PORT", "9581")
|
||||
connection=str(host+":"+port)
|
||||
ch = CH.CommHandler(connection,service)
|
||||
ch.process(script)
|
||||
|
||||
if not ch.isGoodStatus():
|
||||
print ch.formatResponse()
|
||||
exit(1)
|
||||
|
||||
return self.__generateMap( ch.getContents() )
|
||||
|
||||
#
|
||||
# Generates a map of activity types/subtypes, labels, refTimes, and dataURIs from
|
||||
# the XML returned from EDEX uEngine
|
||||
#
|
||||
# The map is a dictionary (dict) of Activity Types in form of "type(subtype)" whose values
|
||||
# are a list of dicts which have keys "activityType", "activityLabel", "dataTime.refTime",
|
||||
# and "dataURI".
|
||||
#
|
||||
def __generateMap(self, xml):
|
||||
aMap = dict()
|
||||
tree = ET.fromstring(xml)
|
||||
for item in tree.iter('items'):
|
||||
record = dict()
|
||||
for attr in item.iter('attributes'):
|
||||
record.update( {attr.attrib['field'] : attr.attrib['value'] } )
|
||||
|
||||
atype = record['activityType']
|
||||
stype = record['activitySubtype']
|
||||
if ( stype != None and len(stype.lstrip()) > 0):
|
||||
atype = atype + "(" + stype.lstrip() + ")"
|
||||
|
||||
if aMap.has_key(atype):
|
||||
aMap[atype].append(record)
|
||||
else:
|
||||
aMap.update( {atype: [record]} )
|
||||
|
||||
return aMap
|
||||
|
||||
#
|
||||
# Compare if a command line string matches an string in activity.
|
||||
# This uses string methods.
|
||||
#
|
||||
def matcher(self, cmdstr, activitystr):
|
||||
|
||||
matched = False
|
||||
if cmdstr == None:
|
||||
matched = True
|
||||
else:
|
||||
if activitystr == None:
|
||||
matched = False;
|
||||
else:
|
||||
realstr = cmdstr.strip("*")
|
||||
if ( cmdstr.startswith("*") ):
|
||||
if ( cmdstr.endswith("*") ):
|
||||
if ( activitystr.find( realstr ) >= 0 ):
|
||||
matched = True
|
||||
else:
|
||||
if activitystr.endswith( realstr):
|
||||
matched = True
|
||||
elif cmdstr.endswith("*"):
|
||||
if activitystr.startswith( realstr):
|
||||
matched = True
|
||||
else:
|
||||
if ( activitystr == cmdstr ):
|
||||
matched = True
|
||||
|
||||
return matched
|
||||
|
||||
#
|
||||
# Compare if a command line string matches an string in activity.
|
||||
# This uses regular expression matching.
|
||||
#
|
||||
# cmdstr - input from command line, could use "*" anywhere to match one or more character.
|
||||
# activitystr - value saved in PGEN DB for an activity, such as type, label, ...
|
||||
#
|
||||
def stringMatcher(self, cmdstr, activitystr):
|
||||
|
||||
matched = False
|
||||
|
||||
if cmdstr == None:
|
||||
matched = True
|
||||
elif activitystr == None:
|
||||
matched = False
|
||||
else:
|
||||
#parenthese should be escaped.
|
||||
ps = cmdstr.replace("(", "\(")
|
||||
pe = ps.replace(")", "\)")
|
||||
|
||||
# "*" could match any one or more characters.
|
||||
pn = pe.replace("*", "(.*)")
|
||||
|
||||
mb = re.match(pn, activitystr)
|
||||
if mb != None:
|
||||
matched = True
|
||||
|
||||
return matched
|
||||
|
||||
#
|
||||
# This method sends a CatalogQuery request to the EDEX uEngine
|
||||
# for the dataURI associated with the given activity type and label
|
||||
#
|
||||
def getDataURI( self, atype, label):
|
||||
|
||||
script='''import CatalogQuery
|
||||
query = CatalogQuery.CatalogQuery("pgen")
|
||||
query.addConstraint("activityType","{0}","=")
|
||||
query.addConstraint("activityLabel","{1}","=")
|
||||
query.addReturnedField("dataURI")
|
||||
query.addReturnedField("dataTime.refTime")
|
||||
return query.execute()'''.format(atype,label)
|
||||
|
||||
|
||||
service = '/services/pyproductjaxb'
|
||||
host = os.getenv("DEFAULT_HOST", "localhost")
|
||||
port = os.getenv("DEFAULT_PORT", "9581")
|
||||
connection=str(host+":"+port)
|
||||
ch = CH.CommHandler(connection,service)
|
||||
ch.process(script)
|
||||
|
||||
if not ch.isGoodStatus():
|
||||
print ch.formatResponse()
|
||||
exit(1)
|
||||
|
||||
logger.debug( ch.getContents() )
|
||||
return __parseResponse( ch.getContents() )
|
||||
|
||||
#
|
||||
# Parses the XML response from the uEngine and extracts
|
||||
# the value for the dataURI field. If multiple are returned, the last
|
||||
# one is used.
|
||||
#
|
||||
def __parseResponse(self, xml):
|
||||
tree = ET.fromstring(xml)
|
||||
for attr in tree.iter('attributes'):
|
||||
if attr.attrib['field'] == 'dataURI':
|
||||
duri = attr.attrib['value']
|
||||
|
||||
return duri
|
|
@ -1,60 +0,0 @@
|
|||
import os
|
||||
from ufpy import ThriftClient
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.datastorage.records import StringDataRecord
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.datastorage.records import ByteDataRecord
|
||||
from dynamicserialize.dstypes.gov.noaa.nws.ncep.common.dataplugin.pgen.request import RetrieveAllProductsRequest
|
||||
|
||||
|
||||
class ProductRetriever:
|
||||
""" Retrieves all PGEN products for a given Activity (dataURI) and writes them to separate files."""
|
||||
|
||||
def __init__(self,dataURI,label):
|
||||
self.dataURI = dataURI
|
||||
self.label = label
|
||||
self.fullpath = False
|
||||
self.outdir = os.getcwd()
|
||||
self.host = os.getenv("DEFAULT_HOST", "localhost")
|
||||
self.port = os.getenv("DEFAULT_PORT", "9581")
|
||||
self.client = ThriftClient.ThriftClient(self.host, self.port)
|
||||
|
||||
def setOutputDir(self, outdir):
|
||||
self.outdir = outdir
|
||||
|
||||
def setFullpath(self, fullpath):
|
||||
self.fullpath = fullpath
|
||||
|
||||
def _writeout(self,filename,bytes):
|
||||
outname = self.outdir + str(os.sep) + filename
|
||||
f = open(outname,"wb")
|
||||
f.write(bytes)
|
||||
f.close()
|
||||
|
||||
def getProducts(self):
|
||||
""" Sends ThriftClient request and writes out received files."""
|
||||
req = RetrieveAllProductsRequest()
|
||||
req.setDataURI(self.dataURI)
|
||||
resp = self.client.sendRequest(req)
|
||||
#os.mkdir(self.outdir)
|
||||
for item in resp:
|
||||
if item.getName() == "ActivityXML":
|
||||
if self.label.endswith(".xml"):
|
||||
filename = self.label
|
||||
else:
|
||||
filename = self.label + ".xml"
|
||||
else:
|
||||
filename = item.getName()
|
||||
|
||||
if ( self.fullpath ):
|
||||
path = self.dataURI
|
||||
fname = path.replace("/", ".") + "$" + filename
|
||||
filename = fname.lstrip().strip(".").replace("..", ".")
|
||||
|
||||
|
||||
if isinstance(item, StringDataRecord):
|
||||
self._writeout(filename,item.getStringData()[0])
|
||||
elif isinstance(item, ByteDataRecord):
|
||||
self._writeout(filename,item.getByteData())
|
||||
print "Extracted... " + filename
|
||||
|
||||
return resp
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
import os
|
||||
from ufpy import ThriftClient
|
||||
#from dynamicserialize.dstypes.com.raytheon.uf.common.datastorage.records import ByteDataRecord
|
||||
from dynamicserialize.dstypes.gov.noaa.nws.ncep.common.dataplugin.pgen.request import StoreActivityRequest
|
||||
from dynamicserialize.dstypes.gov.noaa.nws.ncep.common.dataplugin.pgen import ResponseMessageValidate
|
||||
|
||||
|
||||
class ProductStorer:
|
||||
""" Store a PGEN Activity (XML) to EDEX."""
|
||||
|
||||
def __init__(self, activityInfo, activityXML):
|
||||
self.activityInfo = activityInfo
|
||||
self.activityXML = activityXML
|
||||
self.host = os.getenv("DEFAULT_HOST", "localhost")
|
||||
self.port = os.getenv("DEFAULT_PORT", "9581")
|
||||
self.client = ThriftClient.ThriftClient(self.host, self.port)
|
||||
|
||||
def storeActivity(self):
|
||||
""" Sends ThriftClient request to store Activity."""
|
||||
req = StoreActivityRequest()
|
||||
req.setActivityInfo(self.activityInfo)
|
||||
req.setActivityXML(self.activityXML)
|
||||
resp = self.client.sendRequest(req)
|
||||
if resp.getResult:
|
||||
return resp.getDataURI()
|
||||
else:
|
||||
return None
|
||||
|
|
@ -1,262 +0,0 @@
|
|||
#!/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
|
||||
# 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.
|
||||
#
|
||||
##
|
||||
|
||||
import os
|
||||
import logging
|
||||
import xml.etree.ElementTree as ET
|
||||
from Tkinter import *
|
||||
|
||||
from ufpy import UsageArgumentParser
|
||||
import lib.CommHandler as CH
|
||||
import ProductRetriever
|
||||
import ActivityUtil
|
||||
|
||||
logger = None
|
||||
def __initLogger():
|
||||
global logger
|
||||
logger = logging.getLogger("retrieveActivity")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(logging.INFO)
|
||||
# Uncomment line below to enable debug-level logging
|
||||
#ch.setLevel(logging.DEBUG)
|
||||
formatter = logging.Formatter("%(asctime)s %(name)s %(levelname)s: %(message)s", "%H:%M:%S")
|
||||
ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
|
||||
#
|
||||
# Parses command line input and store in "options".
|
||||
#
|
||||
def __parseCommandLine():
|
||||
parser = UsageArgumentParser.UsageArgumentParser(prog='retrieveActivity',description="Retrieve PGEN Activities from EDEX. When invoked without any arguments, retrieveActivity is run in interactive mode.")
|
||||
bgroup = parser.add_argument_group(title='batch',description='For running in scripts and/or batch mode.')
|
||||
|
||||
bgroup.add_argument("-type", action="store", dest="type",
|
||||
help="Activity Type being requested",
|
||||
required=False, metavar=" type")
|
||||
bgroup.add_argument("-st", action="store", dest="subtype",
|
||||
help="Activity Subtype being requested",
|
||||
required=False, metavar=" subtype")
|
||||
bgroup.add_argument("-tag", action="store", dest="tagId",
|
||||
help="Tag ID being requested",
|
||||
required=False, metavar=" tag")
|
||||
bgroup.add_argument("-l", action="store", dest="label",
|
||||
help="Activity Label being requested",
|
||||
required=False, metavar=" label")
|
||||
bgroup.add_argument("-time", action="store", dest="reftime",
|
||||
help="Activity Ref Time being requested (YYYY-MM-DD_HH:MM)",
|
||||
required=False, metavar=" time")
|
||||
bgroup.add_argument("-n", action="store", dest="name",
|
||||
help="Activity Name being requested",
|
||||
required=False, metavar=" name")
|
||||
bgroup.add_argument("-f", action="store", dest="fullpath",
|
||||
help="Write out XML with full path? (Yes/No)",
|
||||
required=False, metavar=" Yes/No")
|
||||
|
||||
bgroup = parser.add_argument_group(title='Note',description='Pattern matching with "*" is allowed for -type, -l, -time, and -n. E.g., -l "*CCFP*3*" will match any activities whose label contains CCFP and 3.')
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
options.interactive = 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
|
||||
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"
|
||||
exit(0)
|
||||
|
||||
logger.debug("Command-line arguments: " + str(options))
|
||||
return options
|
||||
|
||||
#
|
||||
# Main program.
|
||||
#
|
||||
def main():
|
||||
__initLogger()
|
||||
logger.info("Starting retrieveActivity.")
|
||||
options = __parseCommandLine()
|
||||
|
||||
if options.interactive :
|
||||
# Launch interactive GUI
|
||||
logger.info("Running in interactive mode.")
|
||||
root = Tk()
|
||||
root.title("Retrieve Activity")
|
||||
app = RetrieveGui(master=root)
|
||||
app.mainloop()
|
||||
root.destroy()
|
||||
else:
|
||||
# Retrieve all activities abnd build a map of record using
|
||||
# type(subtype) as key.
|
||||
mu = ActivityUtil.ActivityUtil()
|
||||
activityMap = mu.getActivityMap()
|
||||
|
||||
# Replace a space with the "_" in the type, accepting "CONV SIGMET" & "OUTL SIGMET".
|
||||
reqtype = None
|
||||
if ( options.type != None ):
|
||||
reqtype = options.type.replace(" ", "_");
|
||||
if ( options.subtype != None ) :
|
||||
reqtype = options.type + "(" + options.subtype + ")"
|
||||
|
||||
# Form the matching pattern for tag ID
|
||||
tagID = None
|
||||
if ( options.tagId != None):
|
||||
tagID = "*\." + options.tagId + "\.*"
|
||||
|
||||
records = []
|
||||
for key in activityMap.iterkeys():
|
||||
recs = activityMap[key]
|
||||
for rec in recs:
|
||||
if ( mu.stringMatcher(options.label, rec["activityLabel"]) and
|
||||
mu.stringMatcher(tagID, rec["activityLabel"]) and
|
||||
mu.stringMatcher(reqtype, key ) and
|
||||
mu.stringMatcher(options.name, rec["activityName"] ) ):
|
||||
#Remove sec.msec from record's refTime
|
||||
dbRefTime = rec["dataTime.refTime"]
|
||||
dotIndex = dbRefTime.rfind(":")
|
||||
if ( dotIndex > 0 ):
|
||||
shortTime = dbRefTime[:dotIndex]
|
||||
else:
|
||||
shortTime = dbRefTime
|
||||
|
||||
#Replace the "_" with a whitespace in reftime.
|
||||
optionTime = options.reftime
|
||||
if ( optionTime != None ):
|
||||
optionTime = optionTime.replace("_", " ")
|
||||
|
||||
if ( mu.stringMatcher( optionTime, shortTime ) ):
|
||||
records.append( rec )
|
||||
|
||||
for rec in records:
|
||||
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.")
|
||||
|
||||
#
|
||||
# Interactive GUI for PGEN activity retrieval
|
||||
#
|
||||
class RetrieveGui(Frame):
|
||||
""" Interactive GUI for PGEN activity retrieval """
|
||||
|
||||
def __init__(self, master=None):
|
||||
""" Initialize Frame and create widgets """
|
||||
Frame.__init__(self, master)
|
||||
self.pack()
|
||||
self.createWidgets()
|
||||
|
||||
def getProducts(self):
|
||||
|
||||
# if an activity type and label have been selected, get products and write them out.
|
||||
if len(self.typeList.curselection()) != 0 and len(self.nameList.curselection()) != 0:
|
||||
type = self.typeList.get(self.typeList.curselection())
|
||||
|
||||
items = self.nameList.curselection()
|
||||
for i in items :
|
||||
idx = int(i)
|
||||
label = self.nameList.get(idx)
|
||||
dataURI = self.activityMap[type][idx]['dataURI']
|
||||
|
||||
pr = ProductRetriever.ProductRetriever(dataURI, label)
|
||||
pr.getProducts()
|
||||
|
||||
def createWidgets(self):
|
||||
activityType = Label(self)
|
||||
activityType["text"] = "Activity Type"
|
||||
activityType.pack()
|
||||
|
||||
# Activity Type list section
|
||||
frame = Frame(self)
|
||||
vscrollbar = Scrollbar(frame, orient=VERTICAL)
|
||||
hscrollbar = Scrollbar(frame, orient=HORIZONTAL)
|
||||
self.typeList = Listbox(frame,selectmode=BROWSE,yscrollcommand=vscrollbar.set,xscrollcommand=hscrollbar.set,exportselection=0,width=50,height=15,bg="white")
|
||||
vscrollbar.config(command=self.typeList.yview)
|
||||
hscrollbar.config(command=self.typeList.xview)
|
||||
vscrollbar.pack(side=RIGHT, fill=Y)
|
||||
hscrollbar.pack(side=BOTTOM, fill=BOTH)
|
||||
|
||||
self.typeList.pack(side=LEFT,fill=BOTH,expand=1)
|
||||
frame.pack()
|
||||
self.typeList.insert(END,"Loading...") # Temporary item while data are being requested from EDEX
|
||||
|
||||
activityLabel = Label(self)
|
||||
activityLabel["text"] = "Activity Label"
|
||||
activityLabel.pack()
|
||||
|
||||
# Activity Label list section
|
||||
frame2 = Frame(self)
|
||||
vscrollbar2 = Scrollbar(frame2, orient=VERTICAL)
|
||||
hscrollbar2 = Scrollbar(frame2, orient=HORIZONTAL)
|
||||
self.nameList = Listbox(frame2,yscrollcommand=vscrollbar2.set,xscrollcommand=hscrollbar2.set,exportselection=0, width=50,height=15,bg="white", selectmode=EXTENDED)
|
||||
vscrollbar2.config(command=self.nameList.yview)
|
||||
hscrollbar2.config(command=self.nameList.xview)
|
||||
vscrollbar2.pack(side=RIGHT, fill=Y)
|
||||
hscrollbar2.pack(side=BOTTOM, fill=BOTH)
|
||||
self.nameList.pack()
|
||||
frame2.pack()
|
||||
|
||||
self.QUIT = Button(self)
|
||||
self.QUIT["text"] = "QUIT"
|
||||
self.QUIT["fg"] = "red"
|
||||
self.QUIT["command"] = self.quit
|
||||
|
||||
self.QUIT.pack({"side": "right"})
|
||||
|
||||
self.retrieve = Button(self)
|
||||
self.retrieve["text"] = "Retrieve",
|
||||
self.retrieve["command"] = self.getProducts
|
||||
|
||||
self.retrieve.pack({"side": "left"})
|
||||
|
||||
#
|
||||
# Get all Activity Types and Labels from EDEX for use in selection ListBoxes.
|
||||
# Insert list of Types in Type Listbox
|
||||
#
|
||||
self.activityMap = ActivityUtil.ActivityUtil().getActivityMap()
|
||||
self.typeList.delete(0,END)
|
||||
for key in self.activityMap.iterkeys():
|
||||
self.typeList.insert(END,key)
|
||||
self.current = None
|
||||
self.poll()
|
||||
|
||||
#
|
||||
# Continuously polls for user selection changes in the Activity Type ListBox
|
||||
#
|
||||
def poll(self):
|
||||
now = self.typeList.curselection()
|
||||
if len(now) == 0:
|
||||
self.after(250, self.poll)
|
||||
return
|
||||
|
||||
if now != self.current:
|
||||
self.typeList_has_changed(now)
|
||||
self.current = now
|
||||
self.after(250, self.poll)
|
||||
|
||||
#
|
||||
# Replace the list of Activity Labels in the Label Listbox
|
||||
# with those associated with the current Activity Type selection
|
||||
#
|
||||
def typeList_has_changed(self, index):
|
||||
self.nameList.delete(0,END)
|
||||
for label in self.activityMap[ self.typeList.get(index) ]:
|
||||
self.nameList.insert(END, label['activityLabel'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,173 +0,0 @@
|
|||
##
|
||||
# This script is used to store a PGEN Activity to EDEX.
|
||||
#
|
||||
# Users can override the default EDEX server and port name by specifying them
|
||||
# in the $DEFAULT_HOST and $DEFAULT_PORT shell environment variables.
|
||||
#
|
||||
##
|
||||
import io
|
||||
import logging
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from ufpy import UsageArgumentParser
|
||||
from dynamicserialize.dstypes.gov.noaa.nws.ncep.common.dataplugin.pgen import ActivityInfo
|
||||
import ProductStorer
|
||||
|
||||
logger = None
|
||||
def __initLogger():
|
||||
global logger
|
||||
logger = logging.getLogger("storeActivity")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(logging.INFO)
|
||||
# Uncomment line below to enable debug-level logging
|
||||
ch.setLevel(logging.DEBUG)
|
||||
formatter = logging.Formatter("%(asctime)s %(name)s %(levelname)s: %(message)s", "%H:%M:%S")
|
||||
ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
|
||||
def __parseCommandLine():
|
||||
parser = UsageArgumentParser.UsageArgumentParser(prog='storeActivity',description="Store a PGEN Activity to EDEX.")
|
||||
#bgroup = parser.add_argument_group(title='batch',description='For running in scripts and/or batch mode.')
|
||||
|
||||
#parser.add_argument("-i", action="store", dest="infoFile",
|
||||
# help="Activity Information used to store Activity",
|
||||
# required=True, metavar="infoFile")
|
||||
parser.add_argument("-t", action="store", dest="activityType",
|
||||
help="Activity Type",
|
||||
required=False, metavar="type")
|
||||
parser.add_argument("-st", action="store", dest="activitySubtype",
|
||||
help="Activity Subtype",
|
||||
required=False, metavar="subtype")
|
||||
parser.add_argument("-n", action="store", dest="activityName",
|
||||
help="Activity Name",
|
||||
required=False, metavar="name")
|
||||
parser.add_argument("-s", action="store", dest="site",
|
||||
help="site identifier",
|
||||
required=False, metavar="site")
|
||||
parser.add_argument("-f", action="store", dest="forecaster",
|
||||
help="forecaster",
|
||||
required=False, metavar="forecaster")
|
||||
parser.add_argument("filename",
|
||||
help="File containing XML Activity to be stored",
|
||||
metavar="filename")
|
||||
options = parser.parse_args()
|
||||
|
||||
logger.debug("Command-line arguments: " + str(options))
|
||||
return options
|
||||
|
||||
#
|
||||
# create an ActivityInfo object from command line input and
|
||||
# activityXML. If no input was found from command line, the
|
||||
# info in activityXML will be used.
|
||||
#
|
||||
def __getActivityInfo(xml, options):
|
||||
|
||||
ainfo = ActivityInfo()
|
||||
|
||||
tree = ET.fromstring(xml)
|
||||
product = tree.find('Product')
|
||||
|
||||
# strip the path from file and use it as activityLabel
|
||||
|
||||
fullname = options.filename
|
||||
lastslash = fullname.rfind("/")
|
||||
filename = fullname
|
||||
if ( lastslash >=0 ):
|
||||
filename = fullname[lastslash+1:]
|
||||
|
||||
ainfo.setActivityLabel(filename)
|
||||
|
||||
if ( options.forecaster != None ):
|
||||
ainfo.setForecaster(options.forecaster)
|
||||
else:
|
||||
ainfo.setForecaster(product.attrib['forecaster'])
|
||||
|
||||
if ( options.site != None ):
|
||||
ainfo.setSite(options.site)
|
||||
else:
|
||||
ainfo.setSite(product.attrib['center'])
|
||||
|
||||
# set activity type and subtype
|
||||
if ( options.activityType != None ):
|
||||
ainfo.setActivityType(options.activityType)
|
||||
|
||||
if ( options.activitySubtype != None ):
|
||||
ainfo.setActivitySubtype(options.activitySubtype)
|
||||
else:
|
||||
ainfo.setActivitySubtype("")
|
||||
else:
|
||||
if (product.attrib['type'].find("(") < 0 ):
|
||||
ainfo.setActivityType( product.attrib['type'] )
|
||||
ainfo.setActivitySubtype( "" )
|
||||
else:
|
||||
fulltyp = product.attrib['type']
|
||||
start = fulltyp.find("(")
|
||||
end = fulltyp.find(")")
|
||||
ainfo.setActivityType( fulltyp[0:start] )
|
||||
ainfo.setActivitySubtype( fulltyp[start+1:end] )
|
||||
|
||||
# set activityName
|
||||
if ( options.activityName != None ):
|
||||
ainfo.setActivityName(options.activityName)
|
||||
else:
|
||||
if ( options.activityType != None ):
|
||||
aname = options.activityType;
|
||||
if ( options.activitySubtype != None ):
|
||||
aname = aname + "(" + options.activitySubtype + ")"
|
||||
ainfo.setActivityName( aname )
|
||||
else:
|
||||
ainfo.setActivityName( product.attrib['name'] )
|
||||
|
||||
return ainfo
|
||||
|
||||
# Update Product tag attributes with options given on command line
|
||||
def __updateXML(xml, options):
|
||||
tree = ET.fromstring(xml)
|
||||
product = tree.find('Product')
|
||||
if options.activityName != None:
|
||||
product.attrib['name'] = options.activityName
|
||||
|
||||
if options.activityType != None:
|
||||
if options.activitySubtype != None:
|
||||
ntype = options.activityType + '(' + options.activitySubtype + ')'
|
||||
product.attrib['type'] = ntype
|
||||
else:
|
||||
product.attrib['type'] = options.activityType
|
||||
|
||||
if options.filename != None:
|
||||
product.attrib['outputFile'] = options.filename
|
||||
|
||||
if options.forecaster != None:
|
||||
product.attrib['forecaster'] = options.forecaster
|
||||
|
||||
if options.site != None:
|
||||
product.attrib['center'] = options.site
|
||||
|
||||
return ET.tostring(tree)
|
||||
|
||||
def main():
|
||||
__initLogger()
|
||||
logger.info("Starting storeActivity.")
|
||||
options = __parseCommandLine()
|
||||
|
||||
# read in XML from input file
|
||||
actfile = io.open(options.filename, 'rb')
|
||||
activityXML = actfile.read()
|
||||
actfile.close()
|
||||
|
||||
# generate an activityInfo object and update XML with options
|
||||
# from command line
|
||||
actinfo = __getActivityInfo(activityXML, options)
|
||||
activityXML = __updateXML(activityXML, options)
|
||||
|
||||
# Store Activity to EDEX
|
||||
ps = ProductStorer.ProductStorer(actinfo, activityXML)
|
||||
dataURI = ps.storeActivity()
|
||||
|
||||
logger.info("Activity stored with dataURI: " + dataURI)
|
||||
logger.info("storeActivity is complete.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,51 +0,0 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
# This software was developed and / or modified by Raytheon Company,
|
||||
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
#
|
||||
# U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
# This software product contains export-restricted data whose
|
||||
# export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
# to non-U.S. persons whether in the United States or abroad requires
|
||||
# an export license or other authorization.
|
||||
#
|
||||
# Contractor Name: Raytheon Company
|
||||
# Contractor Address: 6825 Pine Street, Suite 340
|
||||
# Mail Stop B8
|
||||
# Omaha, NE 68106
|
||||
# 402.291.0100
|
||||
#
|
||||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
##############################################################################
|
||||
# This script allows users to extract PGEN products from EDEX.
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 06/08/12 #674 dgilling Initial Creation.
|
||||
##############################################################################
|
||||
|
||||
# this allows you to run this script from outside of ./bin
|
||||
path_to_script=`readlink -f $0`
|
||||
RUN_FROM_DIR=`dirname $path_to_script`
|
||||
|
||||
BASE_AWIPS_DIR=`dirname $RUN_FROM_DIR`
|
||||
|
||||
# get the base environment
|
||||
source ${RUN_FROM_DIR}/setup.env
|
||||
|
||||
# setup the environment needed to run the the Python
|
||||
export LD_LIBRARY_PATH=${BASE_AWIPS_DIR}/src/lib:${PYTHON_INSTALL}/lib
|
||||
export PYTHONPATH=${RUN_FROM_DIR}/src:$PYTHONPATH
|
||||
|
||||
# execute the ifpInit Python module
|
||||
_PYTHON="${PYTHON_INSTALL}/bin/python"
|
||||
_MODULE="${RUN_FROM_DIR}/src/pgen/storeActivity.py"
|
||||
|
||||
# quoting of '$@' is used to prevent command line interpretation
|
||||
#$_PYTHON $_MODULE -h ${DEFAULT_HOST} -p ${DEFAULT_PORT} "$@"
|
||||
$_PYTHON $_MODULE "$@"
|
||||
|
Loading…
Add table
Reference in a new issue