コード例 #1
0
    def send(self, request=None):
        """The request is transmitted and the response object is returned."""
        if (not request == None): self.setRequest(request)

        try:
            response = urlopen(self.getHTTPRequest())
        except URLError:
            raise artbeater.webapi.ServerError, 'There is no response from the server. Please execute it after a while again.'
        except HTTPError:
            raise artbeater.webapi.ServerError, 'There is no response from the server. Please execute it after a while again.'

        if response.info().get('Content-Encoding') == 'gzip':
            file = StringIO(response.read())
            content = gzip.GzipFile(fileobj=file)
        else:
            content = response

        parser = ResponseParser(self._multi_element)
        try:
            result = parser.parse(content)
        except ExpatError:
            raise artbeater.webapi.InvalidResponse, 'Xml not an invalid response was received.'

        return Response({
            'code': response.code,
            'message': response.msg,
            'request': request,
            'headers': response.info(),
            'result': result
        })
コード例 #2
0
ファイル: method.py プロジェクト: holyshared/sharedhat-lab
    def send(self, request=None):
        """The request is transmitted and the response object is returned."""
        if (not request == None): self.setRequest(request)

        try:
            response = urlopen(self.getHTTPRequest())
        except URLError:
            raise artbeater.webapi.ServerError, 'There is no response from the server. Please execute it after a while again.'
        except HTTPError:
            raise artbeater.webapi.ServerError, 'There is no response from the server. Please execute it after a while again.'

        if response.info().get('Content-Encoding') == 'gzip':
            file = StringIO(response.read())
            content = gzip.GzipFile(fileobj=file)
        else:
            content = response

        parser = ResponseParser(self._multi_element)
        try:
            result = parser.parse(content)
        except ExpatError:
            raise artbeater.webapi.InvalidResponse, 'Xml not an invalid response was received.'

        return Response({
            'code': response.code,
            'message': response.msg,
            'request': request,
            'headers': response.info(),
            'result': result
        })
コード例 #3
0
ファイル: decorator.py プロジェクト: holyshared/sharedhat-lab
    def execute(self, values={}):
        parser = ResponseParser()
        res = parser.parse('response.xml')

        return Response({ 'result': res })