当前位置: 首页>>代码示例>>Python>>正文


Python pkg_resources.parse_version方法代码示例

本文整理汇总了Python中pkg_resources.parse_version方法的典型用法代码示例。如果您正苦于以下问题:Python pkg_resources.parse_version方法的具体用法?Python pkg_resources.parse_version怎么用?Python pkg_resources.parse_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pkg_resources的用法示例。


在下文中一共展示了pkg_resources.parse_version方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: checkGCC

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def checkGCC():
    global System
    global gccMinVersion
    print "Checking GCC version..."
    command = "gcc --version | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'"
    out = runCommand(command)
    gccVersion = out.split("\n")[0]
    if parse_version(gccVersion) < parse_version(gccMinVersion):
        if "Ubuntu" in System or "ubuntu" in System:
            command = "sudo apt-get install gcc"
        elif "Amazon Linux AMI" in System:
            command = "sudo yum install gcc"
        runCommand2(command, "y\n")
    command = "gcc --version | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'"
    gccVersion = out.split("\n")[0]
    if parse_version(gccVersion) < parse_version(gccMinVersion):
        print "Error: GCC version is " + gccVersion + " < " + gccMinVersion
        sys.exit()
    else:
        print "GCC version is " + gccVersion + " >= " + gccMinVersion + bcolors.OKGREEN + " [OK]" + bcolors.ENDC 
开发者ID:insightfinder,项目名称:InsightAgent,代码行数:22,代码来源:installLttng.py

示例2: fail_first_step_precondition_exception

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def fail_first_step_precondition_exception(self, scenario):
        """
        Fail first step in the given Scenario and add exception message for the output.
        This is needed because xUnit exporter in Behave fails if there are not failed steps.
        :param scenario: Behave's Scenario
        """

        try:
            import behave
            if parse_version(behave.__version__) < parse_version('1.2.6'):
                status = 'failed'
            else:
                status = behave.model_core.Status.failed
        except ImportError as exc:
            self.logger.error(exc)
            raise

        scenario.steps[0].status = status
        scenario.steps[0].exception = Exception("Preconditions failed")
        scenario.steps[0].error_message = str(self.error_exception) 
开发者ID:Telefonica,项目名称:toolium,代码行数:22,代码来源:env_utils.py

示例3: check_qt_version

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def check_qt_version():
    """Check if the Qt version is recent enough."""
    from PyQt5.QtCore import (qVersion, QT_VERSION, PYQT_VERSION,
                              PYQT_VERSION_STR)
    from pkg_resources import parse_version
    from qutebrowser.utils import log
    parsed_qversion = parse_version(qVersion())

    if (QT_VERSION < 0x050701 or PYQT_VERSION < 0x050700 or
            parsed_qversion < parse_version('5.7.1')):
        text = ("Fatal error: Qt >= 5.7.1 and PyQt >= 5.7 are required, "
                "but Qt {} / PyQt {} is installed.".format(qt_version(),
                                                           PYQT_VERSION_STR))
        _die(text)

    if qVersion().startswith('5.8.'):
        log.init.warning("Running qutebrowser with Qt 5.8 is untested and "
                         "unsupported!")

    if (parsed_qversion >= parse_version('5.12') and
            (PYQT_VERSION < 0x050c00 or QT_VERSION < 0x050c00)):
        log.init.warning("Combining PyQt {} with Qt {} is unsupported! Ensure "
                         "all versions are newer than 5.12 to avoid potential "
                         "issues.".format(PYQT_VERSION_STR, qt_version())) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:26,代码来源:earlyinit.py

示例4: get_numpy_status

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def get_numpy_status():
    """
    Returns a dictionary containing a boolean specifying whether NumPy
    is up-to-date, along with the version string (empty string if
    not installed).
    """
    numpy_status = {}
    try:
        import numpy
        numpy_version = numpy.__version__
        numpy_status['up_to_date'] = parse_version(
            numpy_version) >= parse_version(NUMPY_MIN_VERSION)
        numpy_status['version'] = numpy_version
    except ImportError:
        traceback.print_exc()
        numpy_status['up_to_date'] = False
        numpy_status['version'] = ""
    return numpy_status 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:20,代码来源:setup.py

示例5: get_cython_status

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def get_cython_status():
    """
    Returns a dictionary containing a boolean specifying whether Cython is
    up-to-date, along with the version string (empty string if not installed).
    """
    cython_status = {}
    try:
        import Cython
        from Cython.Build import cythonize
        cython_version = Cython.__version__
        cython_status['up_to_date'] = parse_version(
            cython_version) >= parse_version(CYTHON_MIN_VERSION)
        cython_status['version'] = cython_version
    except ImportError:
        traceback.print_exc()
        cython_status['up_to_date'] = False
        cython_status['version'] = ""
    return cython_status 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:20,代码来源:setup.py

示例6: test_opencv

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def test_opencv():
    """
    This function is workaround to 
    test if correct OpenCV Library version has already been installed
    on the machine or not. Returns True if previously not installed.
    """
    try:
        # import OpenCV Binaries
        import cv2

        # check whether OpenCV Binaries are 3.x+
        if parse_version(cv2.__version__) < parse_version("3"):
            raise ImportError(
                "Incompatible (< 3.0) OpenCV version-{} Installation found on this machine!".format(
                    parse_version(cv2.__version__)
                )
            )
    except ImportError:
        return True
    return False 
开发者ID:abhiTronix,项目名称:vidgear,代码行数:22,代码来源:setup.py

示例7: filter_exploits_without_comparator

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def filter_exploits_without_comparator(exploit, num_version, software_name, final_result_set):
    """
    Add the exploit (without comparator) to the final_result_set if respect the condition set by the user.
    :param exploit: the exploit we have to check if it has a number of version that matches the value passed by
                    the user.
    :param num_version: the number of version searched by the user.
    :param software_name: the name of the software searched by the user.
    :param final_result_set: the result set that
    :return: the result set that
    """
    if not exploit.description.__contains__('.x'):
        # exclude the exploit from results table if the number of version is not equal and contains 'x'
        try:
            if parse_version(num_version) == parse_version(get_num_version(software_name, exploit.description)):
                final_result_set.append(exploit)
        except TypeError:
            pass
    else:
        # exclude the exploit from results table if the number of version is not equal and not contains 'x'
        try:
            if is_equal_with_x(num_version, get_num_version(software_name, exploit.description)):
                final_result_set.append(exploit)
        except TypeError:
            pass
    return final_result_set 
开发者ID:nicolas-carolo,项目名称:houndsploit,代码行数:27,代码来源:filter_query.py

示例8: filter_exploits_with_comparator_and_without_x

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def filter_exploits_with_comparator_and_without_x(exploit, num_version, software_name, final_result_set):
    """
    Add exploit (with comparator and without the x in number version) to the final_result_set if respect the condition set by the user.
    :param exploit: the exploit we have to check if it has a number of version that matches the value passed by
                    the user.
    :param num_version: the number of version searched by the user.
    :param software_name: the name of the software searched by the user.
    :param final_result_set: the result set that
    :return: the result set that
    """
    if str_contains_num_version_range(str(exploit.description)):
        if is_in_version_range(num_version, software_name, exploit.description):
            final_result_set.append(exploit)
    else:
        try:
            if parse_version(num_version) <= parse_version(
                    get_num_version_with_comparator(software_name, exploit.description)):
                final_result_set.append(exploit)
        except TypeError:
            pass
    return final_result_set 
开发者ID:nicolas-carolo,项目名称:houndsploit,代码行数:23,代码来源:filter_query.py

示例9: filter_shellcodes_without_comparator

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def filter_shellcodes_without_comparator(shellcode, num_version, software_name, final_result_set):
    """
    Add the shellcode (without comparator) to the final_result_set if respect the condition set by the user.
    :param shellcode: the shellcode we have to check if it has a number of version that matches the value passed by
                        the user.
    :param num_version: the number of version searched by the user.
    :param software_name: the name of the software searched by the user.
    :param final_result_set: the result set that
    :return: the result set that
    """
    if not shellcode.description.__contains__('.x'):
        # exclude the exploit from results table if the number of version is not equal and contains 'x'
        try:
            if parse_version(num_version) == parse_version(get_num_version(software_name, shellcode.description)):
                final_result_set.append(shellcode)
        except TypeError:
            pass
    else:
        # exclude the exploit from results table if the number of version is not equal and not contains 'x'
        try:
            if is_equal_with_x(num_version, get_num_version(software_name, shellcode.description)):
                final_result_set.append(shellcode)
        except TypeError:
            pass
    return final_result_set 
开发者ID:nicolas-carolo,项目名称:houndsploit,代码行数:27,代码来源:filter_query.py

示例10: filter_shellcodes_with_comparator_and_without_x

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def filter_shellcodes_with_comparator_and_without_x(shellcode, num_version, software_name, final_result_set):
    """
    Add the shellcode (with comparator and without x) to the final_result_set if respect the condition set by the user.
    :param shellcode: the shellcode we have to check if it has a number of version that matches the value passed by
                        the user.
    :param num_version: the number of version searched by the user.
    :param software_name: the name of the software searched by the user.
    :param final_result_set: the result set that
    :return: the result set that
    """
    if str_contains_num_version_range(str(shellcode.description)):
        if is_in_version_range(num_version, software_name, shellcode.description):
            final_result_set.append(shellcode)
    else:
        try:
            if parse_version(num_version) <= parse_version(
                    get_num_version_with_comparator(software_name, shellcode.description)):
                final_result_set.append(shellcode)
        except TypeError:
            pass
    return final_result_set 
开发者ID:nicolas-carolo,项目名称:houndsploit,代码行数:23,代码来源:filter_query.py

示例11: is_equal_with_x

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def is_equal_with_x(num_version, num_to_compare):
    """
    Check if the number of version searched by the user is equal to the number of version (with x) of the software
    contained in the vulnerability's description.
    :param num_version: the number of version searched by the user.
    :param num_to_compare: the number of version (containing the x) in the vulnerability's description.
    :return: True if the number of version searched by the user is equal to the number of version (with x) of the
                software contained in the vulnerability's description.
    """
    version_precision = str(num_to_compare).count('.')
    try:
        regex = re.search(r'\d+(\.\d+){0,%d}' % version_precision, num_version)
        num_version = regex.group()
    except AttributeError:
        pass
    if parse_version(num_version) == parse_version(num_to_compare):
        return True
    else:
        return False 
开发者ID:nicolas-carolo,项目名称:houndsploit,代码行数:21,代码来源:version_comparator.py

示例12: get_assets

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def get_assets(self):
        """Define the static assets the plugin offers."""
        octoprintVersion = pkg_resources.parse_version(octoprint.__version__)

        jsFiles = ["js/excluderegion.js"]

        # The modified gcode renderer is not needed for 1.3.10rc1 and above
        if (octoprintVersion < pkg_resources.parse_version("1.3.10rc1")):
            self._logger.info(
                "Octoprint {} is pre 1.3.10rc1, including renderer.js to override gcode viewer",
                octoprint.__display_version__
            )
            jsFiles.insert(0, "js/renderer.js")

        return dict(
            js=jsFiles,
            css=["css/excluderegion.css"]
        )

    # ~~ TemplatePlugin 
开发者ID:bradcfisher,项目名称:OctoPrint-ExcludeRegionPlugin,代码行数:22,代码来源:__init__.py

示例13: __init__

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def __init__(self, url, key, client, version='0.10.8', headers={}, ssl_verify=True):
        self.url = url.rstrip('/')
        self.parsed_url = six.moves.urllib.parse.urlparse(self.url)
        if not isinstance(key, Key):
            key = Key(key)
        if not key.key:
            raise ValueError("ChefAPI attribute 'key' was invalid.")
        self.key = key
        self.client = client
        self.version = version
        self.headers = dict((k.lower(), v) for k, v in six.iteritems(headers))
        self.version_parsed = pkg_resources.parse_version(self.version)
        self.platform = self.parsed_url.hostname == 'api.opscode.com'
        self.ssl_verify = ssl_verify
        if not api_stack_value():
            self.set_default() 
开发者ID:awslabs,项目名称:lambda-chef-node-cleanup,代码行数:18,代码来源:api.py

示例14: sbo_upgrade

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def sbo_upgrade(skip, flag):
    """Return packages for upgrade
    """
    msg = Msg()
    black = BlackList()
    msg.checking()
    upgrade_names = []
    data = SBoGrep(name="").names()
    blacklist = list(black.get_black())
    for pkg in sbo_list():
        name = split_package(pkg)[0]
        ver = split_package(pkg)[1]
        if (name in data and name not in skip and name not in blacklist):
            sbo_package = f"{name}-{SBoGrep(name).version()}"
            package = f"{name}-{ver}"
            if parse_version(sbo_package) > parse_version(package):
                upgrade_names.append(name)
    msg.done()
    if "--checklist" in flag:
        upgrade_names = choose_upg(upgrade_names)
    return upgrade_names 
开发者ID:dslackw,项目名称:slpkg,代码行数:23,代码来源:check.py

示例15: _check_update_

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import parse_version [as 别名]
def _check_update_(self):
        """Check if the current version of the library is outdated."""
        try:
            data = requests.get(
                "https://pypi.python.org/pypi/jira/json", timeout=2.001
            ).json()

            released_version = data["info"]["version"]
            if parse_version(released_version) > parse_version(__version__):
                warnings.warn(
                    "You are running an outdated version of Jira Python %s. Current version is %s. Do not file any bugs against older versions."
                    % (__version__, released_version)
                )
        except requests.RequestException:
            pass
        except Exception as e:
            logging.warning(e) 
开发者ID:pycontribs,项目名称:jira,代码行数:19,代码来源:client.py


注:本文中的pkg_resources.parse_version方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。