python 判断进程是否存在+获取进程占用内存值
来源:互联网 发布:来肯云商进销存软件 编辑:程序博客网 时间:2024/05/17 03:36
def proc_exist(proc_name):
try:
is_exist = False
file_handle = os.popen('tasklist /FI "IMAGENAME eq ' + proc_name + '"')
file_content = file_handle.read()
if file_content.find(proc_name) > -1:
is_exist = True
except BaseException,e:
print str(e)
finally:
return is_exist
def get_proc_memory(proc_name):
memory = 0
task = os.popen('tasklist')
task_content = task.read()
MAX_IMAGENAME_LEN = 25
proc_name_show = proc_name
if len(proc_name_show) > MAX_IMAGENAME_LEN:
proc_name_show = proc_name_show[:MAX_IMAGENAME_LEN]
if task_content.find(proc_name_show) > -1:
try:
num = task_content.split().index(proc_name_show)
tasklist = task_content.split()
index_n = num+1
memory = tasklist[index_n+3]
except Exception,e:
print e
break
return memory
try:
is_exist = False
file_handle = os.popen('tasklist /FI "IMAGENAME eq ' + proc_name + '"')
file_content = file_handle.read()
if file_content.find(proc_name) > -1:
is_exist = True
except BaseException,e:
print str(e)
finally:
return is_exist
def get_proc_memory(proc_name):
memory = 0
task = os.popen('tasklist')
task_content = task.read()
MAX_IMAGENAME_LEN = 25
proc_name_show = proc_name
if len(proc_name_show) > MAX_IMAGENAME_LEN:
proc_name_show = proc_name_show[:MAX_IMAGENAME_LEN]
if task_content.find(proc_name_show) > -1:
try:
num = task_content.split().index(proc_name_show)
tasklist = task_content.split()
index_n = num+1
memory = tasklist[index_n+3]
except Exception,e:
print e
break
return memory
- python 判断进程是否存在+获取进程占用内存值
- python判断进程是否存在
- Python 判断一个进程是否存在
- python 判断一个进程是否存在
- python 杀进程 判断文件是否存在 查看进程
- 判断某个进程是否存在
- 判断子进程是否存在
- 判断某进程是否存在
- C++ 判断进程是否存在
- C++ 判断进程是否存在
- 判断windows进程是否存在
- VC判断进程是否存在
- VB 判断进程是否存在
- C++ 判断进程是否存在
- C++ 判断进程是否存在
- QT cmd判断进程是否存在 获取进程信息 关闭进程
- QT cmd判断进程是否存在 获取进程信息 关闭进程
- 判断进程是否存在,是否被杀死了
- NS-2相关工具大体介绍<2>
- "对象库未注册"问题
- 免费的C++图形和游戏库
- linux内存管理--进程在内存中的分布
- 设计模式之(一)Factory模式
- python 判断进程是否存在+获取进程占用内存值
- 简单四则运算(华为2011机试题)
- C# 调用C++ dll 方法返回char* 乱码
- Windows下codeblocks+wxWidgets的安装配置
- Spring (二) OOP V.S AOP
- cocos2dx中的touch检查是否选中了控件
- 人生感悟
- Android:Camera的使用,并处理手机拍照后上传图片被旋转的问题
- Redis实战