def send_to_url(self, url=None, params={}, method=None):
        """
        This method will do an http POST or GET request to the Url
        """
        if method is None:
            method = self.default_http_method

        if not url:
            err = "Cannot send XML request %s, no url !" % method
            self.log.warn(err)
            return (None, err)

        params.update(self.session_params)
        for k in self.xml_vars.keys():
            params['var_' + k] = self.xml_vars[k]

        (adjusted_url, url_params) = process_url_params(url)
        timeout = None
        if url_params and url_params.has_key('timeout'):
            timeout = int(url_params['timeout'])

        try:
            http_obj = HTTPRequest(self.key, self.secret, proxy_url=self.proxy_url)
            self.log.warn("CallUUID=%s : Fetching XML from %s with params %s" % (params['CallUUID'], url, params))
            data = http_obj.fetch_response(adjusted_url, params, method, log=self.log, timeout=timeout)
            self.log.warn("CallUUID=%s : Fetched XML = %s" % (params['CallUUID'], data.replace("\n", " ").replace("\r", " ")))
            return (data, None)
        except Exception, e:
            err = "Fetching XML from %s with params %s failed with %s" % (url, params, e)
            self.log.error("CallUUID=%s : %s" % (params['CallUUID'], err))
            return (None, err)
Exemplo n.º 2
0
 def fetch_xml(self, params={}, method="POST"):
     """
     This method will retrieve the xml from the answer_url
     The url result expected is an XML content which will be stored in
     xml_response
     """
     # auto add session parameters
     params.update(self.session_params)
     self.log.info("Fetching %s RESTXML from %s with %s" % (method, self.target_url, params))
     http_obj = HTTPRequest(self.auth_id, self.auth_token)
     self.xml_response = http_obj.fetch_response(self.target_url, params, method)
     self.log.info("Requested RESTXML to %s with %s" % (self.target_url, params))
Exemplo n.º 3
0
 def post_to_url(self, url=None, params={}, method='POST'):
     if not url:
         self.log.warn("Cannot post No url found !")
         return None
     http_obj = HTTPRequest(self.auth_id, self.auth_token)
     try:
         data = http_obj.fetch_response(url, params, method)
         self.log.info("Posted to %s with %s -- Result: %s"
                                         % (url, params, data))
         return data
     except Exception, e:
         self.log.error("Post to %s with %s -- Error: %s"
                                         % (url, params, e))
Exemplo n.º 4
0
    def send_to_url(self, url=None, params={}, method=None):
        if method is None:
            method = self.get_server().default_http_method

        if not url:
            self.log.warn("Cannot send %s, no url !" % method)
            return None
        try:
            http_obj = HTTPRequest(self.get_server().key, self.get_server().secret, self.get_server().proxy_url)
            data = http_obj.fetch_response(url, params, method, log=self.log)
            return data
        except Exception, e:
            self.log.error("Sending to %s %s with %s -- Error: %s" % (method, url, params, e))
Exemplo n.º 5
0
    def send_to_url(self, url=None, params={}, method=None):
        if method is None:
            method = self.get_server().default_http_method

        if not url:
            self.log.warn("Cannot send %s, no url !" % method)
            return None
        try:
            http_obj = HTTPRequest(self.get_server().key, self.get_server().secret, self.get_server().proxy_url)
            data = http_obj.fetch_response(url, params, method, log=self.log)
            return data
        except Exception, e:
            self.log.error("Sending to %s %s with %s -- Error: %s"
                                        % (method, url, params, e))
Exemplo n.º 6
0
    def send_to_url(self, url=None, params={}, method=None):
        if method is None:
            method = self.default_http_method

        if not url:
            self.log.warn("Cannot send %s, no url !" % method)
            return None
        http_obj = HTTPRequest(self.auth_id, self.auth_token)
        try:
            data = http_obj.fetch_response(url, params, method)
            self.log.info("Sent to %s %s with %s -- Result: %s" % (method, url, params, data))
            return data
        except Exception, e:
            self.log.error("Sending to %s %s with %s -- Error: %s" % (method, url, params, e))
Exemplo n.º 7
0
 def post_to_url(self, url=None, params={}, method="POST"):
     """
     This method will do an http POST or GET request to the Url
     """
     if not url:
         self.log.warn("Cannot post, no url !")
         return None
     params.update(self.session_params)
     http_obj = HTTPRequest(self.auth_id, self.auth_token)
     try:
         data = http_obj.fetch_response(url, params, method)
         self.log.info("Posted to %s with %s -- Result: %s" % (url, params, data))
         return data
     except Exception, e:
         self.log.error("Post to %s with %s -- Error: %s" % (url, params, e))
    def send_to_url(self, url=None, params={}, method=None):
        """
        This method will do an http POST or GET request to the Url
        """
        if method is None:
            method = self.default_http_method

        if not url:
            self.log.warn("Cannot send %s, no url !" % method)
            return None
        params.update(self.session_params)
        try:
            http_obj = HTTPRequest(self.key, self.secret, proxy_url=self.proxy_url)
            data = http_obj.fetch_response(url, params, method, log=self.log)
            return data
        except Exception, e:
            self.log.error("Sending to %s %s with %s -- Error: %s" % (method, url, params, e))
    def notify_error(self, error_url=None, params={}, method='POST'):
        if not error_url:
            return None

        urls = error_url.split(',')[:MAX_TARGET_URLS]
        for url in urls:

            (adjusted_url, url_params) = process_url_params(url)
            timeout = None
            if url_params and url_params.has_key('timeout'):
                timeout = int(url_params['timeout'])

            try:
                http_obj = HTTPRequest(self.key, self.secret, self.proxy_url)
                data = http_obj.fetch_response(adjusted_url, params, method, log=self.log, timeout=timeout)
                return data
            except Exception, e:
                self.log.error("Notifying error to %s %s with %s -- Error: %s"
                                        % (method, url, params, e))
    def send_to_url(self, url=None, params={}, method=None):
        """
        This method will do an http POST or GET request to the Url
        """
        if method is None:
            method = self.default_http_method

        if not url:
            self.log.warn("Cannot send %s, no url !" % method)
            return None
        params.update(self.session_params)
        try:
            http_obj = HTTPRequest(self.key,
                                   self.secret,
                                   proxy_url=self.proxy_url)
            data = http_obj.fetch_response(url, params, method, log=self.log)
            return data
        except Exception, e:
            self.log.error("Sending to %s %s with %s -- Error: %s" \
                                        % (method, url, params, e))
Exemplo n.º 11
0
    def send_to_url(self, url=None, params={}, method=None):
        """
        This method will do an http POST or GET request to the Url
        """
        if method is None:
            method = self.default_http_method

        if not url:
            self.log.warn("Cannot send %s, no url !" % method)
            return None
        params.update(self.session_params)
        http_obj = HTTPRequest(self.auth_id, self.auth_token)
        try:
            data = http_obj.fetch_response(url, params, method)
            self.log.info("Sent to %s %s with %s -- Result: %s" \
                                            % (method, url, params, data))
            return data
        except Exception, e:
            self.log.error("Sending to %s %s with %s -- Error: %s" \
                                            % (method, url, params, e))