Browse Source

Merge "Remove psutil 1.x compat wrapping"

Jenkins 1 year ago
parent
commit
07afa7df4a
1 changed files with 11 additions and 17 deletions
  1. 11
    17
      oslo_reports/models/process.py

+ 11
- 17
oslo_reports/models/process.py View File

@@ -18,13 +18,9 @@ This module defines a class representing a process,
18 18
 potentially with subprocesses.
19 19
 """
20 20
 
21
-import psutil
22
-
23 21
 import oslo_reports.models.with_default_views as mwdv
24 22
 import oslo_reports.views.text.process as text_views
25 23
 
26
-PS1 = psutil.version_info[0] == 1
27
-
28 24
 
29 25
 class ProcessModel(mwdv.ModelWithDefaultViews):
30 26
     """A Process Model
@@ -40,13 +36,12 @@ class ProcessModel(mwdv.ModelWithDefaultViews):
40 36
             text_view=text_views.ProcessView())
41 37
 
42 38
         self['pid'] = process.pid
43
-        self['parent_pid'] = (process.ppid if PS1 else process.ppid())
39
+        self['parent_pid'] = process.ppid()
44 40
         if hasattr(process, 'uids'):
45 41
             self['uids'] = {
46
-                'real': (process.uids.real if PS1 else process.uids().real),
47
-                'effective': (process.uids.effective if PS1
48
-                              else process.uids().effective),
49
-                'saved': (process.uids.saved if PS1 else process.uids().saved)
42
+                'real': process.uids().real,
43
+                'effective': process.uids().effective,
44
+                'saved': process.uids().saved
50 45
             }
51 46
         else:
52 47
             self['uids'] = {'real': None,
@@ -55,19 +50,18 @@ class ProcessModel(mwdv.ModelWithDefaultViews):
55 50
 
56 51
         if hasattr(process, 'gids'):
57 52
             self['gids'] = {
58
-                'real': (process.gids.real if PS1 else process.gids().real),
59
-                'effective': (process.gids.effective if PS1
60
-                              else process.gids().effective),
61
-                'saved': (process.gids.saved if PS1 else process.gids().saved)
53
+                'real': process.gids().real,
54
+                'effective': process.gids().effective,
55
+                'saved': process.gids().saved
62 56
             }
63 57
         else:
64 58
             self['gids'] = {'real': None,
65 59
                             'effective': None,
66 60
                             'saved': None}
67 61
 
68
-        self['username'] = process.username if PS1 else process.username()
69
-        self['command'] = process.cmdline if PS1 else process.cmdline()
70
-        self['state'] = process.status if PS1 else process.status()
62
+        self['username'] = process.username()
63
+        self['command'] = process.cmdline()
64
+        self['state'] = process.status()
71 65
 
72
-        children = process.get_children() if PS1 else process.children()
66
+        children = process.children()
73 67
         self['children'] = [ProcessModel(pr) for pr in children]

Loading…
Cancel
Save