Python requests.__version__() Examples
The following are 29
code examples of requests.__version__().
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 also want to check out all available functions/classes of the module
requests
, or try the search function
.
Example #1
Source File: http.py From terraform-templates with Apache License 2.0 | 6 votes |
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 #2
Source File: test_client.py From google-maps-services-python with Apache License 2.0 | 6 votes |
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 #3
Source File: __init__.py From gym-pull with MIT License | 6 votes |
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 #4
Source File: main.py From streamlink with BSD 2-Clause "Simplified" License | 6 votes |
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
Source File: main.py From liveproxy with BSD 2-Clause "Simplified" License | 6 votes |
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
Source File: api_client.py From gocardless-pro-python with MIT License | 5 votes |
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 #7
Source File: discordrest.py From Titan with GNU Affero General Public License v3.0 | 5 votes |
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 #8
Source File: client.py From sewer with MIT License | 5 votes |
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 #9
Source File: x509.py From bazarr with GNU General Public License v3.0 | 5 votes |
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 #10
Source File: appengine.py From bazarr with GNU General Public License v3.0 | 5 votes |
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 #11
Source File: requestmaker.py From python-taiga with MIT License | 5 votes |
def _requests_compatible_true(): if LooseVersion(requests.__version__) >= LooseVersion('2.11.0'): return 'True' else: return True
Example #12
Source File: fishnet.py From fishnet with GNU General Public License v3.0 | 5 votes |
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 #13
Source File: fishnet.py From fishnet with GNU General Public License v3.0 | 5 votes |
def make_request(self): return { "fishnet": { "version": __version__, "python": platform.python_version(), "apikey": get_key(self.conf), }, "stockfish": self.stockfish_info, }
Example #14
Source File: help.py From script.module.openscrapers with GNU General Public License v3.0 | 5 votes |
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 #15
Source File: dwarf.py From Dwarf with GNU General Public License v3.0 | 5 votes |
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 #16
Source File: habanero_utils.py From habanero with MIT License | 5 votes |
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 #17
Source File: cmd_version.py From python-alerta-client with Apache License 2.0 | 5 votes |
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
Source File: setup.py From python-zulip-api with Apache License 2.0 | 5 votes |
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 #19
Source File: appengine.py From Requester with MIT License | 5 votes |
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 #20
Source File: x509.py From addon with GNU General Public License v3.0 | 5 votes |
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 #21
Source File: appengine.py From addon with GNU General Public License v3.0 | 5 votes |
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 #22
Source File: help.py From addon with GNU General Public License v3.0 | 5 votes |
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 #23
Source File: client.py From eclcli with Apache License 2.0 | 5 votes |
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 #24
Source File: client.py From eclcli with Apache License 2.0 | 5 votes |
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 #25
Source File: client.py From eclcli with Apache License 2.0 | 5 votes |
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 #26
Source File: gbifutils.py From pygbif with MIT License | 5 votes |
def make_ua(): return { "user-agent": "python-requests/" + requests.__version__ + ",pygbif/" + pygbif.__version__ }
Example #27
Source File: download.py From pygbif with MIT License | 5 votes |
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 #28
Source File: help.py From a4kScrapers with MIT License | 5 votes |
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 #29
Source File: fishnet.py From fishnet with GNU General Public License v3.0 | 4 votes |
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