本文整理汇总了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')
示例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")
示例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"])
示例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'])
示例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)
示例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