def getUser():
if linux:
proc_obj = subprocess.Popen(r'tty', shell=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
tty = proc_obj.communicate()[0]
else:
tty = []
user_object = psutil.users()
for login in user_object:
try:
username, login_tty, login_host, login_time = [suser for suser in login]
except ValueError: # different version
# suser(name='Guodong', terminal=None, host='0.0.0.0', started=1511519014.0, pid=None)
username, login_tty, login_host, login_time, pid = [suser for suser in login]
print username, login_tty, login_host, time.strftime('%b %d %H:%M:%S', time.localtime(login_time)),
if login_tty in tty:
print '**current user**'
else:
print
getSystemStatus.py 文件源码
python
阅读 36
收藏 0
点赞 0
评论 0
评论列表
文章目录