Пример #1
0
 def connect(self):
     my_hostname = socket.gethostname()
     my_ip = socket.gethostbyname(my_hostname)
     self.socket = None
     vista_info = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
     af, socktype, proto, canonname, sa = vista_info[0]
     try:
         self.socket = socket.socket(af, socktype, proto)
         self.socket.connect(sa)
     except socket.error as message:
         if self.socket:
             self.socket.close();
             self.socket = None
         raise VistaException('Unable to connect: ' + message)
     params = [
         RpcParameter(RpcParameter.LITERAL, my_ip),
         RpcParameter(RpcParameter.LITERAL, my_hostname)
     ]
     rpc = VistaRpc.prepare('HELLO', params)
     try:
         response = self.execute(rpc)
     except:
         raise VistaException('No VistA listener at ' + self.host + ', port ' + self.port)
     if response != 'accept':
         self.disconnect()
         raise VistaException('Connection not accepted: ' + response)
     self.is_connected = True
Пример #2
0
 def connect(self):
     my_hostname = socket.gethostname()
     my_ip = socket.gethostbyname(my_hostname)
     self.socket = None
     vista_info = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC,
                                     socket.SOCK_STREAM)
     af, socktype, proto, canonname, sa = vista_info[0]
     try:
         self.socket = socket.socket(af, socktype, proto)
         self.socket.connect(sa)
     except socket.error as message:
         if self.socket:
             self.socket.close()
             self.socket = None
         raise VistaException('Unable to connect: ' + message)
     params = [
         RpcParameter(RpcParameter.LITERAL, my_ip),
         RpcParameter(RpcParameter.LITERAL, my_hostname)
     ]
     rpc = VistaRpc.prepare('HELLO', params)
     try:
         response = self.execute(rpc)
     except:
         raise VistaException('No VistA listener at ' + self.host +
                              ', port ' + self.port)
     if response != 'accept':
         self.disconnect()
         raise VistaException('Connection not accepted: ' + response)
     self.is_connected = True
Пример #3
0
 def set_context(self, cxn, context):
     param = [RpcParameter(RpcParameter.ENCRYPTED, context)]
     rpc = VistaRpc.prepare("XWB CREATE CONTEXT", param)
     response = cxn.execute(rpc)
     if response != "1":
         raise VistaException(response)
     self.context = context
Пример #4
0
 def set_context(self, cxn, context):
     param = [RpcParameter(RpcParameter.ENCRYPTED, context)]
     rpc = VistaRpc.prepare('XWB CREATE CONTEXT', param)
     response = cxn.execute(rpc)
     if response != '1':
         raise VistaException(response)
     self.context = context
Пример #5
0
 def test_connect_rpc(self):
     expected = "[XWB]10304\x0ATCPConnect50013192.168.1.107f00010f0022LAPTOP2.v11.med.va.govf\x04"
     params = [
         RpcParameter(RpcParameter.LITERAL, '192.168.1.107'),
         RpcParameter(RpcParameter.LITERAL, 'LAPTOP2.v11.med.va.gov')
     ]
     actual = VistaRpc.prepare('HELLO', params)
     self.assertEqual(expected, actual)
Пример #6
0
    def login(self, cxn, access_code, verify_code, context=None):
        rpc = VistaRpc.prepare("XUS SIGNON SETUP")
        response = cxn.execute(rpc)
        if response is None:
            raise VistaException("Unable to setup login")
        param = [RpcParameter(RpcParameter.ENCRYPTED, access_code + ";" + verify_code)]
        rpc = VistaRpc.prepare("XUS AV CODE", param)
        response = cxn.execute(rpc)
        if response is None:
            raise VistaException("No response to login request")
        greeting = self.load(response)
        self.access_code = access_code
        self.verify_code = verify_code

        if context is not None:
            self.set_context(cxn, context)

        return greeting
Пример #7
0
    def login(self, cxn, access_code, verify_code, context=None):
        rpc = VistaRpc.prepare('XUS SIGNON SETUP')
        response = cxn.execute(rpc)
        if response is None:
            raise VistaException('Unable to setup login')
        param = [RpcParameter(RpcParameter.ENCRYPTED, access_code + ';' + verify_code)]
        rpc = VistaRpc.prepare('XUS AV CODE', param)
        response = cxn.execute(rpc)
        if response is None:
            raise VistaException('No response to login request')
        greeting = self.load(response)
        self.access_code = access_code
        self.verify_code = verify_code

        if context is not None:
            self.set_context(cxn, context)

        return greeting
Пример #8
0
 def disconnect(self):
     if self.is_connected:
         rpc = VistaRpc.prepare('BYE')
         response = self.execute(rpc)
         self.socket.close()
         self.is_connected = False
Пример #9
0
 def test_disconnect_rpc(self):
     expected = "[XWB]10304\x05#BYE#\x04"
     actual = VistaRpc.prepare('BYE')
     self.assertEqual(expected, actual)
Пример #10
0
 def test_get_variable_value_rpc(self):
     arg = "$P($G(^DIC(3.1,1362,0)),U,1)"
     expected = "[XWB]11302\x051.108\x16XWB GET VARIABLE VALUE51028$P($G(^DIC(3.1,1362,0)),U,1)f\x04"
     param = RpcParameter(RpcParameter.REFERENCE, arg)
     actual = VistaRpc.prepare('XWB GET VARIABLE VALUE', [param])
     self.assertEqual(expected, actual)
Пример #11
0
 def test_set_context_rpc(self):
     expected = "[XWB]11302\x051.108\x12XWB CREATE CONTEXT50019(&y?#jy<?x:=?#68y].f\x04"
     param = RpcParameter(RpcParameter.ENCRYPTED, 'OR CPRS GUI CHART', [8,14])
     actual = VistaRpc.prepare('XWB CREATE CONTEXT', [param])
     self.assertEqual(expected, actual)
Пример #12
0
 def test_login_rpc(self):
     expected = "[XWB]11302\x051.108\x0BXUS AV CODE50017.r v11k3}!r&sAgP$f\x04"
     param = RpcParameter(RpcParameter.ENCRYPTED, 'ijr773;Akiba12.', [14,4])
     actual = VistaRpc.prepare('XUS AV CODE', [param])
     self.assertEqual(expected, actual)
Пример #13
0
 def test_into_msg_rpc(self):
     expected = "[XWB]11302\x051.108\x0DXUS INTRO MSG54f\x04"
     actual = VistaRpc.prepare('XUS INTRO MSG')
     self.assertEqual(expected, actual)
Пример #14
0
 def __prepare(self):
     self.__prepare_param_list()
     params = RpcParameter(RpcParameter.LIST, self.param_list)
     self.rpc = VistaRpc.prepare('DDR LISTER', [params])
Пример #15
0
 def disconnect(self):
     if self.is_connected:
         rpc = VistaRpc.prepare('BYE')
         response = self.execute(rpc)
         self.socket.close()
         self.is_connected = False
Пример #16
0
 def test_setup_login_rpc(self):
     expected = "[XWB]11302\x051.108\x10XUS SIGNON SETUP54f\x04"
     actual = VistaRpc.prepare('XUS SIGNON SETUP')
     self.assertEqual(expected, actual)
Пример #17
0
 def __prepare(self):
     self.__prepare_param_list()
     params = RpcParameter(RpcParameter.LIST, self.param_list)
     self.rpc = VistaRpc.prepare('DDR LISTER', [params])