Merge branch 'omaha_16.2.1' into omaha_16.2.1-lx
Former-commit-id: 54536fc5ea6cb63df8ad826eb1f4347fe69d922d
This commit is contained in:
commit
6801500899
8 changed files with 398 additions and 21 deletions
|
@ -77,6 +77,8 @@
|
|||
#
|
||||
# Sep 11, 2015 4858 dgilling Remove notification processing from publishElements.
|
||||
# Jan 20, 2016 4751 randerso Fix type of mask returned from getComposite() to work with numpy 1.9.2
|
||||
# 02/22/2016 5374 randerso Added support for sendWFOMessage
|
||||
#
|
||||
########################################################################
|
||||
import types, string, time, sys
|
||||
from math import *
|
||||
|
@ -2702,3 +2704,34 @@ class SmartScript(BaseTool.BaseTool):
|
|||
status = transmitter.transmitProduct(practice)
|
||||
return status
|
||||
|
||||
def sendWFOMessage(self, wfos, message):
|
||||
'''
|
||||
Sends a message to a list of wfos
|
||||
|
||||
Args:
|
||||
wfos: string or list, set or tuple of strings containing the destination wfo(s)
|
||||
|
||||
message: string containing the message to be sent
|
||||
|
||||
Returns:
|
||||
string: empty if successful or error message
|
||||
|
||||
Raises:
|
||||
TypeError: if wfos is not a string, list, tuple or set
|
||||
'''
|
||||
|
||||
if not wfos:
|
||||
# called with empty wfo list, nothing to do
|
||||
return ""
|
||||
|
||||
javaWfos = ArrayList()
|
||||
if type(wfos) in [list, tuple, set]:
|
||||
for wfo in wfos:
|
||||
javaWfos.add(wfo)
|
||||
elif type(wfos) is str:
|
||||
javaWfos.add(wfos)
|
||||
else:
|
||||
raise TypeError("Invalid type received for wfos: " + type(wfos))
|
||||
|
||||
response = self.__dataMgr.getClient().sendWFOMessage(javaWfos, message)
|
||||
return response.message()
|
||||
|
|
|
@ -69,6 +69,7 @@ import com.raytheon.uf.common.dataplugin.gfe.request.IscRequestQueryRequest;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.request.LockChangeRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.SaveGfeGridRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.SendIscGridRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.SendWFOMessageRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerMsg;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
|
@ -124,6 +125,7 @@ import com.raytheon.viz.gfe.core.parm.Parm;
|
|||
* and re-request if not all data returned
|
||||
* 09/23/14 #3648 randerso Changed getParmList to return results even if some DbIds
|
||||
* have errors
|
||||
* 02/22/2016 #5374 randerso Added support for sendWFOMessage
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -200,7 +202,7 @@ public class IFPClient {
|
|||
List<ParmID> parmIds = (List<ParmID>) sr.getPayload();
|
||||
if (!sr.isOkay()) {
|
||||
String msg = formatSRMessage(sr);
|
||||
if (parmIds != null && !parmIds.isEmpty()) {
|
||||
if ((parmIds != null) && !parmIds.isEmpty()) {
|
||||
// got something so display an error message and continue
|
||||
statusHandler.error(msg);
|
||||
} else {
|
||||
|
@ -818,4 +820,10 @@ public class IFPClient {
|
|||
GetTopoDataRequest request = new GetTopoDataRequest(gloc);
|
||||
return (ServerResponse<ScalarGridSlice>) makeRequest(request, false);
|
||||
}
|
||||
|
||||
public ServerResponse<?> sendWFOMessage(List<String> wfos, String message)
|
||||
throws GFEServerException {
|
||||
SendWFOMessageRequest request = new SendWFOMessageRequest(wfos, message);
|
||||
return makeRequest(request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,6 +181,11 @@
|
|||
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.SendIscGridRequest"/>
|
||||
<constructor-arg ref="sendIscGridHandler"/>
|
||||
</bean>
|
||||
<bean id="sendWFOMessageHandler" class="com.raytheon.edex.plugin.gfe.server.handler.SendWFOMessageHandler"/>
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.SendWFOMessageRequest"/>
|
||||
<constructor-arg ref="sendWFOMessageHandler"/>
|
||||
</bean>
|
||||
<bean id="singletonDbIdsHandler" class="com.raytheon.edex.plugin.gfe.server.handler.GetSingletonDbIdsRequestHandler"/>
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.GetSingletonDbIdsRequest"/>
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
package com.raytheon.edex.plugin.gfe.server.handler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import jep.JepException;
|
||||
|
||||
import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.SendWFOMessageRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.python.PyUtil;
|
||||
import com.raytheon.uf.common.python.PythonScript;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
|
||||
/**
|
||||
* Send WFO Message Handler
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 22, 2016 #5374 randerso Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SendWFOMessageHandler extends BaseGfeRequestHandler implements
|
||||
IRequestHandler<SendWFOMessageRequest> {
|
||||
|
||||
private static final String SCRIPT_PATH = FileUtil.join(
|
||||
GfePyIncludeUtil.ISC, "sendWFOMessage.py");
|
||||
|
||||
@Override
|
||||
public ServerResponse<?> handleRequest(SendWFOMessageRequest request) {
|
||||
ServerResponse<?> response = new ServerResponse<>();
|
||||
|
||||
String siteID = request.getSiteID();
|
||||
IFPServerConfig config;
|
||||
try {
|
||||
config = getIfpServer(request).getConfig();
|
||||
|
||||
Map<String, Object> args = new HashMap<>();
|
||||
args.put("siteID", siteID);
|
||||
args.put("config", config);
|
||||
args.put("destSites", request.getWfos());
|
||||
args.put("message", request.getMessage());
|
||||
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext cx = pathMgr.getContext(
|
||||
LocalizationType.EDEX_STATIC, LocalizationLevel.BASE);
|
||||
final String scriptPath = pathMgr.getFile(cx, SCRIPT_PATH)
|
||||
.getPath();
|
||||
final String includePath = PyUtil.buildJepIncludePath(
|
||||
GfePyIncludeUtil.getCommonPythonIncludePath(),
|
||||
GfePyIncludeUtil.getIscScriptsIncludePath(),
|
||||
GfePyIncludeUtil.getGfeConfigIncludePath(siteID));
|
||||
|
||||
try (PythonScript script = new PythonScript(scriptPath,
|
||||
includePath, SendWFOMessageHandler.class.getClassLoader())) {
|
||||
try {
|
||||
script.execute("runFromJava", args);
|
||||
} catch (JepException e) {
|
||||
String msg = "Error servicing SendWFOMessageRequest from site ["
|
||||
+ siteID + "]: " + e.getLocalizedMessage();
|
||||
response.addMessage(msg);
|
||||
}
|
||||
} catch (JepException e) {
|
||||
String msg = "Error creating PythonScript object for: ["
|
||||
+ scriptPath + "]: " + e.getLocalizedMessage();
|
||||
response.addMessage(msg);
|
||||
}
|
||||
} catch (GfeException e) {
|
||||
String msg = "Error retrieving site config for site [" + siteID
|
||||
+ "]: " + e.getLocalizedMessage();
|
||||
response.addMessage(msg);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -17,16 +17,6 @@
|
|||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
|
||||
import cPickle
|
||||
|
||||
import LogStream, tempfile, os, sys, JUtil, subprocess, traceback, errno
|
||||
import time, copy, string, iscUtil
|
||||
|
||||
from com.raytheon.edex.plugin.gfe.isc import IRTManager
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
|
||||
#
|
||||
# Port of IRT functionality from legacy ifpServer
|
||||
#
|
||||
|
@ -50,8 +40,18 @@ from subprocess import CalledProcessError
|
|||
# Additional code clean up
|
||||
# 03/05/2015 4129 randerso Fix exception handling on subprocess calls
|
||||
# Fixed error when no TCV files were found
|
||||
# 02/22/2016 5374 randerso Added support for sendWFOMessage
|
||||
#
|
||||
##
|
||||
|
||||
import cPickle
|
||||
|
||||
import LogStream, tempfile, os, sys, JUtil, subprocess, traceback, errno
|
||||
import time, copy, string, iscUtil
|
||||
|
||||
from com.raytheon.edex.plugin.gfe.isc import IRTManager
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
PURGE_AGE = 30 * 24 * 60 * 60 # 30 days in seconds
|
||||
|
||||
def getLogger():
|
||||
|
@ -202,6 +202,19 @@ def putVTECActiveTable(dataFile, xmlPacket):
|
|||
except:
|
||||
logProblem("Error executing ingestAT: ", traceback.format_exc())
|
||||
|
||||
def sendWfoMessage(siteID, msgFile):
|
||||
with open(msgFile, 'r') as fp:
|
||||
message = fp.read()
|
||||
|
||||
logEvent("Message received from site: %s\n%s" % (siteID, message))
|
||||
|
||||
# send to AlertViz
|
||||
from ufpy import NotificationMessage
|
||||
msg = NotificationMessage.NotificationMessage(port='9581', message=message,
|
||||
category='GFE', priority='SIGNIFICANT', source='GFE')
|
||||
msg.send()
|
||||
|
||||
|
||||
def putTCVFiles(siteID, tarFile):
|
||||
import LocalizationSupport
|
||||
import glob
|
||||
|
|
|
@ -20,15 +20,6 @@
|
|||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
|
||||
import iscMosaic,iscUtil
|
||||
import os, stat, sys, re, string, types
|
||||
import time, xml, LogStream, IrtAccess
|
||||
import IrtServer
|
||||
from xml.etree import ElementTree
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
from java.util import ArrayList
|
||||
|
||||
#
|
||||
# Port of iscDataRec.py
|
||||
#
|
||||
|
@ -47,9 +38,18 @@ from java.util import ArrayList
|
|||
# Additional code cleanup
|
||||
# 04/08/2015 4383 dgilling Support FireWx ISC.
|
||||
# 04/23/2015 4383 randerso Fixed exception logging
|
||||
# 02/22/2016 5374 randerso Added support for sendWFOMessage
|
||||
#
|
||||
##
|
||||
|
||||
import iscMosaic,iscUtil
|
||||
import os, stat, sys, re, string, types
|
||||
import time, xml, LogStream, IrtAccess
|
||||
import IrtServer
|
||||
from xml.etree import ElementTree
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
from java.util import ArrayList
|
||||
|
||||
iscDataRecLogger=None
|
||||
|
||||
## Logging methods ##
|
||||
|
@ -210,7 +210,8 @@ def execIscDataRec(MSGID,SUBJECT,FILES):
|
|||
IrtServer.serviceISCRequest(dataFile)
|
||||
elif SUBJECT == 'PUT_TCV_FILES':
|
||||
IrtServer.putTCVFiles(srcServer.get('site'), dataFile)
|
||||
pass
|
||||
elif SUBJECT == 'SEND_WFO_MESSAGE':
|
||||
IrtServer.sendWfoMessage(srcServer.get('site'), dataFile)
|
||||
else:
|
||||
nosend = True
|
||||
logProblem("unknown subject: ", SUBJECT)
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
#!/usr/bin/env python
|
||||
##
|
||||
# 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.
|
||||
##
|
||||
#
|
||||
# Send Message to a list of WFOs
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 02/22/2016 5374 randerso Initial Creation.
|
||||
#
|
||||
##
|
||||
import os, errno, tempfile
|
||||
|
||||
import xml
|
||||
from xml.etree import ElementTree
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
|
||||
import IrtAccess
|
||||
|
||||
logger = None
|
||||
|
||||
def init_logging():
|
||||
import iscUtil
|
||||
import logging
|
||||
global logger
|
||||
logger = iscUtil.getLogger("sendWFOMessage", logLevel=logging.INFO)
|
||||
|
||||
|
||||
def runFromJava(siteID, config, destSites, message):
|
||||
import siteConfig
|
||||
|
||||
host = str(config.getServerHost())
|
||||
port = str(config.getRpcPort())
|
||||
protocol = str(config.getProtocolVersion())
|
||||
mhsid = str(config.getMhsid())
|
||||
ancf = str(config.iscRoutingTableAddress().get("ANCF"))
|
||||
bncf = str(config.iscRoutingTableAddress().get("BNCF"))
|
||||
xmtScript = str(config.transmitScript())
|
||||
|
||||
init_logging()
|
||||
|
||||
iscProductsDir = os.path.join(siteConfig.GFESUITE_HOME, "products", "ISC")
|
||||
|
||||
|
||||
# get temporary file name for WFO message
|
||||
with tempfile.NamedTemporaryFile(suffix='.sendWFOMessage', dir=iscProductsDir, delete=False) as fp:
|
||||
fp.write(message)
|
||||
fname = fp.name
|
||||
|
||||
|
||||
sourceServer = {'mhsid' : mhsid,
|
||||
'host' : host,
|
||||
'port' : port,
|
||||
'protocol': protocol,
|
||||
'site' : siteID}
|
||||
|
||||
try:
|
||||
if not destSites:
|
||||
raise RuntimeError('No destSites supplied')
|
||||
|
||||
if not message:
|
||||
raise RuntimeError('No message supplied')
|
||||
|
||||
irt = IrtAccess.IrtAccess(ancf, bncf, logger=logger)
|
||||
msgSendDest, xml = irt.createDestinationXML(destSites, sourceServer)
|
||||
|
||||
# create the XML file
|
||||
with tempfile.NamedTemporaryFile(suffix='.xml', dir=iscProductsDir, delete=False) as fd:
|
||||
fnameXML = fd.name
|
||||
fd.write(ElementTree.tostring(xml))
|
||||
|
||||
if len(msgSendDest) > 0:
|
||||
# Now send the message
|
||||
logger.debug("msgSendDest: "+ str(msgSendDest))
|
||||
irt.transmitFiles("SEND_WFO_MESSAGE", msgSendDest, mhsid, [fname, fnameXML], xmtScript)
|
||||
except:
|
||||
logger.exception('Error sending WFO message to sites:' + destSites + "\n" + message)
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* 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.
|
||||
**/
|
||||
package com.raytheon.uf.common.dataplugin.gfe.request;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* Send WFO Message Request
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 22, 2016 #5374 randerso Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class SendWFOMessageRequest extends AbstractGfeRequest {
|
||||
/**
|
||||
* List destination WFOs
|
||||
*/
|
||||
@DynamicSerializeElement
|
||||
private List<String> wfos;
|
||||
|
||||
/**
|
||||
* The message to send
|
||||
*/
|
||||
@DynamicSerializeElement
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization
|
||||
*/
|
||||
public SendWFOMessageRequest() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Consructor
|
||||
*
|
||||
* @param wfos
|
||||
* list of destination wfos
|
||||
* @param message
|
||||
* the message to be sent
|
||||
*/
|
||||
public SendWFOMessageRequest(List<String> wfos, String message) {
|
||||
super();
|
||||
this.wfos = wfos;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the wfos
|
||||
*/
|
||||
public List<String> getWfos() {
|
||||
return wfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param wfos
|
||||
* the wfos to set
|
||||
*/
|
||||
public void setWfos(List<String> wfos) {
|
||||
this.wfos = wfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* the message to set
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue