예제 #1
0
 def _to_url(cls, url_path):
     try:
         return u'{0}{1}'.format(cls.BASE_URL, url_path)
     except Exception as e:
         write_error_message(url_path)
         write_exception(e)
         raise e
예제 #2
0
 def _to_url(cls, url_path):
     try:
         return u'{0}{1}'.format(cls.BASE_URL, url_path)
     except Exception as e:
         write_error_message(url_path)
         write_exception(e)
         raise e
예제 #3
0
    def test_exception_message(self):
        try:
            raise InvalidRequestError('Look for me in validation')
        except Exception as e:
            write_exception(e)

        output = self._stringio.getvalue()
        T.assert_equal(0, output.find('[ERROR] InvalidRequestError Look for me in validation'))
예제 #4
0
    def test_specific_exception(self):
        try:
            raise InvalidRequestError()
        except Exception as e:
            write_exception(e)

        output = self._stringio.getvalue()
        T.assert_equal(0, output.find('[ERROR] InvalidRequestError'))
예제 #5
0
    def test_simple_exception(self):
        try:
            raise Exception()
        except Exception as e:
            write_exception(e)

        output = self._stringio.getvalue()
        T.assert_equal(0, output.find('[ERROR]'))
예제 #6
0
    def test_specific_exception(self):
        try:
            raise InvalidRequestError()
        except Exception as e:
            write_exception(e)

        output = self._stringio.getvalue()
        T.assert_equal(0, output.find('[ERROR] InvalidRequestError'))
예제 #7
0
    def test_simple_exception(self):
        try:
            raise Exception()
        except Exception as e:
            write_exception(e)

        output = self._stringio.getvalue()
        T.assert_equal(0, output.find('[ERROR]'))
예제 #8
0
    def _to_urls(cls, fmt_url_path, url_path_args):
        url_paths = []
        for path_arg in url_path_args:
            try:
                url_paths.append(fmt_url_path.format(path_arg))
            except Exception as e:
                write_error_message(path_arg)
                write_exception(e)
                raise e

        return [cls._to_url(url_path) for url_path in url_paths]
예제 #9
0
    def _to_urls(cls, fmt_url_path, url_path_args):
        url_paths = []
        for path_arg in url_path_args:
            try:
                url_paths.append(fmt_url_path.format(path_arg))
            except Exception as e:
                write_error_message(path_arg)
                write_exception(e)
                raise e

        return [cls._to_url(url_path) for url_path in url_paths]
예제 #10
0
    def test_exception_message(self):
        try:
            raise InvalidRequestError('Look for me in validation')
        except Exception as e:
            write_exception(e)

        output = self._stringio.getvalue()
        T.assert_equal(
            0,
            output.find(
                '[ERROR] InvalidRequestError Look for me in validation'))
예제 #11
0
        def wrapper(*args, **kwargs):
            try:
                result = fn(*args, **kwargs)
                return result
            except InvalidRequestError as e:
                write_exception(e)

                if hasattr(e, 'request'):
                    write_error_message('request {0}'.format(repr(e.request)))
                if hasattr(e, 'response'):
                    write_error_message('response {0}'.format(repr(e.response)))

                raise e
예제 #12
0
파일: http.py 프로젝트: burdzz/threat_intel
        def wrapper(*args, **kwargs):
            try:
                result = fn(*args, **kwargs)
                return result
            except InvalidRequestError as e:
                write_exception(e)

                if hasattr(e, 'request'):
                    write_error_message('request {0}'.format(repr(e.request)))
                if hasattr(e, 'response'):
                    write_error_message('response {0}'.format(repr(e.response)))

                raise e