Ejemplo n.º 1
0
    def __init__(self, app_id, key, secret, ssl=True, host=None, port=None, timeout=5, cluster=None,
                 json_encoder=None, json_decoder=None, backend=RequestsBackend, **backend_options):
        self._app_id = ensure_text(app_id, "app_id")
        if not app_id_re.match(self._app_id):
            raise ValueError("Invalid app id")

        self._key = ensure_text(key, "key")
        self._secret = ensure_text(secret, "secret")

        if not isinstance(ssl, bool):
            raise TypeError("SSL should be a boolean")
        self._ssl = ssl

        if host:
            self._host = ensure_text(host, "host")
        elif cluster:
            self._host = six.text_type("api-%s.pusher.com") % ensure_text(cluster, "cluster")
        else:
            self._host = six.text_type("api.pusherapp.com")

        if port and not isinstance(port, six.integer_types):
            raise TypeError("port should be an integer")
        self._port = port or (443 if ssl else 80)

        if not isinstance(timeout, six.integer_types):
            raise TypeError("timeout should be an integer")
        self._timeout = timeout
        self._json_encoder = json_encoder
        self._json_decoder = json_decoder

        self.http = backend(self, **backend_options)
Ejemplo n.º 2
0
    def __init__(
            self, app_id, key, secret, ssl=True, host=None, port=None,
            timeout=5, cluster=None, json_encoder=None, json_decoder=None,
            backend=None, **backend_options):
        if backend is None:
              from .requests import RequestsBackend
              backend = RequestsBackend

        self._app_id = ensure_text(app_id, "app_id")
        if not app_id_re.match(self._app_id):
              raise ValueError("Invalid app id")

        self._key = ensure_text(key, "key")
        self._secret = ensure_text(secret, "secret")

        if not isinstance(ssl, bool):
              raise TypeError("SSL should be a boolean")

        self._ssl = ssl

        if port and not isinstance(port, six.integer_types):
              raise TypeError("port should be an integer")

        self._port = port or (443 if ssl else 80)

        if not isinstance(timeout, six.integer_types):
              raise TypeError("timeout should be an integer")

        self._timeout = timeout
        self._json_encoder = json_encoder
        self._json_decoder = json_decoder

        self.http = backend(self, **backend_options)
Ejemplo n.º 3
0
    def __init__(self,
                 app_id,
                 key,
                 secret,
                 ssl=True,
                 host=None,
                 port=None,
                 timeout=5,
                 cluster=None,
                 encryption_master_key=None,
                 encryption_master_key_base64=None,
                 json_encoder=None,
                 json_decoder=None,
                 backend=None,
                 **backend_options):

        if backend is None:
            from .requests import RequestsBackend
            backend = RequestsBackend

        self._app_id = ensure_text(app_id, "app_id")
        if not app_id_re.match(self._app_id):
            raise ValueError("Invalid app id")

        self._key = ensure_text(key, "key")
        self._secret = ensure_text(secret, "secret")

        if not isinstance(ssl, bool):
            raise TypeError("SSL should be a boolean")

        self._ssl = ssl

        if host:
            self._host = ensure_text(host, "host")
        elif cluster:
            self._host = (six.text_type("api-%s.pusher.com") %
                          ensure_text(cluster, "cluster"))
        else:
            self._host = six.text_type("api.pusherapp.com")

        if port and not isinstance(port, six.integer_types):
            raise TypeError("port should be an integer")

        self._port = port or (443 if ssl else 80)

        if not isinstance(timeout, six.integer_types):
            raise TypeError("timeout should be an integer")

        self._timeout = timeout
        self._json_encoder = json_encoder
        self._json_decoder = json_decoder

        self._encryption_master_key = parse_master_key(
            encryption_master_key, encryption_master_key_base64)

        self.http = backend(self, **backend_options)
Ejemplo n.º 4
0
    def __init__(self,
                 app_id,
                 key,
                 secret,
                 ssl=True,
                 host=None,
                 port=None,
                 timeout=5,
                 cluster=None,
                 encryption_master_key=None,
                 json_encoder=None,
                 json_decoder=None,
                 backend=None,
                 **backend_options):
        if backend is None:
            from .requests import RequestsBackend
            backend = RequestsBackend

        self._app_id = ensure_text(app_id, "app_id")
        if not app_id_re.match(self._app_id):
            raise ValueError("Invalid app id")

        self._key = ensure_text(key, "key")
        self._secret = ensure_text(secret, "secret")

        if not isinstance(ssl, bool):
            raise TypeError("SSL should be a boolean")

        self._ssl = ssl

        if port and not isinstance(port, six.integer_types):
            raise TypeError("port should be an integer")

        self._port = port or (443 if ssl else 80)

        if not isinstance(timeout, six.integer_types):
            raise TypeError("timeout should be an integer")

        self._timeout = timeout
        self._json_encoder = json_encoder
        self._json_decoder = json_decoder

        if encryption_master_key is not None:
            encryption_master_key = ensure_binary(encryption_master_key,
                                                  "encryption_master_key")

        self._encryption_master_key = encryption_master_key

        self.http = backend(self, **backend_options)
Ejemplo n.º 5
0
    def __init__(self,
                 app_id,
                 key,
                 secret,
                 ssl=False,
                 host=None,
                 port=None,
                 cluster=None):
        if not isinstance(app_id, six.text_type):
            raise TypeError("App ID should be %s" % text)

        if not isinstance(key, six.text_type):
            raise TypeError("Key should be %s" % text)

        if not isinstance(secret, six.text_type):
            raise TypeError("Secret should be %s" % text)

        if not app_id_re.match(app_id):
            raise ValueError("Invalid app id")

        if port and not isinstance(port, six.integer_types):
            raise TypeError("Port should be a number")

        if not isinstance(ssl, bool):
            raise TypeError("SSL should be a boolean")

        self.app_id = app_id
        self.key = key
        self.secret = secret

        if host:
            if not isinstance(host, six.text_type):
                raise TypeError("Host should be %s" % text)

            self.host = host
        elif cluster:
            if not isinstance(cluster, six.text_type):
                raise TypeError("Cluster should be %s" % text)

            self.host = "api-%s.pusher.com" % cluster
        else:
            self.host = "api.pusherapp.com"

        self.port = port or (443 if ssl else 80)
        self.ssl = ssl