Fix deprecation warnings.

Drop psutil < 2.0 leftovers.
This commit is contained in:
Alessio Sergi 2014-04-15 12:55:15 +02:00
parent e17b4b61cf
commit 9cf956b881
2 changed files with 17 additions and 26 deletions

View File

@ -106,21 +106,21 @@ class glancesProcesses:
procstat['status'] = str(proc.status())[:1].upper()
# Process nice
procstat['nice'] = proc.get_nice()
procstat['nice'] = proc.nice()
# Process memory
procstat['memory_info'] = proc.get_memory_info()
procstat['memory_percent'] = proc.get_memory_percent()
procstat['memory_info'] = proc.memory_info()
procstat['memory_percent'] = proc.memory_percent()
# Process CPU
procstat['cpu_times'] = proc.get_cpu_times()
procstat['cpu_percent'] = proc.get_cpu_percent(interval=0)
procstat['cpu_times'] = proc.cpu_times()
procstat['cpu_percent'] = proc.cpu_percent(interval=0)
# Process network connections (TCP and UDP) (Experimental)
# !!! High CPU consumption
# try:
# procstat['tcp'] = len(proc.get_connections(kind="tcp"))
# procstat['udp'] = len(proc.get_connections(kind="udp"))
# procstat['tcp'] = len(proc.connections(kind="tcp"))
# procstat['udp'] = len(proc.connections(kind="udp"))
# except:
# procstat['tcp'] = 0
# procstat['udp'] = 0
@ -134,7 +134,7 @@ class glancesProcesses:
if not is_Mac:
try:
# Get the process IO counters
proc_io = proc.get_io_counters()
proc_io = proc.io_counters()
io_new = [proc_io.read_bytes, proc_io.write_bytes]
except AccessDenied:
# Access denied to process IO (no root account)
@ -197,7 +197,7 @@ class glancesProcesses:
self.processcount['total'] += 1
# Update thread number (global statistics)
try:
self.processcount['thread'] += proc.get_num_threads()
self.processcount['thread'] += proc.num_threads()
except:
pass
except (NoSuchProcess, AccessDenied):

View File

@ -18,14 +18,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Import system libs
# Check for PSUtil already done in the glances_core script
try:
from psutil import get_boot_time
except:
from psutil import BOOT_TIME
from datetime import datetime
# Check for psutil already done in the glances_core script
import psutil
# Import Glances libs
from glances.plugins.glances_plugin import GlancesPlugin
@ -54,13 +51,7 @@ class Plugin(GlancesPlugin):
"""
Update uptime stat
"""
try:
# For PsUtil >= 0.7.0
uptime = datetime.now() - datetime.fromtimestamp(get_boot_time())
except NameError:
uptime = datetime.now() - datetime.fromtimestamp(BOOT_TIME)
else:
uptime = '.UNKNOW'
uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time())
# Convert uptime to string (because datetime is not JSONifi)
self.stats = str(uptime).split('.')[0]