mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-29 04:04:03 +03:00
Correct issue on Mac OS X running in non root (issue #423)
This commit is contained in:
parent
57569b23f3
commit
d50f49eb89
@ -318,7 +318,7 @@ class GlancesProcesses(object):
|
||||
processdict = {}
|
||||
for proc in psutil.process_iter():
|
||||
# If self.get_max_processes() is None: Only retreive mandatory stats
|
||||
# Else: retreive mandatoryadn standard stast
|
||||
# Else: retreive mandatory and standard stats
|
||||
s = self.__get_process_stats(proc,
|
||||
mandatory_stats=True,
|
||||
standard_stats=self.get_max_processes() is None)
|
||||
@ -348,14 +348,28 @@ class GlancesProcesses(object):
|
||||
except:
|
||||
pass
|
||||
|
||||
# Process optimization
|
||||
# Only retreive stats for visible processes (get_max_processes)
|
||||
if self.get_max_processes() is not None:
|
||||
# Sort the internal dict and cut the top N (Return a list of tuple)
|
||||
# tuple=key (proc), dict (returned by __get_process_stats)
|
||||
processiter = sorted(processdict.items(), key=lambda x: x[1][self.getsortkey()], reverse=True)
|
||||
first = True
|
||||
for i in processiter[0:self.get_max_processes()]:
|
||||
# Already existing mandatory stats
|
||||
procstat = i[1]
|
||||
try:
|
||||
processiter = sorted(processdict.items(), key=lambda x: x[1][self.getsortkey()], reverse=True)
|
||||
except TypeError:
|
||||
# Fallback to all process (issue #423)
|
||||
processloop = processdict.items()
|
||||
first = False
|
||||
else:
|
||||
processloop = processiter[0:self.get_max_processes()]
|
||||
first = True
|
||||
else:
|
||||
# Get all processes stats
|
||||
processloop = processdict.items()
|
||||
first = False
|
||||
for i in processloop:
|
||||
# Already existing mandatory stats
|
||||
procstat = i[1]
|
||||
if self.get_max_processes() is not None:
|
||||
# Update with standard stats
|
||||
# and extended stats but only for TOP (first) process
|
||||
s = self.__get_process_stats(i[0],
|
||||
@ -365,21 +379,12 @@ class GlancesProcesses(object):
|
||||
if s is None:
|
||||
continue
|
||||
procstat.update(s)
|
||||
# Add a specific time_since_update stats for bitrate
|
||||
procstat['time_since_update'] = time_since_update
|
||||
# Update process list
|
||||
self.processlist.append(procstat)
|
||||
# Next...
|
||||
first = False
|
||||
else:
|
||||
# Get all the processes
|
||||
for i in processdict.items():
|
||||
# Already existing mandatory and standard stats
|
||||
procstat = i[1]
|
||||
# Add a specific time_since_update stats for bitrate
|
||||
procstat['time_since_update'] = time_since_update
|
||||
# Update process list
|
||||
self.processlist.append(procstat)
|
||||
# Add a specific time_since_update stats for bitrate
|
||||
procstat['time_since_update'] = time_since_update
|
||||
# Update process list
|
||||
self.processlist.append(procstat)
|
||||
# Next...
|
||||
first = False
|
||||
|
||||
# Clean internals caches if timeout is reached
|
||||
if self.cache_timer.finished():
|
||||
|
Loading…
Reference in New Issue
Block a user