awips2/edexOsgi/com.raytheon.uf.tools.gfesuite.servicebackup/svcBackup/ServiceBackup/scripts/receive_configuration.py
2022-05-05 12:34:50 -05:00

75 lines
2.4 KiB
Python

#!/awips2/python/bin/python3
##
# 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.
##
import sys
import os
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import ProcessReceivedConfRequest
from dynamicserialize.dstypes.com.raytheon.uf.common.message import WsId
from ufpy import ThriftClient
#
# TODO: ADD DESCRIPTION
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 08/04/11 bphillip Initial Creation.
# 02/12/15 #4103 dgilling Set site ID field.
# 03/27/15 #4103 dgilling Read connection values from environment.
#
#
#
def main():
connectionParams = getConnectionParams()
try:
receiveConfRequest = createRequest()
thriftClient = ThriftClient.ThriftClient(connectionParams[0], connectionParams[1], "/services")
serverResponse = thriftClient.sendRequest(receiveConfRequest)
except Exception as e:
print("Unhandled exception thrown during receive_configuration processing: \n", str(e))
sys.exit(1)
if (not serverResponse.isOkay()):
print("Errors occurred during iscDataRec processing: ", serverResponse.message())
sys.exit(1)
def getConnectionParams():
return (str(os.environ["SVCBU_HOST"]), int(os.environ["CDSPORT"]))
def createRequest():
obj = ProcessReceivedConfRequest()
wsId = WsId(progName="receive_configuration")
obj.setWorkstationID(wsId)
obj.setSiteID(str(sys.argv[6]).upper())
obj.setReceivedConfFile(str(sys.argv[5]))
return obj
if __name__ == '__main__':
main()