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 = {}
|
processdict = {}
|
||||||
for proc in psutil.process_iter():
|
for proc in psutil.process_iter():
|
||||||
# If self.get_max_processes() is None: Only retreive mandatory stats
|
# 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,
|
s = self.__get_process_stats(proc,
|
||||||
mandatory_stats=True,
|
mandatory_stats=True,
|
||||||
standard_stats=self.get_max_processes() is None)
|
standard_stats=self.get_max_processes() is None)
|
||||||
@ -348,14 +348,28 @@ class GlancesProcesses(object):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Process optimization
|
||||||
|
# Only retreive stats for visible processes (get_max_processes)
|
||||||
if self.get_max_processes() is not None:
|
if self.get_max_processes() is not None:
|
||||||
# Sort the internal dict and cut the top N (Return a list of tuple)
|
# Sort the internal dict and cut the top N (Return a list of tuple)
|
||||||
# tuple=key (proc), dict (returned by __get_process_stats)
|
# tuple=key (proc), dict (returned by __get_process_stats)
|
||||||
processiter = sorted(processdict.items(), key=lambda x: x[1][self.getsortkey()], reverse=True)
|
try:
|
||||||
first = True
|
processiter = sorted(processdict.items(), key=lambda x: x[1][self.getsortkey()], reverse=True)
|
||||||
for i in processiter[0:self.get_max_processes()]:
|
except TypeError:
|
||||||
# Already existing mandatory stats
|
# Fallback to all process (issue #423)
|
||||||
procstat = i[1]
|
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
|
# Update with standard stats
|
||||||
# and extended stats but only for TOP (first) process
|
# and extended stats but only for TOP (first) process
|
||||||
s = self.__get_process_stats(i[0],
|
s = self.__get_process_stats(i[0],
|
||||||
@ -365,21 +379,12 @@ class GlancesProcesses(object):
|
|||||||
if s is None:
|
if s is None:
|
||||||
continue
|
continue
|
||||||
procstat.update(s)
|
procstat.update(s)
|
||||||
# Add a specific time_since_update stats for bitrate
|
# Add a specific time_since_update stats for bitrate
|
||||||
procstat['time_since_update'] = time_since_update
|
procstat['time_since_update'] = time_since_update
|
||||||
# Update process list
|
# Update process list
|
||||||
self.processlist.append(procstat)
|
self.processlist.append(procstat)
|
||||||
# Next...
|
# Next...
|
||||||
first = False
|
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)
|
|
||||||
|
|
||||||
# Clean internals caches if timeout is reached
|
# Clean internals caches if timeout is reached
|
||||||
if self.cache_timer.finished():
|
if self.cache_timer.finished():
|
||||||
|
Loading…
Reference in New Issue
Block a user