def _do_send(self, data): """ Perform a single request and return the deserialized response. """ headers = { "User-Agent": "jmx4py 0.1", # TODO: add automatic version detection } req_body = json.dumps( data) # TODO: using data automatically select POST as method req = urllib2.Request(self.url, data=req_body, headers=headers, unverifiable=True) handle = network.urlopen(req) # TODO: , username, password) try: # TODO: wire debugging # if debug: # log.trace("Reponse headers for %r:\n %s" % ( # url, "\n ".join(i.strip() for i in handle.info().headers) # )) result = json.loads(handle.read()) return result finally: handle.close()
def _do_send(self, data): """ Perform a single request and return the deserialized response. """ headers = { "User-Agent": "jmx4py 0.1", # TODO: add automatic version detection } req_body = json.dumps(data) # TODO: using data automatically select POST as method req = urllib2.Request(self.url, data=req_body, headers=headers, unverifiable=True) handle = network.urlopen(req) # TODO: , username, password) try: # TODO: wire debugging # if debug: # log.trace("Reponse headers for %r:\n %s" % ( # url, "\n ".join(i.strip() for i in handle.info().headers) # )) result = json.loads(handle.read()) return result finally: handle.close()
def __str__(self): """ Return fully nested representation of JMX response (JSON dump). """ return json.dumps(self, indent=2)