Python requests 模块,__version__() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用requests.__version__()

项目:mygene.info    作者:biothings    | 项目源码 | 文件源码
def _get_options(self, options, kwargs):
        # this species parameter is added to the query, thus will
        # change facet counts.
        kwargs['species'] = self._cleaned_species(kwargs.get('species', None))
        include_tax_tree = kwargs.pop('include_tax_tree', False)
        if include_tax_tree:
            headers = {'content-type': 'application/x-www-form-urlencoded',
                       'user-agent': "Python-requests_mygene.info/%s (gzip)"
                       % requests.__version__}
            # TODO: URL as config param
            res = requests.post('http://t.biothings.io/v1/taxon?ids=' +
                                ','.join(['{}'.format(sid) for sid in
                                          kwargs['species']]) +
                                '&expand_species=true', headers=headers)
            if res.status_code == requests.codes.ok:
                kwargs['species'] = res.json()

        # this parameter is to add species filter without
        # changing facet counts.
        kwargs['species_facet_filter'] = self._cleaned_species(
                kwargs.get('species_facet_filter', None), default_to_none=True)
        options.kwargs = kwargs
        return options
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
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)
项目:gym-pull    作者:ppaquette    | 项目源码 | 文件源码
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.)
项目:Library    作者:clc-runner    | 项目源码 | 文件源码
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)
项目:Library    作者:clc-runner    | 项目源码 | 文件源码
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)
项目:mygene.py    作者:biothings    | 项目源码 | 文件源码
def _get(self, url, params={}, none_on_404=False, verbose=True):
        debug = params.pop('debug_get', False)
        return_raw = params.pop('return_raw', False)
        headers = {'user-agent': "mygene.py/%s python-requests/%s" % (__version__, requests.__version__)}
        res = requests.get(url, params=params, headers=headers)
        from_cache = getattr(res, 'from_cache', False)
        if debug:
            return from_cache, res
        if none_on_404 and res.status_code == 404:
            return from_cache, None
        if self.raise_for_status:
            # raise requests.exceptions.HTTPError if not 200
            res.raise_for_status()
        if return_raw:
            return from_cache, res.text
        ret = res.json()
        return from_cache, ret
项目:st-python-api    作者:Secure-Trading    | 项目源码 | 文件源码
def _get_requests_lib():
    try:
        import requests
        split_version = requests.__version__.split(".")
        requests_version = requests.__version__
    except ImportError as e:
        requests = None
        split_version = ["0", "0", "0"]
        requests_version = "Not found"

    requests_version = tuple(map(int, split_version))
    min_requests_version = securetrading.util.min_requests_version
    if requests_version < min_requests_version:
        data = ["Current requests version: {0}".format(requests_version)]
        raise securetrading.SecureTradingError("2", data=data)
    return requests
项目:mygene.info    作者:biothings    | 项目源码 | 文件源码
def _pre_query_builder_GET_hook(self, options):
        if options.esqb_kwargs.include_tax_tree and 'all' not in options.esqb_kwargs.species:
            headers = {'content-type': 'application/x-www-form-urlencoded',
                        'user-agent': 'Python-requests_mygene.info/{} (gzip)'.format(requests.__version__)}

            res = requests.post(self.web_settings.INCLUDE_TAX_TREE_REDIRECT_TEMPLATE.format(
                ids=','.join(['{}'.format(sid) for sid in options.esqb_kwargs.species])), headers=headers)

            if res.status_code == requests.codes.ok:
                options['esqb_kwargs']['species'] = [str(x) for x in res.json()]
                #logging.debug('tax_tree species: {}'.format(options.esqb_kwargs.species))

        return options
项目:vmware-nsxlib    作者:openstack    | 项目源码 | 文件源码
def provider_id(self):
        return "%s-%s" % (requests.__title__, requests.__version__)
项目:pyminer    作者:sckott    | 项目源码 | 文件源码
def make_ua():
    requa = 'python-requests/' + requests.__version__
    pymua = 'pyminer/%s' % __version__
    ua = requa + ' ' + pymua
    str = {
      'User-Agent': ua,
      'X-USER-AGENT': ua
    }
    return str
项目:pyminer    作者:sckott    | 项目源码 | 文件源码
def make_ua():
    requa = 'python-requests/' + requests.__version__
    pymua = 'pyminer/%s' % __version__
    ua = requa + ' ' + pymua
    str = {
      'User-Agent': ua,
      'X-USER-AGENT': ua
    }
    return str
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def print_debug_info(env):
    sys.stderr.writelines([
        'HTTPie %s\n' % httpie_version,
        'HTTPie data: %s\n' % env.config.directory,
        'Requests %s\n' % requests_version,
        'Pygments %s\n' % pygments_version,
        'Python %s %s\n' % (sys.version, sys.platform)
    ])
项目:flickr_downloader    作者:Denisolt    | 项目源码 | 文件源码
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__
            )
        )
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def _set_user_agent(clc):
        if hasattr(clc, 'SetRequestsSession'):
            agent_string = "ClcAnsibleModule/" + __version__
            ses = requests.Session()
            ses.headers.update({"Api-Client": agent_string})
            ses.headers['User-Agent'] += " " + agent_string
            clc.SetRequestsSession(ses)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def _set_user_agent(clc):
        if hasattr(clc, 'SetRequestsSession'):
            agent_string = "ClcAnsibleModule/" + __version__
            ses = requests.Session()
            ses.headers.update({"Api-Client": agent_string})
            ses.headers['User-Agent'] += " " + agent_string
            clc.SetRequestsSession(ses)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def _set_user_agent(clc):
        if hasattr(clc, 'SetRequestsSession'):
            agent_string = "ClcAnsibleModule/" + __version__
            ses = requests.Session()
            ses.headers.update({"Api-Client": agent_string})
            ses.headers['User-Agent'] += " " + agent_string
            clc.SetRequestsSession(ses)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def _set_user_agent(clc):
        if hasattr(clc, 'SetRequestsSession'):
            agent_string = "ClcAnsibleModule/" + __version__
            ses = requests.Session()
            ses.headers.update({"Api-Client": agent_string})
            ses.headers['User-Agent'] += " " + agent_string
            clc.SetRequestsSession(ses)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def _set_user_agent(clc):
        if hasattr(clc, 'SetRequestsSession'):
            agent_string = "ClcAnsibleModule/" + __version__
            ses = requests.Session()
            ses.headers.update({"Api-Client": agent_string})
            ses.headers['User-Agent'] += " " + agent_string
            clc.SetRequestsSession(ses)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def _set_user_agent(clc):
        if hasattr(clc, 'SetRequestsSession'):
            agent_string = "ClcAnsibleModule/" + __version__
            ses = requests.Session()
            ses.headers.update({"Api-Client": agent_string})
            ses.headers['User-Agent'] += " " + agent_string
            clc.SetRequestsSession(ses)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def _set_user_agent(clc):
        if hasattr(clc, 'SetRequestsSession'):
            agent_string = "ClcAnsibleModule/" + __version__
            ses = requests.Session()
            ses.headers.update({"Api-Client": agent_string})
            ses.headers['User-Agent'] += " " + agent_string
            clc.SetRequestsSession(ses)
项目:Liljimbo-Chatbot    作者:chrisjim316    | 项目源码 | 文件源码
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__
            )
        )
项目:AngelBot    作者:ccubed    | 项目源码 | 文件源码
def get_shard_count(self):
        r = requests.get(BOT_ENDPOINT, headers={
            "Authorization": "Bot {}".format(self.token),
            "User-Agent": 'DiscordBot (https://github.com/Rapptz/discord.py {0}) Python/{1[0]}.{1[1]} requests/{2}'.format(
                discord.__version__, sys.version_info, requests.__version__)
        })

        if r.status_code == 200:
            return r.json()['shards']+1
        else:
            return None
项目:sewer    作者:komuW    | 项目源码 | 文件源码
def get_user_agent(self):
        # TODO: add the sewer-acme versionto the 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__)
项目:gym    作者:openai    | 项目源码 | 文件源码
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 code runs before importing the rest of gym, since we may
# print a warning at load time.)
#
# It's generally not best practice to configure the logger in a
# library. We choose to do so because, empirically, many of our users
# are unfamiliar with Python's logging configuration, and never find
# their way to enabling our logging. Users who are aware of how to
# configure Python's logging do have to accept a bit of incovenience
# (generally by caling `gym.undo_logger_setup()`), but in exchange,
# the library becomes much more usable for the uninitiated.
#
# Gym's design goal generally is to be simple and intuitive, and while
# the tradeoff is definitely not obvious in this case, we've come down
# on the side of auto-configuring the logger.
项目:benzo    作者:coddingtonbear    | 项目源码 | 文件源码
def get_headers(self):
        formatter = self.get_output_formatter()

        return {
            'Content-Type': formatter.CONTENT_TYPE,
            'User-Agent': 'benzo/{benzo} python-requests/{requests}'.format(
                benzo=__version__,
                requests=requests.__version__,
            )
        }
项目:eclcli    作者:nttcom    | 项目源码 | 文件源码
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)
项目:eclcli    作者:nttcom    | 项目源码 | 文件源码
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)
项目:eclcli    作者:nttcom    | 项目源码 | 文件源码
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)
项目:Library    作者:clc-runner    | 项目源码 | 文件源码
def _set_user_agent(clc):
        if hasattr(clc, 'SetRequestsSession'):
            agent_string = "ClcAnsibleModule/" + __version__
            ses = requests.Session()
            ses.headers.update({"Api-Client": agent_string})
            ses.headers['User-Agent'] += " " + agent_string
            clc.SetRequestsSession(ses)
项目:Library    作者:clc-runner    | 项目源码 | 文件源码
def _set_user_agent(clc):
        if hasattr(clc, 'SetRequestsSession'):
            agent_string = "ClcAnsibleModule/" + __version__
            ses = requests.Session()
            ses.headers.update({"Api-Client": agent_string})
            ses.headers['User-Agent'] += " " + agent_string
            clc.SetRequestsSession(ses)
项目:mygene.py    作者:biothings    | 项目源码 | 文件源码
def _post(self, url, params, verbose=True):
        return_raw = params.pop('return_raw', False)
        headers = {'content-type': 'application/x-www-form-urlencoded',
                   'user-agent': "mygene.py/%s python-requests/%s" % (__version__, requests.__version__)}
        res = requests.post(url, data=params, headers=headers)
        from_cache = getattr(res, 'from_cache', False)
        if self.raise_for_status:
            # raise requests.exceptions.HTTPError if not 200
            res.raise_for_status()
        if return_raw:
            return from_cache, res
        ret = res.json()
        return from_cache, ret
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def print_debug_info(env):
    sys.stderr.writelines([
        'HTTPie %s\n' % httpie_version,
        'HTTPie data: %s\n' % env.config.directory,
        'Requests %s\n' % requests_version,
        'Pygments %s\n' % pygments_version,
        'Python %s %s\n' % (sys.version, sys.platform)
    ])
项目:strawpoll.py    作者:PapyrusThePlant    | 项目源码 | 文件源码
def __init__(self, loop=None, requests_policy=RequestsPolicy.asynchronous):
        self.loop = loop if loop is not None else asyncio.get_event_loop()
        self.requests_policy = requests_policy

        # Build our default headers
        fmt = '{0}/{1} ({2}) Python/{3.major}.{3.minor}.{3.micro} aiohttp/{4} requests/{5}'
        user_agent = fmt.format(__title__, __version__, __url__, version_info, aiohttp.__version__, requests.__version__)
        self.default_headers = {'User-Agent': user_agent}

        # Prepare the sessions
        self.session_async = aiohttp.ClientSession(loop=loop, headers=self.default_headers)
        self.session_sync = requests.Session()
        self.session_sync.headers = self.default_headers
项目:OctoFusion    作者:tapnair    | 项目源码 | 文件源码
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__
            )
        )
项目:AI-Fight-the-Landlord    作者:YoungGer    | 项目源码 | 文件源码
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 code runs before importing the rest of gym, since we may
# print a warning at load time.)
#
# It's generally not best practice to configure the logger in a
# library. We choose to do so because, empirically, many of our users
# are unfamiliar with Python's logging configuration, and never find
# their way to enabling our logging. Users who are aware of how to
# configure Python's logging do have to accept a bit of incovenience
# (generally by caling `gym.undo_logger_setup()`), but in exchange,
# the library becomes much more usable for the uninitiated.
#
# Gym's design goal generally is to be simple and intuitive, and while
# the tradeoff is definitely not obvious in this case, we've come down
# on the side of auto-configuring the logger.
项目:fishnet    作者:niklasf    | 项目源码 | 文件源码
def make_request(self):
        return {
            "fishnet": {
                "version": __version__,
                "python": platform.python_version(),
                "apikey": get_key(self.conf),
            },
            "stockfish": self.stockfish_info,
        }
项目:fishnet    作者:niklasf    | 项目源码 | 文件源码
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
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def print_debug_info(env):
    env.stderr.writelines([
        'HTTPie %s\n' % httpie_version,
        'Requests %s\n' % requests_version,
        'Pygments %s\n' % pygments_version,
        'Python %s\n%s\n' % (sys.version, sys.executable),
        '%s %s' % (platform.system(), platform.release()),
    ])
    env.stderr.write('\n\n')
    env.stderr.write(repr(env))
    env.stderr.write('\n')
项目:gym-adv    作者:lerrel    | 项目源码 | 文件源码
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 code runs before importing the rest of gym, since we may
# print a warning at load time.)
#
# It's generally not best practice to configure the logger in a
# library. We choose to do so because, empirically, many of our users
# are unfamiliar with Python's logging configuration, and never find
# their way to enabling our logging. Users who are aware of how to
# configure Python's logging do have to accept a bit of incovenience
# (generally by caling `gym.undo_logger_setup()`), but in exchange,
# the library becomes much more usable for the uninitiated.
#
# Gym's design goal generally is to be simple and intuitive, and while
# the tradeoff is definitely not obvious in this case, we've come down
# on the side of auto-configuring the logger.
项目:python-zulip-api    作者:zulip    | 项目源码 | 文件源码
def version():
    # type: () -> 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
项目:sewer    作者:komuW    | 项目源码 | 文件源码
def __init__(
            self,
            domain_name,
            dns_class,
            domain_alt_names=[],
            registration_recovery_email=None,
            account_key=None,
            bits=2048,
            digest='sha256',
            ACME_REQUEST_TIMEOUT=65,
            ACME_CHALLENGE_WAIT_PERIOD=4,
            GET_NONCE_URL="https://acme-v01.api.letsencrypt.org/directory",
            ACME_CERTIFICATE_AUTHORITY_URL="https://acme-v01.api.letsencrypt.org",
            ACME_CERTIFICATE_AUTHORITY_TOS='https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf',
            ACME_CERTIFICATE_AUTHORITY_CHAIN='https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem'
    ):

        self.logger = get_logger(__name__).bind(
            client_name=self.__class__.__name__)

        self.domain_name = domain_name
        self.dns_class = dns_class
        self.domain_alt_names = domain_alt_names
        self.all_domain_names = copy.copy(self.domain_alt_names)
        self.all_domain_names.insert(0, self.domain_name)
        self.registration_recovery_email = registration_recovery_email
        self.bits = bits
        self.digest = digest
        self.ACME_REQUEST_TIMEOUT = ACME_REQUEST_TIMEOUT
        self.ACME_CHALLENGE_WAIT_PERIOD = ACME_CHALLENGE_WAIT_PERIOD
        self.GET_NONCE_URL = GET_NONCE_URL
        self.ACME_CERTIFICATE_AUTHORITY_URL = ACME_CERTIFICATE_AUTHORITY_URL
        self.ACME_CERTIFICATE_AUTHORITY_TOS = ACME_CERTIFICATE_AUTHORITY_TOS
        self.ACME_CERTIFICATE_AUTHORITY_CHAIN = ACME_CERTIFICATE_AUTHORITY_CHAIN
        self.User_Agent = self.get_user_agent()
        self.certificate_key = self.create_certificate_key()
        self.csr = self.create_csr()
        self.certificate_chain = self.get_certificate_chain()

        if not account_key:
            self.account_key = self.create_account_key()
            self.PRIOR_REGISTERED = False
        else:
            self.account_key = account_key
            self.PRIOR_REGISTERED = True

        self.logger = self.logger.bind(
            sewer_client_name=self.__class__.__name__,
            sewer_client_version=sewer_version.__version__,
            domain_names=self.all_domain_names,
            ACME_CERTIFICATE_AUTHORITY_URL=self.ACME_CERTIFICATE_AUTHORITY_URL)

        # for staging/test, use:
        # GET_NONCE_URL="https://acme-staging.api.letsencrypt.org/directory",
        # ACME_CERTIFICATE_AUTHORITY_URL="https://acme-staging.api.letsencrypt.org"