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


Python platform.dist方法代码示例

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


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

示例1: parseDefaults

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def parseDefaults(disable, defaultsGetter, log):
  defaultsMeta, defaultsBody = defaultsGetter()
  # Defaults are actually special packages. They can override metadata
  # of any other package and they can disable other packages. For
  # example they could decide to switch from ROOT 5 to ROOT 6 and they
  # could disable alien for O2. For this reason we need to parse their
  # metadata early and extract the override and disable data.
  defaultsDisable = asList(defaultsMeta.get("disable", []))
  for x in defaultsDisable:
    log("Package %s has been disabled by current default." % x)
  disable.extend(defaultsDisable)
  if type(defaultsMeta.get("overrides", OrderedDict())) != OrderedDict:
    return ("overrides should be a dictionary", None, None)
  overrides, taps = OrderedDict(), {}
  commonEnv = {"env": defaultsMeta["env"]} if "env" in defaultsMeta else {}
  overrides["defaults-release"] = commonEnv
  for k, v in defaultsMeta.get("overrides", {}).items():
    f = k.split("@", 1)[0].lower()
    if "@" in k:
      taps[f] = "dist:"+k
    overrides[f] = dict(**(v or {}))
  return (None, overrides, taps) 
开发者ID:alisw,项目名称:alibuild,代码行数:24,代码来源:utilities.py

示例2: test_linux_distribution_encoding

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def test_linux_distribution_encoding(self):
        # Issue #17429
        with tempfile.TemporaryDirectory() as tempdir:
            filename = os.path.join(tempdir, 'fedora-release')
            with open(filename, 'w', encoding='utf-8') as f:
                f.write('Fedora release 19 (Schr\xf6dinger\u2019s Cat)\n')

            with mock.patch('platform._UNIXCONFDIR', tempdir):
                with warnings.catch_warnings():
                    warnings.filterwarnings(
                        'ignore',
                        'dist\(\) and linux_distribution\(\) '
                        'functions are deprecated .*',
                        PendingDeprecationWarning,
                    )
                    distname, version, distid = platform.linux_distribution()

                self.assertEqual(distname, 'Fedora')
            self.assertEqual(version, '19')
            self.assertEqual(distid, 'Schr\xf6dinger\u2019s Cat') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:test_platform.py

示例3: checkproc

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def checkproc(self):
        dist, ver, name = platform.dist()
        if dist == "Ubuntu":
            self.proc = 'docker.io -d'
        else:
            self.proc = 'docker -d'
        try:
            s = subprocess.Popen(["ps", "aux"], stdout=subprocess.PIPE)
            for prs in s.stdout:
                if re.search(self.proc, prs):
                    logger.info(
                        "Requested process: %s is running" % (self.proc))
                    return True
        except Exception as e:
            logger.debug(e)
            return False 
开发者ID:humblec,项目名称:dockit,代码行数:18,代码来源:install.py

示例4: find_package_manager

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def find_package_manager(operation):
    """
    Checks if the dist is debian based or centos based and assigns the package manager accordingly
    """
    global PackageManager
    global BundleFileName
    dist, ver = find_vm_distro(operation)

    dpkg_set = {"debian", "ubuntu"}
    rpm_set = {"oracle", "redhat", "centos", "red hat", "suse"}
    for dpkg_dist in dpkg_set:
        if dist.lower().startswith(dpkg_dist):
            PackageManager = "dpkg"
            BundleFileName = BundleFileNameDeb
            break

    for rpm_dist in rpm_set:
        if dist.lower().startswith(rpm_dist):
            PackageManager = "rpm"
            BundleFileName = BundleFileNameRpm
            break

    if PackageManager == "":
        log_and_exit(operation, UnsupportedOperatingSystem, "The OS has neither rpm nor dpkg" ) 
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:26,代码来源:agent.py

示例5: find_vm_distro

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def find_vm_distro(operation):
    """
    Finds the Linux Distribution this vm is running on. 
    """
    vm_dist = vm_id = vm_ver =  None
    try:
        vm_dist, vm_ver, vm_id = platform.linux_distribution()
    except AttributeError:
        vm_dist, vm_ver, vm_id = platform.dist()

    if not vm_dist and not vm_ver: # SLES 15 and others
        try:
            with open('/etc/os-release', 'r') as fp:
                for line in fp:
                    if line.startswith('ID='):
                        vm_dist = line.split('=')[1]
                        vm_dist = vm_dist.split('-')[0]
                        vm_dist = vm_dist.replace('\"', '').replace('\n', '')
                    elif line.startswith('VERSION_ID='):
                        vm_ver = line.split('=')[1]
                        vm_ver = vm_ver.split('.')[0]
                        vm_ver = vm_ver.replace('\"', '').replace('\n', '')
        except:
            log_and_exit(operation, UndeterminateOperatingSystem, 'Undeterminate operating system')
    return vm_dist, vm_ver 
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:27,代码来源:agent.py

示例6: DistInfo

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def DistInfo():
    if 'FreeBSD' in platform.system():
        release = re.sub('\-.*\Z', '', str(platform.release()))
        distinfo = ['FreeBSD', release]
        return distinfo
    if os.path.isfile('/etc/oracle-release'):
        release = re.sub('\-.*\Z', '', str(platform.release()))
        distinfo = ['Oracle', release]
        return distinfo
    if 'linux_distribution' in dir(platform):
        distinfo = list(platform.linux_distribution(full_distribution_name=0))
        # remove trailing whitespace in distro name
        distinfo[0] = distinfo[0].strip()
        return distinfo
    else:
        return platform.dist() 
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:18,代码来源:__init__.py

示例7: DistInfo

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def DistInfo(fullname=0):
    if 'FreeBSD' in platform.system():
        release = re.sub('\-.*\Z', '', str(platform.release()))
        distinfo = ['FreeBSD', release]
        return distinfo
    if os.path.isfile('/etc/oracle-release'):
        release = re.sub('\-.*\Z', '', str(platform.release()))
        distinfo = ['Oracle', release]
        return distinfo
    if 'linux_distribution' in dir(platform):
        distinfo = list(platform.linux_distribution(\
                        full_distribution_name=fullname))
        # remove trailing whitespace in distro name
        distinfo[0] = distinfo[0].strip()
        return distinfo
    else:
        return platform.dist() 
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:19,代码来源:__init__.py

示例8: getRecipeReader

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def getRecipeReader(url, dist=None):
  m = re.search(r'^dist:(.*)@([^@]+)$', url)
  if m and dist:
    return GitReader(url, dist)
  else:
    return FileReader(url)

# Read a recipe from a file 
开发者ID:alisw,项目名称:alibuild,代码行数:10,代码来源:utilities.py

示例9: __call__

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def __call__(self):
    m = re.search(r'^dist:(.*)@([^@]+)$', self.url)
    fn,gh = m.groups()
    err,d = getstatusoutput(format("GIT_DIR=%(dist)s/.git git show %(gh)s:%(fn)s.sh",
                                   dist=self.configDir, gh=gh, fn=fn.lower()))
    if err:
      raise RuntimeError(format("Cannot read recipe %(fn)s from reference %(gh)s.\n" +
                                "Make sure you run first (this will not alter your recipes):\n" +
                                "  cd %(dist)s && git remote update -p && git fetch --tags",
                                dist=self.configDir, gh=gh, fn=fn))
    return d 
开发者ID:alisw,项目名称:alibuild,代码行数:13,代码来源:utilities.py

示例10: get_os

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def get_os():
    if platform.system() == 'Windows':
        uname = platform.uname()
        return '%s %s %s' % (uname[0], uname[2], uname[4])
    else:
        uname = platform.dist()
        return '%s %s %s %s' % (uname[0], uname[1], uname[2], platform.machine()) 
开发者ID:BennyThink,项目名称:ServerSan,代码行数:9,代码来源:ss-agent.py

示例11: run

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def run(self):
        if not self.distribution.dist_files:
            raise DistutilsOptionError("No dist file created in earlier command")
        for command, pyversion, filename in self.distribution.dist_files:
            self.upload_file(command, pyversion, filename) 
开发者ID:glmcdona,项目名称:meddle,代码行数:7,代码来源:upload.py

示例12: test_dist

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def test_dist(self):
        res = platform.dist() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_platform.py

示例13: get_sysinfo

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def get_sysinfo():
    info = {}
    
    #basic
    info["architecture"] = platform.architecture()[0]
    info["machine"] = platform.machine()
    info["node"] = platform.node()
    info["system"] = platform.system()
    
    #distro
    dist = platform.dist()
    info["dist"] = " ".join(x for x in dist)
    
    #cpuinfo
    with open("/proc/cpuinfo", "r") as f:
        cpuInfo = f.readlines()
    info["cpuinfo"] = [x.strip().split(":")[1] for x in cpuInfo if "model name" in x]

    #memory
    with open("/proc/meminfo", "r") as f:
        memInfo = f.readlines()
    info["memTotal"] = memInfo[0].strip()\
        .replace("MemTotal:        ", "").replace(" kB", "")
    info["memFree"] = memInfo[1].strip()\
        .replace("MemFree:          ", "").replace(" kB", "")

    #uptime
    with open("/proc/uptime") as f:
        uptime = f.read().split(" ")[0].strip()
    uptime = int(float(uptime))
    info["uptime"] = str(uptime)

    return info 
开发者ID:dawiddydlinski,项目名称:web-rpi-fm,代码行数:35,代码来源:funcs.py

示例14: about

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def about(application, appname=None, appversion=None):
    data = []
    if appname is not None:
        data.append("{}{}".format(appname,
            (" " + appversion) if appversion is not None else ""))
    python = platform.python_implementation()
    if python == "CPython":
        python = python[1:]
    data.append("{0} {1.major}.{1.minor}.{1.micro}".format(python,
            sys.version_info))
    data.append("Tk {}".format(application.tk.getvar(
            "tk_patchLevel")))
    system = platform.system()
    if system == "Linux":
        distro, version = platform.dist()[:2]
        if distro:
            system = "{}/{}".format(system, distro)
            if version:
                system += " " + version
    elif system == "Windows":
        version, service_pack = platform.win32_ver()[:2]
        if version:
            system = "{} {}".format(system, version)
            if service_pack:
                system += " (SP {})".format(service_pack)
    elif system == "Mac":
        version, info = platform.mac_ver()
        if version:
            system = "{} {}".format(system, version)
            if info:
                system += "." + info[0]
    return " • ".join(data) + "\n" + system + " • " + platform.machine()


# No shortcuts on Mac OS X 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:37,代码来源:__init__.py

示例15: create_package_from_setup_py

# 需要导入模块: import platform [as 别名]
# 或者: from platform import dist [as 别名]
def create_package_from_setup_py(self, path_to_setup_py, custom_package_name):
        """
        Creates a package from Setup.py specified in the the given path
        :param path_to_setup_py:
        :return: Package Information: Contains package name, version and path
        """
        if os.path.isfile(path_to_setup_py):
            path_to_setup_py = os.path.abspath(path_to_setup_py)
            setup_py_directory = os.path.dirname(path_to_setup_py)
        elif os.path.isdir(path_to_setup_py):
            setup_py_directory = os.path.abspath(path_to_setup_py)
            path_to_setup_py = setup_py_directory + '/setup.py'
        else:
            raise Exception("Given path/file: " + path_to_setup_py + " doesn't exist")

        if not os.path.exists(path_to_setup_py):
            raise Exception("setup.py doesn't exist in the given path: " + path_to_setup_py)

        sandbox.run_setup(path_to_setup_py, ['sdist'])
        eggs = find_distributions(setup_py_directory)

        version = None
        for egg in eggs:
            if custom_package_name in egg.egg_name():
                version = egg.version

        if not version:
            raise Exception("{package_name} not found".format(package_name=custom_package_name))

        package_info = dict()
        package_info['path'] = setup_py_directory + "/dist/" + custom_package_name + "-" + version + ".tar.gz"
        package_info['version'] = version
        package_info['name'] = custom_package_name
        return package_info 
开发者ID:flipkart-incubator,项目名称:Hunch,代码行数:36,代码来源:hunch_publisher.py


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