Python requests.__version__() Examples

The following are 29 code examples for showing how to use requests.__version__(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module requests , or try the search function .

Example 1
Project: gym-pull   Author: ppaquette   File: __init__.py    License: MIT License 6 votes vote down vote up
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__)

# We automatically configure a logger with a simple stderr handler. If
# you'd rather customize logging yourself, run undo_logger_setup.
#
# (Note: this needs to happen before importing the rest of gym, since
# we may print a warning at load time.) 
Example 2
Project: terraform-templates   Author: PaloAltoNetworks   File: http.py    License: Apache License 2.0 6 votes vote down vote up
def __init__(self,
                 timeout=None,
                 verify_cert=True):
        self.timeout = timeout
        self.verify_cert = verify_cert

        if self.timeout is not None:
            try:
                self.timeout = float(self.timeout)
                if not self.timeout >= 0:
                    raise ValueError
            except ValueError:
                raise PanHttpError('Invalid timeout: %s' % self.timeout)

        self.using_requests = _using_requests

        if self.using_requests:
            self._http_request = self._http_request_requests
            if not self.verify_cert:
                requests.packages.urllib3.disable_warnings()
            self.requests_version = requests.__version__
        else:
            self._http_request = self._http_request_urllib 
Example 3
Project: google-maps-services-python   Author: googlemaps   File: test_client.py    License: Apache License 2.0 6 votes vote down vote up
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 4
Project: streamlink   Author: streamlink   File: main.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def log_current_versions():
    """Show current installed versions"""
    if logger.root.isEnabledFor(logging.DEBUG):
        # MAC OS X
        if sys.platform == "darwin":
            os_version = "macOS {0}".format(platform.mac_ver()[0])
        # Windows
        elif sys.platform.startswith("win"):
            os_version = "{0} {1}".format(platform.system(), platform.release())
        # linux / other
        else:
            os_version = platform.platform()

        log.debug("OS:         {0}".format(os_version))
        log.debug("Python:     {0}".format(platform.python_version()))
        log.debug("Streamlink: {0}".format(streamlink_version))
        log.debug("Requests({0}), Socks({1}), Websocket({2})".format(
            requests.__version__, socks_version, websocket_version)) 
Example 5
Project: liveproxy   Author: back-to   File: main.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def log_current_versions():
    '''Show current installed versions'''

    # MAC OS X
    if sys.platform == 'darwin':
        os_version = 'macOS {0}'.format(platform.mac_ver()[0])
    # Windows
    elif sys.platform.startswith('win'):
        os_version = '{0} {1}'.format(platform.system(), platform.release())
    # linux / other
    else:
        os_version = platform.platform()

    log.info('For LiveProxy support visit https://github.com/back-to/liveproxy')
    log.debug('OS:         {0}'.format(os_version))
    log.debug('Python:     {0}'.format(platform.python_version()))
    log.debug('LiveProxy:  {0}'.format(liveproxy_version))
    log.debug('Streamlink: {0}'.format(streamlink_version))
    log.debug('Requests:   {0}'.format(requests_version)) 
Example 6
Project: a4kScrapers   Author: a4k-openproject   File: help.py    License: MIT License 5 votes vote down vote up
def systemInfo():
    try:
        platform_info = {
            'system': platform.system(),
            'release': platform.release(),
        }
    except IOError:
        platform_info = {
            'system': 'Unknown',
            'release': 'Unknown',
        }

    return OrderedDict([
        ('platform', platform_info),
        ('interpreter', _pythonVersion()),
        ('cloudscraper', cloudscraper_version),
        ('requests', requests.__version__),
        ('urllib3', urllib3.__version__),
        ('OpenSSL', OrderedDict(
            [
                ('version', ssl.OPENSSL_VERSION),
                ('ciphers', getPossibleCiphers())
            ]
        ))
    ])

# ------------------------------------------------------------------------------- # 
Example 7
Project: pygbif   Author: sckott   File: download.py    License: MIT License 5 votes vote down vote up
def __init__(self, creator, email, polygon=None):
        """class to setup a JSON doc with the query and POST a request

        All predicates (default key-value or iterative based on a list of
        values) are combined with an AND statement. Iterative predicates are
        creating a subset equal statements combined with OR

        :param creator: User name.
        :param email: user email
        :param polygon: Polygon of points to extract data from
        """
        self.predicates = []
        self._main_pred_type = "and"

        self.url = "http://api.gbif.org/v1/occurrence/download/request"
        self.header = {
            "accept": "application/json",
            "content-type": "application/json",
            "user-agent": "".join(
                [
                    "python-requests/",
                    requests.__version__,
                    ",pygbif/",
                    package_metadata.__version__,
                ]
            ),
        }

        self.payload = {
            "creator": creator,
            "notification_address": [email],
            "send_notification": "true",
            "created": datetime.date.today().year,
            "predicate": {"type": self._main_pred_type, "predicates": self.predicates},
        }
        self.request_id = None

        # prepare the geometry polygon constructions
        if polygon:
            self.add_geometry(polygon) 
Example 8
Project: pygbif   Author: sckott   File: gbifutils.py    License: MIT License 5 votes vote down vote up
def make_ua():
    return {
        "user-agent": "python-requests/"
        + requests.__version__
        + ",pygbif/"
        + pygbif.__version__
    } 
Example 9
Project: eclcli   Author: nttcom   File: client.py    License: Apache License 2.0 5 votes vote down vote up
def init_poolmanager(self, *args, **kwargs):
        if requests.__version__ >= '2.4.1':
            kwargs.setdefault('socket_options', [
                (socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),
                (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
            ])
        super(TCPKeepAliveAdapter, self).init_poolmanager(*args, **kwargs) 
Example 10
Project: eclcli   Author: nttcom   File: client.py    License: Apache License 2.0 5 votes vote down vote up
def init_poolmanager(self, *args, **kwargs):
        if requests.__version__ >= '2.4.1':
            kwargs.setdefault('socket_options', [
                (socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),
                (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
            ])
        super(TCPKeepAliveAdapter, self).init_poolmanager(*args, **kwargs) 
Example 11
Project: eclcli   Author: nttcom   File: client.py    License: Apache License 2.0 5 votes vote down vote up
def init_poolmanager(self, *args, **kwargs):
        if requests.__version__ >= '2.4.1':
            kwargs.setdefault('socket_options', [
                (socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),
                (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
            ])
        super(TCPKeepAliveAdapter, self).init_poolmanager(*args, **kwargs) 
Example 12
Project: addon   Author: alfa-addon   File: help.py    License: GNU General Public License v3.0 5 votes vote down vote up
def systemInfo():
    try:
        platform_info = {
            'system': platform.system(),
            'release': platform.release(),
        }
    except IOError:
        platform_info = {
            'system': 'Unknown',
            'release': 'Unknown',
        }

    return OrderedDict([
        ('platform', platform_info),
        ('interpreter', _pythonVersion()),
        ('cloudscraper', cloudscraper_version),
        ('requests', requests.__version__),
        ('urllib3', urllib3.__version__),
        ('OpenSSL', OrderedDict(
            [
                ('version', ssl.OPENSSL_VERSION),
                ('ciphers', getPossibleCiphers())
            ]
        ))
    ])

# ------------------------------------------------------------------------------- # 
Example 13
Project: addon   Author: alfa-addon   File: appengine.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _check_version():
    if gaecontrib is None:
        raise exc.VersionMismatchError(
            "The toolbelt requires at least Requests 2.10.0 to be "
            "installed. Version {0} was found instead.".format(
                requests.__version__
            )
        ) 
Example 14
Project: addon   Author: alfa-addon   File: x509.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _check_version(self):
        if PyOpenSSLContext is None:
            raise exc.VersionMismatchError(
                "The X509Adapter requires at least Requests 2.12.0 to be "
                "installed. Version {0} was found instead.".format(
                    requests.__version__
                )
            ) 
Example 15
Project: Requester   Author: kylebebak   File: appengine.py    License: MIT License 5 votes vote down vote up
def _check_version():
    if gaecontrib is None:
        raise exc.VersionMismatchError(
            "The toolbelt requires at least Requests 2.10.0 to be "
            "installed. Version {0} was found instead.".format(
                requests.__version__
            )
        ) 
Example 16
Project: python-zulip-api   Author: zulip   File: setup.py    License: Apache License 2.0 5 votes vote down vote up
def version() -> str:
    version_py = os.path.join(os.path.dirname(__file__), "zulip", "__init__.py")
    with open(version_py) as in_handle:
        version_line = next(itertools.dropwhile(lambda x: not x.startswith("__version__"),
                                                in_handle))
    version = version_line.split('=')[-1].strip().replace('"', '')
    return version 
Example 17
Project: python-alerta-client   Author: alerta   File: cmd_version.py    License: Apache License 2.0 5 votes vote down vote up
def cli(ctx, obj):
    """Show Alerta server and client versions."""
    client = obj['client']
    click.echo('alerta {}'.format(client.mgmt_status()['version']))
    click.echo('alerta client {}'.format(client_version))
    click.echo('requests {}'.format(requests_version))
    click.echo('click {}'.format(click.__version__))
    ctx.exit() 
Example 18
Project: habanero   Author: sckott   File: habanero_utils.py    License: MIT License 5 votes vote down vote up
def make_ua(mailto=None, ua_string=None):
    requa = "python-requests/" + requests.__version__
    habua = "habanero/%s" % __version__
    ua = requa + " " + habua
    if mailto is not None:
        ua = ua + " (mailto:%s)" % mailto
    if ua_string is not None:
        if not isinstance(ua_string, str):
            raise TypeError("ua_string must be a str")
        ua = ua + " " + ua_string
    strg = {"User-Agent": ua, "X-USER-AGENT": ua}
    return strg 
Example 19
Project: Dwarf   Author: iGio90   File: dwarf.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _check_package_version(package_name, min_version):
    try:
        installed_version = None
        if package_name == 'frida':
            import frida
            installed_version = frida.__version__
        elif package_name == 'capstone':
            import capstone
            installed_version = capstone.__version__
        elif package_name == 'requests':
            import requests
            installed_version = requests.__version__
        elif package_name == 'pyqt5':
            from PyQt5 import QtCore
            installed_version = QtCore.PYQT_VERSION_STR
        elif package_name == 'pyperclip':
            import pyperclip
            installed_version = pyperclip.__version__
        if installed_version is not None:
            installed_version = installed_version.split('.')
            _min_version = min_version.split('.')
            needs_update = False
            if int(installed_version[0]) < int(_min_version[0]):
                needs_update = True
            elif (int(installed_version[0]) <= int(_min_version[0])) and (
                    int(installed_version[1]) < int(_min_version[1])):
                needs_update = True
            elif (int(installed_version[1]) <= int(_min_version[1])) and (
                    int(installed_version[2]) < int(_min_version[2])):
                needs_update = True

            if needs_update:
                print('updating ' + package_name + '... to ' + min_version)
                if pip_install_package(package_name + '>=' + min_version):
                    print('*** success ***')
    except Exception:  # pylint: disable=broad-except
        print('installing ' + package_name + '...')
        if pip_install_package(package_name + '>=' + min_version):
            print('*** success ***') 
Example 20
Project: script.module.openscrapers   Author: a4k-openproject   File: help.py    License: GNU General Public License v3.0 5 votes vote down vote up
def systemInfo():
    try:
        platform_info = {
            'system': platform.system(),
            'release': platform.release(),
        }
    except IOError:
        platform_info = {
            'system': 'Unknown',
            'release': 'Unknown',
        }

    return OrderedDict([
        ('platform', platform_info),
        ('interpreter', _pythonVersion()),
        ('cloudscraper', cloudscraper_version),
        ('requests', requests.__version__),
        ('urllib3', urllib3.__version__),
        ('OpenSSL', OrderedDict(
            [
                ('version', ssl.OPENSSL_VERSION),
                ('ciphers', getPossibleCiphers())
            ]
        ))
    ])

# ------------------------------------------------------------------------------- # 
Example 21
Project: fishnet   Author: niklasf   File: fishnet.py    License: GNU General Public License v3.0 5 votes vote down vote up
def make_request(self):
        return {
            "fishnet": {
                "version": __version__,
                "python": platform.python_version(),
                "apikey": get_key(self.conf),
            },
            "stockfish": self.stockfish_info,
        } 
Example 22
Project: fishnet   Author: niklasf   File: fishnet.py    License: GNU General Public License v3.0 5 votes vote down vote up
def update_available():
    try:
        result = requests.get("https://pypi.org/pypi/fishnet/json", timeout=HTTP_TIMEOUT).json()
        latest_version = result["info"]["version"]
    except Exception:
        logging.exception("Failed to check for update on PyPI")
        return False

    if latest_version == __version__:
        logging.info("[fishnet v%s] Client is up to date", __version__)
        return False
    else:
        logging.info("[fishnet v%s] Update available on PyPI: %s",
                     __version__, latest_version)
        return True 
Example 23
Project: python-taiga   Author: nephila   File: requestmaker.py    License: MIT License 5 votes vote down vote up
def _requests_compatible_true():
    if LooseVersion(requests.__version__) >= LooseVersion('2.11.0'):
        return 'True'
    else:
        return True 
Example 24
Project: bazarr   Author: morpheus65535   File: appengine.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _check_version():
    if gaecontrib is None:
        raise exc.VersionMismatchError(
            "The toolbelt requires at least Requests 2.10.0 to be "
            "installed. Version {} was found instead.".format(
                requests.__version__
            )
        ) 
Example 25
Project: bazarr   Author: morpheus65535   File: x509.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _check_version(self):
        if PyOpenSSLContext is None:
            raise exc.VersionMismatchError(
                "The X509Adapter requires at least Requests 2.12.0 to be "
                "installed. Version {} was found instead.".format(
                    requests.__version__
                )
            ) 
Example 26
Project: sewer   Author: komuw   File: client.py    License: MIT License 5 votes vote down vote up
def get_user_agent():
        return "python-requests/{requests_version} ({system}: {machine}) sewer {sewer_version} ({sewer_url})".format(
            requests_version=requests.__version__,
            system=platform.system(),
            machine=platform.machine(),
            sewer_version=sewer_version.__version__,
            sewer_url=sewer_version.__url__,
        ) 
Example 27
Project: Titan   Author: TitanEmbeds   File: discordrest.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def __init__(self, bot_token):
        self.global_redis_prefix = "discordapiratelimit/"
        self.bot_token = bot_token
        self.user_agent = "TitanEmbeds (https://github.com/TitanEmbeds/Titan) Python/{} requests/{}".format(sys.version_info, requests.__version__) 
Example 28
Project: gocardless-pro-python   Author: gocardless   File: api_client.py    License: MIT License 5 votes vote down vote up
def _user_agent(self):
        python_version = '.'.join(platform.python_version_tuple()[0:2])
        vm_version = '{}.{}.{}-{}{}'.format(*sys.version_info)
        return ' '.join([
            'gocardless-pro-python/1.19.0',
            'python/{0}'.format(python_version),
            '{0}/{1}'.format(platform.python_implementation(), vm_version),
            '{0}/{1}'.format(platform.system(), platform.release()),
            'requests/{0}'.format(requests.__version__),
        ]) 
Example 29
Project: fishnet   Author: niklasf   File: fishnet.py    License: GNU General Public License v3.0 4 votes vote down vote up
def display_config(args, conf):
    '''Display args and conf settings'''

    # Don't call validate here as stockfish should be validated from update_config.
    stockfish_command = conf_get(conf, "StockfishCommand")

    print()
    print("### Checking configuration ...")
    print()
    print("Python:           %s (with requests %s)" % (platform.python_version(), requests.__version__))
    print("EngineDir:        %s" % get_engine_dir(conf))
    print("StockfishCommand: %s" % stockfish_command)
    print("Key:              %s" % (("*" * len(get_key(conf))) or "(none)"))

    cores = validate_cores(conf_get(conf, "Cores"))
    print("Cores:            %d" % cores)

    threads = validate_threads_per_process(conf_get(conf, "ThreadsPerProcess"), conf)
    instances = max(1, cores // threads)
    print("Engine processes: %d (each ~%d threads)" % (instances, threads))
    memory = validate_memory(conf_get(conf, "Memory"), conf)
    print("Memory:           %d MB" % memory)
    endpoint = get_endpoint(conf)
    warning = "" if endpoint.startswith("https://") else " (WARNING: not using https)"
    print("Endpoint:         %s%s" % (endpoint, warning))
    user_backlog, system_backlog = validate_backlog(conf)
    print("UserBacklog:      %ds" % user_backlog)
    print("SystemBacklog:    %ds" % system_backlog)
    print("FixedBackoff:     %s" % parse_bool(conf_get(conf, "FixedBackoff")))
    print()

    if conf.has_section("Stockfish") and conf.items("Stockfish"):
        print("Using custom UCI options is discouraged:")
        for name, value in conf.items("Stockfish"):
            if name.lower() == "hash":
                hint = " (use --memory instead)"
            elif name.lower() == "threads":
                hint = " (use --threads-per-process instead)"
            else:
                hint = ""
            print(" * %s = %s%s" % (name, value, hint))
        print()

    if args.ignored_threads:
        print("Ignored deprecated option --threads. Did you mean --cores?")
        print()

    return cores, threads, instances, memory, user_backlog, system_backlog