@@ -122,12 +122,10 @@ class PosixProcess(Process):
122
122
123
123
def _get_processes (self , ** filters ):
124
124
cmd = "ps -Aww -o %s"
125
- attributes = {"pid" , "comm" , "pcpu" , "pmem" } | set (filters .keys ())
126
-
127
- # Theses attributes contains spaces. Put them at the end of the list
128
- attributes -= {"lstart" , "args" }
129
- attributes = sorted (attributes )
130
- attributes .extend (["lstart" , "args" ])
125
+ # lstart and args attributes contains spaces. Put them at the end of the list
126
+ attributes = sorted (
127
+ ({"pid" , "comm" , "pcpu" , "pmem" } | set (filters )) - {"lstart" , "args" }
128
+ ) + ["lstart" , "args" ]
131
129
arg = ":50," .join (attributes )
132
130
133
131
procs = []
@@ -155,12 +153,10 @@ def _get_process_attribute_by_pid(self, pid, name):
155
153
class BusyboxProcess (Process ):
156
154
def _get_processes (self , ** filters ):
157
155
cmd = "ps -A -o %s"
158
- attributes = {"pid" , "comm" , "time" } | set (filters .keys ())
159
-
160
- # Theses attributes contains spaces. Put them at the end of the list
161
- attributes -= {"args" }
162
- attributes = sorted (attributes )
163
- attributes .extend (["args" ])
156
+ # "args" attribute contains spaces. Put them at the end of the list
157
+ attributes = sorted (({"pid" , "comm" , "time" } | set (filters )) - {"args" }) + [
158
+ "args"
159
+ ]
164
160
arg = "," .join (attributes )
165
161
166
162
procs = []
0 commit comments