mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Py3 compatibility fixes.
This commit is contained in:
parent
f1e86e1cf4
commit
be8e880672
@ -6,9 +6,9 @@ See http://code.google.com/p/psutil.
|
||||
:depends: - psutil Python module, version 0.3.0 or later
|
||||
- python-utmp package (optional)
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import time
|
||||
import datetime
|
||||
|
||||
@ -16,6 +16,8 @@ import datetime
|
||||
from salt.exceptions import SaltInvocationError, CommandExecutionError
|
||||
|
||||
# Import third party libs
|
||||
import salt.ext.six as six
|
||||
# pylint: disable=import-error
|
||||
try:
|
||||
import psutil
|
||||
|
||||
@ -23,6 +25,7 @@ try:
|
||||
PSUTIL2 = psutil.version_info >= (2, 0)
|
||||
except ImportError:
|
||||
HAS_PSUTIL = False
|
||||
# pylint: enable=import-error
|
||||
|
||||
|
||||
def __virtual__():
|
||||
@ -120,7 +123,7 @@ def top(num_processes=5, interval=3):
|
||||
start_usage[process] = user + system
|
||||
time.sleep(interval)
|
||||
usage = set()
|
||||
for process, start in start_usage.items():
|
||||
for process, start in six.iteritems(start_usage):
|
||||
try:
|
||||
user, system = process.get_cpu_times()
|
||||
except psutil.NoSuchProcess:
|
||||
@ -144,9 +147,9 @@ def top(num_processes=5, interval=3):
|
||||
'cpu': {},
|
||||
'mem': {},
|
||||
}
|
||||
for key, value in process.get_cpu_times()._asdict().items():
|
||||
for key, value in six.iteritems(process.get_cpu_times()._asdict()):
|
||||
info['cpu'][key] = value
|
||||
for key, value in process.get_memory_info()._asdict().items():
|
||||
for key, value in six.iteritems(process.get_memory_info()._asdict()):
|
||||
info['mem'][key] = value
|
||||
result.append(info)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user