Remove psutil 1.x compat wrapping

oslo.reports requires psutil at least to be 3.x, so the compat
code paths for 1.x can be removed safely.

Change-Id: If5de0051f2cd131db2f2b0b2919082e1623c29aa
This commit is contained in:
Dirk Mueller 2017-07-29 08:58:21 +02:00
parent c75749bd54
commit 21cbc5db00

View File

@ -18,13 +18,9 @@ This module defines a class representing a process,
potentially with subprocesses.
"""
import psutil
import oslo_reports.models.with_default_views as mwdv
import oslo_reports.views.text.process as text_views
PS1 = psutil.version_info[0] == 1
class ProcessModel(mwdv.ModelWithDefaultViews):
"""A Process Model
@ -40,13 +36,12 @@ class ProcessModel(mwdv.ModelWithDefaultViews):
text_view=text_views.ProcessView())
self['pid'] = process.pid
self['parent_pid'] = (process.ppid if PS1 else process.ppid())
self['parent_pid'] = process.ppid()
if hasattr(process, 'uids'):
self['uids'] = {
'real': (process.uids.real if PS1 else process.uids().real),
'effective': (process.uids.effective if PS1
else process.uids().effective),
'saved': (process.uids.saved if PS1 else process.uids().saved)
'real': process.uids().real,
'effective': process.uids().effective,
'saved': process.uids().saved
}
else:
self['uids'] = {'real': None,
@ -55,19 +50,18 @@ class ProcessModel(mwdv.ModelWithDefaultViews):
if hasattr(process, 'gids'):
self['gids'] = {
'real': (process.gids.real if PS1 else process.gids().real),
'effective': (process.gids.effective if PS1
else process.gids().effective),
'saved': (process.gids.saved if PS1 else process.gids().saved)
'real': process.gids().real,
'effective': process.gids().effective,
'saved': process.gids().saved
}
else:
self['gids'] = {'real': None,
'effective': None,
'saved': None}
self['username'] = process.username if PS1 else process.username()
self['command'] = process.cmdline if PS1 else process.cmdline()
self['state'] = process.status if PS1 else process.status()
self['username'] = process.username()
self['command'] = process.cmdline()
self['state'] = process.status()
children = process.get_children() if PS1 else process.children()
children = process.children()
self['children'] = [ProcessModel(pr) for pr in children]