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


Python Platform.is_windows方法代码示例

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


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

示例1: _save_logs_path

# 需要导入模块: from util import Platform [as 别名]
# 或者: from util.Platform import is_windows [as 别名]
 def _save_logs_path(self):
     prefix = ''
     if Platform.is_windows():
         prefix = 'windows_'
     config = get_logging_config()
     self._collector_log = config.get('{0}collector_log_file'.format(prefix))
     self._forwarder_log = config.get('{0}forwarder_log_file'.format(prefix))
     self._dogstatsd_log = config.get('{0}dogstatsd_log_file'.format(prefix))
     self._jmxfetch_log = config.get('jmxfetch_log_file')
开发者ID:AquaBindi,项目名称:dd-agent,代码行数:11,代码来源:flare.py

示例2: _save_logs_path

# 需要导入模块: from util import Platform [as 别名]
# 或者: from util.Platform import is_windows [as 别名]
 def _save_logs_path(self):
     prefix = ""
     if Platform.is_windows():
         prefix = "windows_"
     config = get_logging_config()
     self._collector_log = config.get("{0}collector_log_file".format(prefix))
     self._forwarder_log = config.get("{0}forwarder_log_file".format(prefix))
     self._dogstatsd_log = config.get("{0}dogstatsd_log_file".format(prefix))
     self._jmxfetch_log = config.get("jmxfetch_log_file")
开发者ID:miketheman,项目名称:dd-agent,代码行数:11,代码来源:flare.py

示例3: _supervisor_status

# 需要导入模块: from util import Platform [as 别名]
# 或者: from util.Platform import is_windows [as 别名]
 def _supervisor_status(self):
     if Platform.is_windows():
         print "Windows - status not implemented"
     else:
         agent_exec = self._get_path_agent_exec()
         print "{0} status".format(agent_exec)
         self._print_output_command([agent_exec, "status"])
         supervisor_exec = self._get_path_supervisor_exec()
         print "{0} status".format(supervisor_exec)
         self._print_output_command([supervisor_exec, "-c", self._get_path_supervisor_conf(), "status"])
开发者ID:miketheman,项目名称:dd-agent,代码行数:12,代码来源:flare.py

示例4: _supervisor_status

# 需要导入模块: from util import Platform [as 别名]
# 或者: from util.Platform import is_windows [as 别名]
 def _supervisor_status(self):
     if Platform.is_windows():
         print 'Windows - status not implemented'
     else:
         agent_exec = self._get_path_agent_exec()
         print '{0} status'.format(agent_exec)
         self._print_output_command([agent_exec, 'status'])
         supervisor_exec = self._get_path_supervisor_exec()
         print '{0} status'.format(supervisor_exec)
         self._print_output_command([supervisor_exec,
                                     '-c', self._get_path_supervisor_conf(),
                                     'status'])
开发者ID:AquaBindi,项目名称:dd-agent,代码行数:14,代码来源:flare.py

示例5: _add_conf_tar

# 需要导入模块: from util import Platform [as 别名]
# 或者: from util.Platform import is_windows [as 别名]
    def _add_conf_tar(self):
        conf_path = get_config_path()
        log.info("  * {0}".format(conf_path))
        self._tar.add(self._strip_comment(conf_path), os.path.join(self._prefix, "etc", "datadog.conf"))

        if not Platform.is_windows():
            supervisor_path = os.path.join(os.path.dirname(get_config_path()), "supervisor.conf")
            log.info("  * {0}".format(supervisor_path))
            self._tar.add(self._strip_comment(supervisor_path), os.path.join(self._prefix, "etc", "supervisor.conf"))

        for file_path in glob.glob(os.path.join(get_confd_path(), "*.yaml")) + glob.glob(
            os.path.join(get_confd_path(), "*.yaml.default")
        ):
            self._add_clean_confd(file_path)
开发者ID:miketheman,项目名称:dd-agent,代码行数:16,代码来源:flare.py

示例6: pid_exists

# 需要导入模块: from util import Platform [as 别名]
# 或者: from util.Platform import is_windows [as 别名]
def pid_exists(pid):
    """
    Check if a pid exists.
    Lighter than psutil.pid_exists
    """
    if psutil:
        return psutil.pid_exists(pid)

    if Platform.is_windows():
        import ctypes  # Available from python2.5
        kernel32 = ctypes.windll.kernel32
        synchronize = 0x100000

        process = kernel32.OpenProcess(synchronize, 0, pid)
        if process != 0:
            kernel32.CloseHandle(process)
            return True
        else:
            return False

    # Code from psutil._psposix.pid_exists
    # See https://github.com/giampaolo/psutil/blob/master/psutil/_psposix.py
    if pid == 0:
        # According to "man 2 kill" PID 0 has a special meaning:
        # it refers to <<every process in the process group of the
        # calling process>> so we don't want to go any further.
        # If we get here it means this UNIX platform *does* have
        # a process with id 0.
        return True
    try:
        os.kill(pid, 0)
    except OSError as err:
        if err.errno == errno.ESRCH:
            # ESRCH == No such process
            return False
        elif err.errno == errno.EPERM:
            # EPERM clearly means there's a process to deny access to
            return True
        else:
            # According to "man 2 kill" possible error values are
            # (EINVAL, EPERM, ESRCH) therefore we should never get
            # here. If we do let's be explicit in considering this
            # an error.
            raise err
    else:
        return True
开发者ID:PagerDuty,项目名称:dd-agent,代码行数:48,代码来源:process.py


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