# Path: autopush/constants.py
# DEFAULT_ROUTER_TIMEOUT = 3
# 
# Path: autopush/exceptions.py
# class RouterException(AutopushException):
#     """Exception if routing has failed, may include a custom status_code and
#     body to write to the response.
# 
#     """
#     def __init__(self, message, status_code=500, response_body="",
#                  router_data=None, headers=None, log_exception=True,
#                  errno=None, logged_status=None, **kwargs):
#         """Create a new RouterException"""
#         super(AutopushException, self).__init__(message)
#         self.status_code = status_code
#         self.headers = {} if headers is None else headers
#         self.log_exception = log_exception
#         self.response_body = response_body or message
#         self.errno = errno
#         self.logged_status = logged_status
#         self.extra = kwargs


import json
import treq
from twisted.web.http_headers import Headers
from twisted.logger import Logger
from twisted.internet.error import ConnectError
from autopush.constants import DEFAULT_ROUTER_TIMEOUT
from autopush.exceptions import RouterException
    pass


class Result(object):
    """Abstraction object for GCM response"""

    def __init__(self, response, message):
        """Process GCM message and response into abstracted object

        :param message: Message payload
        :type message: JSONMessage
        :param response: GCM response
        :type response: requests.Response

        """
        self.success = {}
        self.canonicals = {}
        self.unavailable = []
        self.not_registered = []
        self.failed = {}

        self.message = message
        self.retry_message = None

        self.retry_after = (
            response.headers.getRawHeaders('Retry-After') or [None])[0]

    def parse_response(self, content, code, message):
        # 401 handled in GCM.process()
        if code in (400, 404):

# Path: autopush/constants.py
# DEFAULT_ROUTER_TIMEOUT = 3
# 
# Path: autopush/exceptions.py
# class RouterException(AutopushException):
#     """Exception if routing has failed, may include a custom status_code and
#     body to write to the response.
# 
#     """
#     def __init__(self, message, status_code=500, response_body="",
#                  router_data=None, headers=None, log_exception=True,
#                  errno=None, logged_status=None, **kwargs):
#         """Create a new RouterException"""
#         super(AutopushException, self).__init__(message)
#         self.status_code = status_code
#         self.headers = {} if headers is None else headers
#         self.log_exception = log_exception
#         self.response_body = response_body or message
#         self.errno = errno
#         self.logged_status = logged_status
#         self.extra = kwargs


# Path: autopush/router/gcmclient.py
import json
import treq
from twisted.web.http_headers import Headers
from twisted.logger import Logger
from twisted.internet.error import ConnectError
from autopush.constants import DEFAULT_ROUTER_TIMEOUT
from autopush.exceptions import RouterException

    pass


class Result(object):
    """Abstraction object for GCM response"""

    def __init__(self, response, message):
        """Process GCM message and response into abstracted object

        :param message: Message payload
        :type message: JSONMessage
        :param response: GCM response
        :type response: requests.Response

        """
        self.success = {}
        self.canonicals = {}
        self.unavailable = []
        self.not_registered = []
        self.failed = {}

        self.message = message
        self.retry_message = None

        self.retry_after = (
            response.headers.getRawHeaders('Retry-After') or [None])[0]

    def parse_response(self, content, code, message):
        # 401 handled in GCM.process()
        if code in (400, 404):

            raise RouterException(content)