requests.__version__

Here are the examples of the python api requests.__version__ taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

36 Examples 7

Example 1

Project: twine
Source File: cli.py
View license
def list_dependencies_and_versions():
    return [
        ('pkginfo', Installed(pkginfo).version),
        ('requests', requests.__version__),
        ('setuptools', setuptools.__version__),
        ('requests-toolbelt', requests_toolbelt.__version__),
        ('clint', clint.__version__),
    ]

Example 2

Project: habanero
Source File: habanero_utils.py
View license
def make_ua():
    requa = 'python-requests/' + requests.__version__
    habua = 'habanero/%s' % __version__
    ua = requa + ' ' + habua
    str = {
      'User-Agent': ua,
      'X-USER-AGENT': ua
    }
    return str

Example 3

Project: flask-rst
Source File: github.py
View license
def get_json_from_response(res):
    """
    This is only a stupid function to support requests befor and
    after 1.0.0.0
    """

    if requests.__version__ < '1.0.0':
        return res.json
    else:
        return res.json()

Example 4

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module
        self.policy_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 5

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module
        self.policy_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 6

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module
        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 7

Project: ansible-modules-extras
Source File: clc_group.py
View license
    def __init__(self, module):
        """
        Construct module
        """
        self.clc = clc_sdk
        self.module = module
        self.group_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 8

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.clc = clc_sdk
        self.module = module

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 9

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module
        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 10

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 11

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module
        self.policy_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 12

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module
        self.policy_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 13

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module
        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 14

Project: ansible-modules-extras
Source File: clc_group.py
View license
    def __init__(self, module):
        """
        Construct module
        """
        self.clc = clc_sdk
        self.module = module
        self.group_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 15

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.clc = clc_sdk
        self.module = module

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 16

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module
        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 17

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.module = module

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 18

Project: gym
Source File: __init__.py
View license
def sanity_check_dependencies():
    import numpy
    import requests
    import six

    if distutils.version.LooseVersion(numpy.__version__) < distutils.version.LooseVersion('1.10.4'):
        logger.warn("You have 'numpy' version %s installed, but 'gym' requires at least 1.10.4. HINT: upgrade via 'pip install -U numpy'.", numpy.__version__)

    if distutils.version.LooseVersion(requests.__version__) < distutils.version.LooseVersion('2.0'):
        logger.warn("You have 'requests' version %s installed, but 'gym' requires at least 2.0. HINT: upgrade via 'pip install -U requests'.", requests.__version__)

Example 19

Project: vdirsyncer
Source File: test_main.py
View license
def _fingerprints_broken():
    from pkg_resources import parse_version as ver
    broken_urllib3 = ver(requests.__version__) <= ver('2.5.1')
    return broken_urllib3

Example 20

Project: auth0-python
Source File: rest.py
View license
    def __init__(self, jwt, telemetry=True):
        self.jwt = jwt

        if telemetry:
            py_version = '%i.%i.%i' % (sys.version_info.major,
                                       sys.version_info.minor,
                                       sys.version_info.micro)

            # FIXME: is there a nicer way to do this?
            from ... import __version__ as version

            auth0_client = json.dumps({
                'name': 'auth0-python', 'version': version,
                'dependencies': [
                    {
                        'name': 'requests',
                        'version': requests.__version__,
                    }
                ],
                'environment': [
                    {
                        'name': 'python',
                        'version': py_version,
                    }
                ]
            }).encode('utf-8')

            self.base_headers = {
                'User-Agent': 'Python/%s' % py_version,
                'Auth0-Client': base64.b64encode(auth0_client),
                'Content-Type': 'application/json'
            }
        else:
            self.base_headers = {}

Example 21

Project: headphones
Source File: sni_test.py
View license
def check_installation():
    """
    Check if some core modules are available. Info is based on this topic:
    https://github.com/rembo10/headphones/issues/2210.
    """

    if can_import("requests"):
        import requests
        requests_version = requests.__version__
    else:
        requests_version = "no"

    if can_import("OpenSSL"):
        import OpenSSL
        openssl_version = OpenSSL.__version__
    else:
        openssl_version = "no"

    if can_import("cryptography"):
        import cryptography
        cryptography_version = cryptography.__version__
    else:
        cryptography_version = "no"

    if can_import("pyasn1"):
        import pyasn1
        pyasn1_version = pyasn1.__version__
    else:
        pyasn1_version = "no"

    if can_import("ndg.httpsclient"):
        from ndg import httpsclient
        ndg_version = httpsclient.__date__
    else:
        ndg_version = "no"

    # Print some system information.
    sys.stdout.write(
        "* Checking Python version: %s.%s.%s\n" % sys.version_info[:3])
    sys.stdout.write("* Operating system: %s\n" % sys.platform)

    sys.stdout.write(
        "* Checking if requests can be imported: %s\n" % requests_version)
    sys.stdout.write(
        "* Checking if pyOpenSSL is installed: %s\n" % openssl_version)
    sys.stdout.write(
        "* Checking if cryptography is installed: %s\n" % cryptography_version)
    sys.stdout.write(
        "* Checking if pyasn1 is installed: %s\n" % pyasn1_version)
    sys.stdout.write(
        "* Checking if ndg.httpsclient is installed: %s\n" % ndg_version)

Example 22

Project: SickRage
Source File: requests_transport.py
View license
    def __init__(self, use_https=True, authtype=None, username=None,
                 password=None, check_ssl_cert=True, proxies=None):
        """Inits RequestsTransport.

        Args:
            use_https: If true, https else http
            authtype: None, basic or digest
            username: Username
            password: Password
            check_ssl_cert: Check SSL certificate
            proxies: A dict of proxies(
                     Ex: {"http": "http://10.10.1.10:3128",
                          "https": "http://10.10.1.10:1080",})

        Raises:
            ValueError: Invalid info
        """
        # Python 2 can't use super on old style class.
        if issubclass(xmlrpc_client.Transport, object):
            super(RequestsTransport, self).__init__()
        else:
            xmlrpc_client.Transport.__init__(self)

        self.user_agent = "Python Requests/" + requests.__version__

        self._use_https = use_https
        self._check_ssl_cert = check_ssl_cert

        if authtype == "basic" or authtype == "digest":
            self._authtype = authtype
        else:
            raise ValueError(
                "Supported authentication are: basic and digest")
        if authtype and (not username or not password):
            raise ValueError(
                "Username and password required when using authentication")

        self._username = username
        self._password = password
        if proxies is None:
            self._proxies = {}
        else:
            self._proxies = proxies

Example 23

Project: pywikibot-core
Source File: version.py
View license
def main(*args):
    """Print pywikibot version and important settings."""
    pywikibot.output('Pywikibot: %s' % getversion())
    pywikibot.output('Release version: %s' % pywikibot.__release__)
    pywikibot.output('requests version: %s' % requests.__version__)

    has_wikimedia_cert = False
    if (not hasattr(requests, 'certs') or
            not hasattr(requests.certs, 'where') or
            not callable(requests.certs.where)):
        pywikibot.output('  cacerts: not defined')
    elif not os.path.isfile(requests.certs.where()):
        pywikibot.output('  cacerts: %s (missing)' % requests.certs.where())
    else:
        pywikibot.output('  cacerts: %s' % requests.certs.where())

        with codecs.open(requests.certs.where(), 'r', 'utf-8') as cert_file:
            text = cert_file.read()
            if WMF_CACERT in text:
                has_wikimedia_cert = True
        pywikibot.output(u'    certificate test: %s'
                         % ('ok' if has_wikimedia_cert else 'not ok'))
    if not has_wikimedia_cert:
        pywikibot.output(
            '  Please reinstall requests!')

    pywikibot.output('Python: %s' % sys.version)

    check_environ('PYWIKIBOT2_DIR')
    check_environ('PYWIKIBOT2_DIR_PWB')
    check_environ('PYWIKIBOT2_NO_USER_CONFIG')
    pywikibot.output('Config base dir: {0}'.format(pywikibot.config2.base_dir))
    for family, usernames in pywikibot.config2.usernames.items():
        if usernames:
            pywikibot.output('Usernames for family "{0}":'.format(family))
            for lang, username in usernames.items():
                sysop_name = pywikibot.config2.sysopnames.get(family, {}).get(lang)
                if not sysop_name:
                    sysop_name = 'no sysop configured'
                elif sysop_name == username:
                    sysop_name = 'also sysop'
                pywikibot.output('\t{0}: {1} ({2})'.format(lang, username, sysop_name))

Example 24

Project: requestbuilder
Source File: suite.py
View license
    def get_user_agent(self):
        if self.__user_agent is None:
            user_agent = ['requestbuilder/{0}'.format(__version__)]

            tokens = []
            impl = platform.python_implementation()
            if impl == 'PyPy':
                impl_version = '{0}.{1}.{2}'.format(
                    sys.pypy_version_info.major,
                    sys.pypy_version_info.minor,
                    sys.pypy_version_info.micro)
                if sys.pypy_version_info.releaselevel != 'final':
                    impl_version += sys.pypy_version_info.releaselevel
            else:
                # I'm guessing for non-CPython implementations; feel free to
                # submit patches or the needed implementation-specific API
                # references.
                impl_version = platform.python_version()
            tokens.append('{0} {1}'.format(impl, impl_version))
            plat = []
            try:
                plat.append(platform.system())
                plat.append(platform.release())
            except IOError:
                pass
            if plat:
                tokens.append(' '.join(plat))
            tokens.append(platform.machine())
            user_agent.append('({0})'.format('; '.join(tokens)))
            user_agent.append('requests/{0}'.format(requests.__version__))

            self.__user_agent = ' '.join(user_agent)
        return self.__user_agent

Example 25

Project: conda
Source File: main_info.py
View license
def execute(args, parser):
    import os
    from os.path import dirname

    import conda
    from conda.base.context import context
    from conda.models.channel import offline_keep
    from conda.resolve import Resolve
    from conda.api import get_index
    from conda.connection import user_agent

    if args.root:
        if context.json:
            stdout_json({'root_prefix': context.root_dir})
        else:
            print(context.root_dir)
        return

    if args.packages:
        index = get_index()
        r = Resolve(index)
        if context.json:
            stdout_json({
                package: [p._asdict()
                          for p in sorted(r.get_pkgs(arg2spec(package)))]
                for package in args.packages
            })
        else:
            for package in args.packages:
                versions = r.get_pkgs(arg2spec(package))
                for pkg in sorted(versions):
                    pretty_package(pkg)
        return

    options = 'envs', 'system', 'license'

    try:
        from conda.install import linked_data
        root_pkgs = linked_data(sys.prefix)
    except:
        root_pkgs = None

    try:
        import requests
        requests_version = requests.__version__
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        import conda_env
        conda_env_version = conda_env.__version__
    except:
        try:
            cenv = [p for p in itervalues(root_pkgs) if p['name'] == 'conda-env']
            conda_env_version = cenv[0]['version']
        except:
            conda_env_version = "not installed"

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    channels = context.channels

    if args.unsafe_channels:
        if not context.json:
            print("\n".join(channels))
        else:
            print(json.dumps({"channels": channels}))
        return 0

    channels = list(prioritize_channels(channels).keys())
    if not context.json:
        channels = [c + ('' if offline_keep(c) else '  (offline)')
                    for c in channels]
    channels = [mask_anaconda_token(c) for c in channels]

    info_dict = dict(
        platform=context.subdir,
        conda_version=conda.__version__,
        conda_env_version=conda_env_version,
        conda_build_version=conda_build_version,
        root_prefix=context.root_dir,
        conda_prefix=context.conda_prefix,
        conda_private=context.conda_private,
        root_writable=context.root_writable,
        pkgs_dirs=context.pkgs_dirs,
        envs_dirs=context.envs_dirs,
        default_prefix=context.default_prefix,
        channels=channels,
        rc_path=rc_path,
        user_rc_path=user_rc_path,
        sys_rc_path=sys_rc_path,
        # is_foreign=bool(foreign),
        offline=context.offline,
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
        requests_version=requests_version,
        user_agent=user_agent,
    )
    if not on_win:
        info_dict['UID'] = os.geteuid()
        info_dict['GID'] = os.getegid()

    if args.all or context.json:
        for option in options:
            setattr(args, option, True)

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 26 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable' if info_dict['root_writable'] else
                               'read only')
        print("""\
Current conda install:

               platform : %(platform)s
          conda version : %(conda_version)s
       conda is private : %(conda_private)s
      conda-env version : %(conda_env_version)s
    conda-build version : %(conda_build_version)s
         python version : %(python_version)s
       requests version : %(requests_version)s
       root environment : %(root_prefix)s  (%(_rtwro)s)
    default environment : %(default_prefix)s
       envs directories : %(_envs_dirs)s
          package cache : %(_pkgs_dirs)s
           channel URLs : %(_channels)s
            config file : %(rc_path)s
           offline mode : %(offline)s
             user-agent : %(user_agent)s\
""" % info_dict)

        if not on_win:
            print("""\
                UID:GID : %(UID)s:%(GID)s
""" % info_dict)
        else:
            print()

    if args.envs:
        handle_envs_list(info_dict['envs'], not context.json)

    if args.system:
        from conda.cli.find_commands import find_commands, find_executable

        site_dirs = get_user_site()
        evars = ['PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
                 'CIO_TEST', 'CONDA_ENVS_PATH']

        if context.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif context.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')

        if context.json:
            info_dict['sys.version'] = sys.version
            info_dict['sys.prefix'] = sys.prefix
            info_dict['sys.executable'] = sys.executable
            info_dict['site_dirs'] = get_user_site()
            info_dict['env_vars'] = {ev: os.getenv(ev, '<not set>') for ev in evars}
        else:
            print("sys.version: %s..." % (sys.version[:40]))
            print("sys.prefix: %s" % sys.prefix)
            print("sys.executable: %s" % sys.executable)
            print("conda location: %s" % dirname(conda.__file__))
            for cmd in sorted(set(find_commands() + ['build'])):
                print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
            print("user site dirs: ", end='')
            if site_dirs:
                print(site_dirs[0])
            else:
                print()
            for site_dir in site_dirs[1:]:
                print('                %s' % site_dir)
            print()

            for ev in sorted(evars):
                print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
            print()

    if args.license and not context.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if context.json:
        stdout_json(info_dict)

Example 26

Project: euca2ools
Source File: __init__.py
View license
    def get_user_agent(self):
        if self.__user_agent is None:
            user_agent_bits = ['euca2ools/{0}'.format(__version__)]

            tokens = []
            impl = platform.python_implementation()
            if impl == 'PyPy':
                # pylint: disable=E1101
                impl_version = '{0}.{1}.{2}'.format(
                    sys.pypy_version_info.major,
                    sys.pypy_version_info.minor,
                    sys.pypy_version_info.micro)
                if sys.pypy_version_info.releaselevel != 'final':
                    impl_version += sys.pypy_version_info.releaselevel
                # pylint: enable=E1101
            else:
                # I'm guessing for non-CPython implementations; feel free to
                # submit patches or the needed implementation-specific API
                # references.
                impl_version = platform.python_version()
            tokens.append('{0} {1}'.format(impl, impl_version))
            plat = []
            try:
                plat.append(platform.system())
                plat.append(platform.release())
            except IOError:
                pass
            if plat:
                tokens.append(' '.join(plat))
            tokens.append(platform.machine())
            user_agent_bits.append('({0})'.format('; '.join(tokens)))

            user_agent_bits.append('requestbuilder/{0}'.format(
                requestbuilder.__version__))
            user_agent_bits.append('requests/{0}'.format(requests.__version__))
            self.__user_agent = ' '.join(user_agent_bits)
        return self.__user_agent

Example 27

View license
    def test_requests_version(self):
        client_args_timeout = {
            "key": "AIzaasdf",
            "client_id": "foo",
            "client_secret": "a2V5",
            "channel": "MyChannel_1",
            "connect_timeout": 5,
            "read_timeout": 5
        }
        client_args = client_args_timeout.copy()
        del client_args["connect_timeout"]
        del client_args["read_timeout"]

        requests.__version__ = '2.3.0'
        with self.assertRaises(NotImplementedError):
            googlemaps.Client(**client_args_timeout)
        googlemaps.Client(**client_args)

        requests.__version__ = '2.4.0'
        googlemaps.Client(**client_args_timeout)
        googlemaps.Client(**client_args)

Example 28

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.clc = clc_sdk
        self.module = module
        self.firewall_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 29

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.clc = clc_sdk
        self.module = module
        self.lb_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 30

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.clc = clc_sdk
        self.module = module
        self.firewall_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 31

View license
    def __init__(self, module):
        """
        Construct module
        """
        self.clc = clc_sdk
        self.module = module
        self.lb_dict = {}

        if not CLC_FOUND:
            self.module.fail_json(
                msg='clc-python-sdk required for this module')
        if not REQUESTS_FOUND:
            self.module.fail_json(
                msg='requests library is required for this module')
        if requests.__version__ and LooseVersion(
                requests.__version__) < LooseVersion('2.5.0'):
            self.module.fail_json(
                msg='requests library  version should be >= 2.5.0')

        self._set_user_agent(self.clc)

Example 32

Project: appurify-python
Source File: utils.py
View license
    @staticmethod
    def user_agent(): # pragma: no cover
        """Returns string representation of user-agent"""
        implementation = platform.python_implementation()

        if implementation == 'CPython':
            version = platform.python_version()
        elif implementation == 'PyPy':
            version = '%s.%s.%s' % (sys.pypy_version_info.major, sys.pypy_version_info.minor, sys.pypy_version_info.micro)
        elif implementation == 'Jython':
            version = platform.python_version()
        elif implementation == 'IronPython':
            version = platform.python_version()
        else:
            version = 'Unknown'

        try:
            system = platform.system()
            release = platform.release()
        except IOError:
            system = 'Unknown'
            release = 'Unknown'

        return " ".join([
            'appurify-client/%s' % constants.__version__,
            'python-requests/%s' % requests.__version__,
            '%s/%s' % (implementation, version),
            '%s/%s' % (system, release)
        ])

Example 33

Project: appurify-python
Source File: utils.py
View license
    @staticmethod
    def user_agent(): # pragma: no cover
        """Returns string representation of user-agent"""
        implementation = platform.python_implementation()

        if implementation == 'CPython':
            version = platform.python_version()
        elif implementation == 'PyPy':
            version = '%s.%s.%s' % (sys.pypy_version_info.major, sys.pypy_version_info.minor, sys.pypy_version_info.micro)
        elif implementation == 'Jython':
            version = platform.python_version()
        elif implementation == 'IronPython':
            version = platform.python_version()
        else:
            version = 'Unknown'

        try:
            system = platform.system()
            release = platform.release()
        except IOError:
            system = 'Unknown'
            release = 'Unknown'

        return " ".join([
            'appurify-client/%s' % constants.__version__,
            'python-requests/%s' % requests.__version__,
            '%s/%s' % (implementation, version),
            '%s/%s' % (system, release)
        ])

Example 34

Project: python-taiga
Source File: requestmaker.py
View license
def _disable_pagination():
    if LooseVersion(requests.__version__) >= LooseVersion('2.11.0'):
        return 'True'
    else:
        return True

Example 35

Project: python-taiga
Source File: requestmaker.py
View license
def _disable_pagination():
    if LooseVersion(requests.__version__) >= LooseVersion('2.11.0'):
        return 'True'
    else:
        return True

Example 36

Project: stdeb
Source File: transport.py
View license
    def request(self, host, handler, request_body, verbose):
        """
        Make an xmlrpc request.
        """
        headers = {'User-Agent': self.user_agent,
                   'Content-Type': 'text/xml',
                   }
        url = self._build_url(host, handler)
        kwargs = {}
        if StrictVersion(requests.__version__) >= StrictVersion('0.8.8'):
            kwargs['verify']=True
        else:
            if self.use_https:
                warnings.warn('using https transport but no certificate '
                              'verification. (Hint: upgrade requests package.)')
        try:
            resp = requests.post(url, data=request_body, headers=headers,
                                 **kwargs)
        except ValueError:
            raise
        except Exception:
            raise # something went wrong
        else:
            try:
                resp.raise_for_status()
            except requests.RequestException as e:
                raise xmlrpc.ProtocolError(url, resp.status_code, 
                                                        str(e), resp.headers)
            else:
                return self.parse_response(resp)