FKScript with args reference to RsiDB instance (GT-400 Development)

; TerminalStatus.txt

; Example of a Synchronously Executed XML-RPC Request
; being executed on a host within a function key script, with
; the output of the host call being displayed to the terminal
; user.

; We are using the terminal's XML-RPC Server to simulate
; a host based XML-RPC Service.

TABLE
 F1 TermStatus  FIRST LABEL "Term Status" OTHER
END

LIST TermStatus
 PROMPT "Terminal Status"
 COLS 2
 HEADER "Attribute" "Value"
 COLWIDTH 10 4
 NOSELECT ;Makes list read-only
 GET TermStatusList
 TACODE 80
END

PYTHON TermStatusList
BEGIN
# program to list the terminal status attributes
# that are returned from the terminal's XMLRPC
# server using the GetTerminalStatus() call.

# import the appropriate Python library packages
import socket
import xmlrpclib

rsiDB = args.GetRsiDB()

# obtain the terminal's IP address
termIPaddr = socket.gethostbyname(socket.gethostname())

svrURI = 'http://' + termIPaddr + '/'
svrProxy = xmlrpclib.Server(svrURI)
rsiDB.LogInfo('svrURI: %s' % svrURI)

try:
   # Sample XML-RPC Host Call
   termStatusRsp = svrProxy.GetTerminalStatus()
except:
   # If the host is not available, let the user know.
   return [('Error', 'XML-RPC Call Failed')]

attribTplList = []

keyList = list(termStatusResp.keys())
for key in keyList:
   attribName = key
   attribValue = termStatusResp[attribName]
   attribTplList.append((attribName, attribValue))

return attribTplList
END


DISCLAIMER:

INFORMATION PROVIDED THROUGH THIS SITE IS PROVIDED TO YOU AS IS WITHOUT ANY EXPRESS REPRESENTATIONS OR WARRANTIES OF ANY KIND, AND WE MAKE NO REPRESENTATION OR WARRANTY THAT THIS SITE(OR ANY INFORMATION PROVIDED IN RESPONSE TO YOUR INQUIRY), WILL BE ACCURATE, COMPLETE, OR ERROR-FREE.

YOU AGREE THAT YOU MUST EVALUATE ALL INFORMATION AND RESPONSES, AND THAT YOU BEAR ALL RISKS ASSOCIATED WITH, THE USE OF THIS SITE, INCLUDING ANY RELIANCE ON THE ACCURACY,COMPLETENESS, OR USEFULNESS OF ANY INFORMATION OR MATERIALS MADE AVAILABLE THROUGH THIS SITE.