Beispiel #1
0
 def put(self, data):
     try:
         response = self.client.put(self.path, data)
         logging.info("Received Response Post-> " + response.pretty_print())
         return True
     except:
         return False
Beispiel #2
0
 def delete(self):
     try:
         response = self.client.delete(self.path)
         logging.info("Received Response delete-> " +
                      response.pretty_print())
         return True
     except:
         return False
Beispiel #3
0
 def get(self):
     try:
         response = self.client.get(self.path)
         logging.info("Received Response GET-> " + response.pretty_print())
         logging.info(response.Message.payload)
         return True
     except:
         return False
Beispiel #4
0
 def handlePostTest(self, resource, payload):
     self.initClient()
     response = self.client.post(resource, payload)
     if response: 
         print(response.pretty_print())
     else:
         print("No response received for POST using resource: " + resource)
     self.client.stop()
Beispiel #5
0
 def handleGetTest(self, resource):
     self.initClient()
     response = self.client.get(resource)
     if response: 
         print(response.pretty_print())
     else:
         print("No response received for GET using resource: " + resource)
     self.client.stop()
    def __init__(self, ip):
        self.ip_addr = ip
        
        try:
            self.client = HelperClient(server=(self.ip_addr, self.port))
            response = self.client.get(self.path, timeout=0.2)
            if response:
                self.connected = True
                return

            print response.pretty_print() # ruin test data

        except Exception as e:
            raise e
        finally:
            if hasattr(self, 'client'):
                thread = Thread(target=lambda: self.client.stop())
                thread.start()