How to use the jwplatform.PY3 function in jwplatform

To help you get started, we’ve selected a few jwplatform examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jwplayer / jwplatform-py / tests / test_build_request.py View on Github external
# -*- coding: utf-8 -*-

import time
import hashlib
import jwplatform

if jwplatform.PY3:
    from urllib.parse import quote
    unicode = lambda s: str(s)
else:
    from urllib import quote


def test_required_parameters_present():

    KEY = 'api_key'
    SECRET = 'api_secret'

    jwp_client = jwplatform.Client(KEY, SECRET)

    url, params = jwp_client._build_request('')

    assert url == 'https://api.jwplatform.com/v1'
github jwplayer / jwplatform-py / jwplatform / client.py View on Github external
BACKOFF_FACTOR = 1.7
RETRY_COUNT = 5


class RetryAdapter(HTTPAdapter):
    """Exponential backoff http adapter.
    """
    def __init__(self, *args, **kwargs):
        super(RetryAdapter, self).__init__(*args, **kwargs)
        self.max_retries = Retry(total=RETRY_COUNT,
                                 backoff_factor=BACKOFF_FACTOR)


if PY3:
    from urllib.parse import quote
    unicode = lambda s: str(s)
else:
    from urllib import quote


class Client(object):
    """JW Platform API client.

    An API client for the JW Platform. For the API documentation see:
    https://developer.jwplayer.com/jw-platform/reference/v1/index.html

    Args:
        key (str): API User key
        secret (str): API User secret
        scheme (str, optional): Connection scheme: 'http' or 'https'.