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


Python platform.py方法代码示例

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


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

示例1: compatible_tags

# 需要导入模块: import platform [as 别名]
# 或者: from platform import py [as 别名]
def compatible_tags(
    python_version=None,  # type: Optional[PythonVersion]
    interpreter=None,  # type: Optional[str]
    platforms=None,  # type: Optional[Iterable[str]]
):
    # type: (...) -> Iterator[Tag]
    """
    Yields the sequence of tags that are compatible with a specific version of Python.

    The tags consist of:
    - py*-none-<platform>
    - <interpreter>-none-any  # ... if `interpreter` is provided.
    - py*-none-any
    """
    if not python_version:
        python_version = sys.version_info[:2]
    platforms = list(platforms or _platform_tags())
    for version in _py_interpreter_range(python_version):
        for platform_ in platforms:
            yield Tag(version, "none", platform_)
    if interpreter:
        yield Tag(interpreter, "none", "any")
    for version in _py_interpreter_range(python_version):
        yield Tag(version, "none", "any") 
开发者ID:pypa,项目名称:pipenv,代码行数:26,代码来源:tags.py

示例2: _glibc_version_string_confstr

# 需要导入模块: import platform [as 别名]
# 或者: from platform import py [as 别名]
def _glibc_version_string_confstr():
    # type: () -> Optional[str]
    """
    Primary implementation of glibc_version_string using os.confstr.
    """
    # os.confstr is quite a bit faster than ctypes.DLL. It's also less likely
    # to be broken or missing. This strategy is used in the standard library
    # platform module.
    # https://github.com/python/cpython/blob/fcf1d003bf4f0100c9d0921ff3d70e1127ca1b71/Lib/platform.py#L175-L183
    try:
        # os.confstr("CS_GNU_LIBC_VERSION") returns a string like "glibc 2.17".
        version_string = os.confstr(  # type: ignore[attr-defined] # noqa: F821
            "CS_GNU_LIBC_VERSION"
        )
        assert version_string is not None
        _, version = version_string.split()  # type: Tuple[str, str]
    except (AssertionError, AttributeError, OSError, ValueError):
        # os.confstr() or CS_GNU_LIBC_VERSION not available (or a bad value)...
        return None
    return version 
开发者ID:pypa,项目名称:pipenv,代码行数:22,代码来源:tags.py

示例3: compatible_tags

# 需要导入模块: import platform [as 别名]
# 或者: from platform import py [as 别名]
def compatible_tags(
    python_version=None,  # type: Optional[PythonVersion]
    interpreter=None,  # type: Optional[str]
    platforms=None,  # type: Optional[Iterator[str]]
):
    # type: (...) -> Iterator[Tag]
    """
    Yields the sequence of tags that are compatible with a specific version of Python.

    The tags consist of:
    - py*-none-<platform>
    - <interpreter>-none-any  # ... if `interpreter` is provided.
    - py*-none-any
    """
    if not python_version:
        python_version = sys.version_info[:2]
    if not platforms:
        platforms = _platform_tags()
    for version in _py_interpreter_range(python_version):
        for platform_ in platforms:
            yield Tag(version, "none", platform_)
    if interpreter:
        yield Tag(interpreter, "none", "any")
    for version in _py_interpreter_range(python_version):
        yield Tag(version, "none", "any") 
开发者ID:glutanimate,项目名称:review-heatmap,代码行数:27,代码来源:tags.py

示例4: _py_interpreter_range

# 需要导入模块: import platform [as 别名]
# 或者: from platform import py [as 别名]
def _py_interpreter_range(py_version):
    # type: (PythonVersion) -> Iterator[str]
    """
    Yields Python versions in descending order.

    After the latest version, the major-only version will be yielded, and then
    all previous versions of that major version.
    """
    if len(py_version) > 1:
        yield "py{major}{minor}".format(major=py_version[0], minor=py_version[1])
    yield "py{major}".format(major=py_version[0])
    if len(py_version) > 1:
        for minor in range(py_version[1] - 1, -1, -1):
            yield "py{major}{minor}".format(major=py_version[0], minor=minor) 
开发者ID:pypa,项目名称:pipenv,代码行数:16,代码来源:tags.py

示例5: _py_interpreter_range

# 需要导入模块: import platform [as 别名]
# 或者: from platform import py [as 别名]
def _py_interpreter_range(py_version):
    # type: (PythonVersion) -> Iterator[str]
    """
    Yields Python versions in descending order.

    After the latest version, the major-only version will be yielded, and then
    all previous versions of that major version.
    """
    if len(py_version) > 1:
        yield "py{version}".format(version=_version_nodot(py_version[:2]))
    yield "py{major}".format(major=py_version[0])
    if len(py_version) > 1:
        for minor in range(py_version[1] - 1, -1, -1):
            yield "py{version}".format(version=_version_nodot((py_version[0], minor))) 
开发者ID:pypa,项目名称:pipenv,代码行数:16,代码来源:tags.py

示例6: test_getdefaultencoding

# 需要导入模块: import platform [as 别名]
# 或者: from platform import py [as 别名]
def test_getdefaultencoding(self):
        self.assertRaises(TypeError, sys.getdefaultencoding, 42)
        # can't check more than the type, as the user might have changed it
        self.assertIsInstance(sys.getdefaultencoding(), str)

    # testing sys.settrace() is done in test_sys_settrace.py
    # testing sys.setprofile() is done in test_sys_setprofile.py 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test_sys.py

示例7: test_getwindowsversion

# 需要导入模块: import platform [as 别名]
# 或者: from platform import py [as 别名]
def test_getwindowsversion(self):
        # Raise SkipTest if sys doesn't have getwindowsversion attribute
        test.support.get_attribute(sys, "getwindowsversion")
        v = sys.getwindowsversion()
        self.assertEqual(len(v), 5)
        self.assertIsInstance(v[0], int)
        self.assertIsInstance(v[1], int)
        self.assertIsInstance(v[2], int)
        self.assertIsInstance(v[3], int)
        self.assertIsInstance(v[4], str)
        self.assertRaises(IndexError, operator.getitem, v, 5)
        self.assertIsInstance(v.major, int)
        self.assertIsInstance(v.minor, int)
        self.assertIsInstance(v.build, int)
        self.assertIsInstance(v.platform, int)
        self.assertIsInstance(v.service_pack, str)
        self.assertIsInstance(v.service_pack_minor, int)
        self.assertIsInstance(v.service_pack_major, int)
        self.assertIsInstance(v.suite_mask, int)
        self.assertIsInstance(v.product_type, int)
        self.assertEqual(v[0], v.major)
        self.assertEqual(v[1], v.minor)
        self.assertEqual(v[2], v.build)
        self.assertEqual(v[3], v.platform)
        self.assertEqual(v[4], v.service_pack)

        # This is how platform.py calls it. Make sure tuple
        #  still has 5 elements
        maj, min, buildno, plat, csd = sys.getwindowsversion() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:31,代码来源:test_sys.py

示例8: get_os_version_names

# 需要导入模块: import platform [as 别名]
# 或者: from platform import py [as 别名]
def get_os_version_names():
  """Returns the marketing/user-friendly names of the OS.

  The return value contains the base marketing name, e.g. Vista, 10, or
  2008Server. For Windows Server starting with 2016, this value is always
  "Server".

  For versions released before Windows 10, the return value also contains the
  name with the service pack, e.g. 7-SP1 or 2012ServerR2-SP0.

  For Windows 10 and Windows Server starting with 2016, the return value
  includes "10-" or "Server-" followed by one or more parts of the build number.
  E.g. for Windows 10 with build number 18362.207, the return value includes
  10-18362, 10-18362.207. For Windows Server 2019 with build number 17763.557,
  the return value includes Server-17763, Server-17763.557.
  """
  # Python keeps a local map in platform.py and it is updated at newer python
  # release. Since our python release is a bit old, do not rely on it.
  is_server = sys.getwindowsversion().product_type != 1
  lookup = _WIN32_SERVER_NAMES if is_server else _WIN32_CLIENT_NAMES
  version_number, build_number = _get_os_numbers()
  marketing_name = lookup.get(version_number, version_number)
  if version_number == u'10.0':
    rv = [marketing_name]
    # Windows 10 doesn't have service packs, the build number now is the
    # reference number. More discussion in
    # https://docs.google.com/document/d/1iF1tbc1oedCQ9J6aL7sHeuaayY3bs52fuvKxvLLZ0ig
    if '.' in build_number:
      major_version = build_number.split(u'.')[0]
      rv.append(u'%s-%s' % (marketing_name, major_version))
    rv.append(u'%s-%s' % (marketing_name, build_number))
    rv.sort()
    return rv
  service_pack = platform.win32_ver()[2] or u'SP0'
  return [marketing_name, u'%s-%s' % (marketing_name, service_pack)] 
开发者ID:luci,项目名称:luci-py,代码行数:37,代码来源:win.py


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