def getUserList(self, tokenInput): ip, port = self.__resolve_ear_config() transport = TSocket.TSocket(ip, port) try: transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = EarPiThriftService.Client(protocol) transport.open() output = client.getUserList(tokenInput=tokenInput) transport.close() return output except Thrift.TException as tx: print("%s" % (tx.message)) finally: transport.close()
def configureUserModule(self, uniquename, autorisations, tokenInput): ip, port = self.__resolve_ear_config() transport = TSocket.TSocket(ip, port) try: transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = EarPiThriftService.Client(protocol) transport.open() output = client.configureUserModule(uniquename=uniquename, autorisations=autorisations, tokenInput=tokenInput) transport.close() return output except Thrift.TException as tx: print("%s" % (tx.message)) finally: transport.close()
def storeNewPerson(self, person, tokenInput): ip, port = self.__resolve_ear_config() transport = TSocket.TSocket(ip, port) try: transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = EarPiThriftService.Client(protocol) transport.open() output = client.createNewPerson(person=person, tokenInput=tokenInput) transport.close() return output except LoginFailedException as fail: raise fail except UniqueFailedException as unique: raise unique except Thrift.TException as tx: print("%s" % (tx.message)) except Exception as ex: print('unexpected exception') finally: transport.close()
def create_server(): handler = EarPiThriftHandler() return TServer.TSimpleServer(EarPiThriftService.Processor(handler), TSocket.TServerSocket(port=port), TTransport.TBufferedTransportFactory(), TBinaryProtocol.TBinaryProtocolFactory())