Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
 def __str__(self):
     """ Return fully nested representation of JMX response (JSON dump).
     """
     return json.dumps(self, indent=2)
Exemplo n.º 4
0
 def __str__(self):
     """ Return fully nested representation of JMX response (JSON dump).
     """
     return json.dumps(self, indent=2)