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


Python Platform.is_win32方法代码示例

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


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

示例1: get_system_stats

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
def get_system_stats():
    systemStats = {
        'machine': platform.machine(),
        'platform': sys.platform,
        'processor': platform.processor(),
        'pythonV': platform.python_version(),
    }

    platf = sys.platform

    if Platform.is_linux(platf):
        grep = subprocess.Popen(['grep', 'model name', '/proc/cpuinfo'], stdout=subprocess.PIPE, close_fds=True)
        wc = subprocess.Popen(['wc', '-l'], stdin=grep.stdout, stdout=subprocess.PIPE, close_fds=True)
        systemStats['cpuCores'] = int(wc.communicate()[0])

    if Platform.is_darwin(platf):
        systemStats['cpuCores'] = int(subprocess.Popen(['sysctl', 'hw.ncpu'], stdout=subprocess.PIPE, close_fds=True).communicate()[0].split(': ')[1])

    if Platform.is_freebsd(platf):
        systemStats['cpuCores'] = int(subprocess.Popen(['sysctl', 'hw.ncpu'], stdout=subprocess.PIPE, close_fds=True).communicate()[0].split(': ')[1])

    if Platform.is_linux(platf):
        systemStats['nixV'] = platform.dist()

    elif Platform.is_darwin(platf):
        systemStats['macV'] = platform.mac_ver()

    elif Platform.is_freebsd(platf):
        version = platform.uname()[2]
        systemStats['fbsdV'] = ('freebsd', version, '')  # no codename for FreeBSD

    elif Platform.is_win32(platf):
        systemStats['winV'] = platform.win32_ver()

    return systemStats
开发者ID:Shopify,项目名称:dd-agent,代码行数:37,代码来源:config.py

示例2: get_system_stats

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
def get_system_stats():
    systemStats = {
        'machine': platform.machine(),
        'platform': sys.platform,
        'processor': platform.processor(),
        'pythonV': platform.python_version(),
    }

    platf = sys.platform

    try:
        if Platform.is_linux(platf):
            output, _, _ = get_subprocess_output(['grep', 'model name', '/proc/cpuinfo'], log)
            systemStats['cpuCores'] = len(output.splitlines())

        if Platform.is_darwin(platf) or Platform.is_freebsd(platf):
            output, _, _ = get_subprocess_output(['sysctl', 'hw.ncpu'], log)
            systemStats['cpuCores'] = int(output.split(': ')[1])
    except SubprocessOutputEmptyError as e:
        log.warning("unable to retrieve number of cpuCores. Failed with error %s", e)

    if Platform.is_linux(platf):
        systemStats['nixV'] = platform.dist()

    elif Platform.is_darwin(platf):
        systemStats['macV'] = platform.mac_ver()

    elif Platform.is_freebsd(platf):
        version = platform.uname()[2]
        systemStats['fbsdV'] = ('freebsd', version, '')  # no codename for FreeBSD

    elif Platform.is_win32(platf):
        systemStats['winV'] = platform.win32_ver()

    return systemStats
开发者ID:bsandvik,项目名称:dd-agent,代码行数:37,代码来源:config.py

示例3: _get_pickle_path

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
 def _get_pickle_path(cls):
     if Platform.is_win32():
         path = os.path.join(_windows_commondata_path(), 'Datadog')
     elif os.path.isdir(PidFile.get_dir()):
         path = PidFile.get_dir()
     else:
         path = tempfile.gettempdir()
     return os.path.join(path, cls.__name__ + '.pickle')
开发者ID:7040210,项目名称:dd-agent,代码行数:10,代码来源:check_status.py

示例4: _get_dir

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
 def _get_dir(cls):
     if Platform.is_win32():
         path = os.path.join(_windows_commondata_path(), 'Datadog')
     elif os.path.isdir(PidFile.get_dir()):
         path = PidFile.get_dir()
     else:
         path = tempfile.gettempdir()
     return path
开发者ID:darron,项目名称:dd-agent,代码行数:10,代码来源:jmx.py

示例5: _exclude_disk_psutil

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
 def _exclude_disk_psutil(self, part):
     # skip cd-rom drives with no disk in it; they may raise
     # ENOENT, pop-up a Windows GUI error for a non-ready
     # partition or just hang;
     # and all the other excluded disks
     return ((Platform.is_win32() and ('cdrom' in part.opts or
                                       part.fstype == '')) or
             self._exclude_disk(part.device, part.fstype, part.mountpoint))
开发者ID:htgeis,项目名称:mystore,代码行数:10,代码来源:unix.py

示例6: windows_friendly_colon_split

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
def windows_friendly_colon_split(config_string):
    '''
    Perform a split by ':' on the config_string
    without splitting on the start of windows path
    '''
    if Platform.is_win32():
        # will split on path/to/module.py:blabla but not on C:\\path
        return COLON_NON_WIN_PATH.split(config_string)
    else:
        return config_string.split(':')
开发者ID:jalaziz,项目名称:dd-agent,代码行数:12,代码来源:util.py

示例7: _get_dir

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
 def _get_dir(cls):
     if Platform.is_win32():
         path = os.path.join(_windows_commondata_path(), 'Server Density')
         if not os.path.isdir(path):
             path = tempfile.gettempdir()
     elif os.path.isdir(PidFile.get_dir()):
         path = PidFile.get_dir()
     else:
         path = tempfile.gettempdir()
     return path
开发者ID:serverdensity,项目名称:sd-agent,代码行数:12,代码来源:jmx.py

示例8: psutil_wrapper

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
    def psutil_wrapper(self, process, method, accessors, *args, **kwargs):
        """
        A psutil wrapper that is calling
        * psutil.method(*args, **kwargs) and returns the result
        OR
        * psutil.method(*args, **kwargs).accessor[i] for each accessors given in
        a list, the result being indexed in a dictionary by the accessor name
        """

        if accessors is None:
            result = None
        else:
            result = {}

        # Ban certain method that we know fail
        if method == 'memory_info_ex'\
                and (Platform.is_win32() or Platform.is_solaris()):
            return result
        elif method == 'num_fds' and not Platform.is_unix():
            return result
        elif method == 'num_handles' and not Platform.is_win32():
            return result

        try:
            res = getattr(process, method)(*args, **kwargs)
            if accessors is None:
                result = res
            else:
                for acc in accessors:
                    try:
                        result[acc] = getattr(res, acc)
                    except AttributeError:
                        self.log.debug("psutil.%s().%s attribute does not exist", method, acc)
        except (NotImplementedError, AttributeError):
            self.log.debug("psutil method %s not implemented", method)
        except psutil.AccessDenied:
            self.log.debug("psutil was denied acccess for method %s", method)
        ## we don't want this warning output
        # except psutil.NoSuchProcess:
            # self.warning("Process {0} disappeared while scanning".format(process.pid))

        return result
开发者ID:tomazstrukeljdlabs,项目名称:ansible-datadog,代码行数:44,代码来源:process.py

示例9: collect_metrics_psutil

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
    def collect_metrics_psutil(self):
        self._valid_disks = {}
        for part in psutil.disk_partitions(all=True):
            # we check all exclude conditions
            if self._exclude_disk_psutil(part):
                continue

            # Get disk metrics here to be able to exclude on total usage
            try:
                disk_usage = timeout(5)(psutil.disk_usage)(part.mountpoint)
            except TimeoutException:
                self.log.warn(
                    u"Timeout while retrieving the disk usage of `%s` mountpoint. Skipping...",
                    part.mountpoint
                )
                continue
            except Exception as e:
                self.log.warn("Unable to get disk metrics for %s: %s", part.mountpoint, e)
                continue
            # Exclude disks with total disk size 0
            if disk_usage.total == 0:
                continue
            # For later, latency metrics
            self._valid_disks[part.device] = (part.fstype, part.mountpoint)
            self.log.debug('Passed: {0}'.format(part.device))

            tags = [part.fstype] if self._tag_by_filesystem else []
            device_name = part.mountpoint if self._use_mount else part.device

            # Note: psutil (0.3.0 to at least 3.1.1) calculates in_use as (used / total)
            #       The problem here is that total includes reserved space the user
            #       doesn't have access to. This causes psutil to calculate a misleadng
            #       percentage for in_use; a lower percentage than df shows.

            # Calculate in_use w/o reserved space; consistent w/ df's Use% metric.
            pmets = self._collect_part_metrics(part, disk_usage)
            used = 'system.disk.used'
            free = 'system.disk.free'
            pmets['system.disk.in_use'] = float(pmets[used]) / (pmets[used] + pmets[free])

            # legacy check names c: vs psutil name C:\\
            if Platform.is_win32():
                device_name = device_name.strip('\\').lower()
            for metric_name, metric_value in pmets.iteritems():
                self.gauge(metric_name, metric_value,
                           tags=tags, device_name=device_name)
开发者ID:htgeis,项目名称:mystore,代码行数:48,代码来源:unix.py

示例10: get_system_stats

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
def get_system_stats():
    systemStats = {
        "machine": platform.machine(),
        "platform": sys.platform,
        "processor": platform.processor(),
        "pythonV": platform.python_version(),
    }

    platf = sys.platform

    if Platform.is_linux(platf):
        grep = subprocess.Popen(["grep", "model name", "/proc/cpuinfo"], stdout=subprocess.PIPE, close_fds=True)
        wc = subprocess.Popen(["wc", "-l"], stdin=grep.stdout, stdout=subprocess.PIPE, close_fds=True)
        systemStats["cpuCores"] = int(wc.communicate()[0])

    if Platform.is_darwin(platf):
        systemStats["cpuCores"] = int(
            subprocess.Popen(["sysctl", "hw.ncpu"], stdout=subprocess.PIPE, close_fds=True)
            .communicate()[0]
            .split(": ")[1]
        )

    if Platform.is_freebsd(platf):
        systemStats["cpuCores"] = int(
            subprocess.Popen(["sysctl", "hw.ncpu"], stdout=subprocess.PIPE, close_fds=True)
            .communicate()[0]
            .split(": ")[1]
        )

    if Platform.is_linux(platf):
        systemStats["nixV"] = platform.dist()

    elif Platform.is_darwin(platf):
        systemStats["macV"] = platform.mac_ver()

    elif Platform.is_freebsd(platf):
        version = platform.uname()[2]
        systemStats["fbsdV"] = ("freebsd", version, "")  # no codename for FreeBSD

    elif Platform.is_win32(platf):
        systemStats["winV"] = platform.win32_ver()

    return systemStats
开发者ID:relateiq,项目名称:dd-agent,代码行数:45,代码来源:config.py

示例11: get_system_stats

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
def get_system_stats():
    systemStats = {
        'machine': platform.machine(),
        'platform': sys.platform,
        'processor': platform.processor(),
        'pythonV': platform.python_version(),
    }

    platf = sys.platform

    if Platform.is_linux(platf):
        output, _, _ = get_subprocess_output(['grep', 'model name', '/proc/cpuinfo'], log)
        systemStats['cpuCores'] = len(output.splitlines())

    if Platform.is_darwin(platf):
        output, _, _ = get_subprocess_output(['sysctl', 'hw.ncpu'], log)
        systemStats['cpuCores'] = int(output.split(': ')[1])

    if Platform.is_freebsd(platf):
        output, _, _ = get_subprocess_output(['sysctl', 'hw.ncpu'], log)
        systemStats['cpuCores'] = int(output.split(': ')[1])

    if Platform.is_linux(platf):
        systemStats['nixV'] = platform.dist()

    elif Platform.is_darwin(platf):
        systemStats['macV'] = platform.mac_ver()

    elif Platform.is_freebsd(platf):
        version = platform.uname()[2]
        systemStats['fbsdV'] = ('freebsd', version, '')  # no codename for FreeBSD

    elif Platform.is_win32(platf):
        systemStats['winV'] = platform.win32_ver()

    return systemStats
开发者ID:jszwedko,项目名称:dd-agent,代码行数:38,代码来源:config.py

示例12: get_system_stats

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
def get_system_stats():
    systemStats = {
        "machine": platform.machine(),
        "platform": sys.platform,
        "processor": platform.processor(),
        "pythonV": platform.python_version(),
    }

    platf = sys.platform

    if Platform.is_linux(platf):
        output, _, _ = get_subprocess_output(["grep", "model name", "/proc/cpuinfo"], log)
        systemStats["cpuCores"] = len(output.splitlines())

    if Platform.is_darwin(platf):
        output, _, _ = get_subprocess_output(["sysctl", "hw.ncpu"], log)
        systemStats["cpuCores"] = int(output.split(": ")[1])

    if Platform.is_freebsd(platf):
        output, _, _ = get_subprocess_output(["sysctl", "hw.ncpu"], log)
        systemStats["cpuCores"] = int(output.split(": ")[1])

    if Platform.is_linux(platf):
        systemStats["nixV"] = platform.dist()

    elif Platform.is_darwin(platf):
        systemStats["macV"] = platform.mac_ver()

    elif Platform.is_freebsd(platf):
        version = platform.uname()[2]
        systemStats["fbsdV"] = ("freebsd", version, "")  # no codename for FreeBSD

    elif Platform.is_win32(platf):
        systemStats["winV"] = platform.win32_ver()

    return systemStats
开发者ID:dadicool,项目名称:dd-agent,代码行数:38,代码来源:config.py

示例13: get_jmx_status_path

# 需要导入模块: from utils.platform import Platform [as 别名]
# 或者: from utils.platform.Platform import is_win32 [as 别名]
def get_jmx_status_path():
    if Platform.is_win32():
        path = os.path.join(_windows_commondata_path(), 'Datadog')
    else:
        path = tempfile.gettempdir()
    return path
开发者ID:ip2k,项目名称:dd-agent,代码行数:8,代码来源:config.py


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