Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: third_party/psutil/examples/process_detail.py

Issue 8774018: Add psutil build step to fix pyauto media issues. Upgrade psutil to 0.4.0. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Replace 'python' w/ sys.executable. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/psutil/examples/process_detail.py
diff --git a/third_party/psutil/examples/process_detail.py b/third_party/psutil/examples/process_detail.py
index 4c791d167cfc91c97b54ab60c43c214f0167a850..815cf45fa604343e1a845483b74980ac9a7869f4 100644
--- a/third_party/psutil/examples/process_detail.py
+++ b/third_party/psutil/examples/process_detail.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# $Id: process_detail.py 1143 2011-10-05 19:11:59Z g.rodola $
+# $Id: process_detail.py 1213 2011-10-29 03:30:41Z g.rodola $
#
# Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
@@ -16,7 +16,6 @@ import socket
import sys
import psutil
-from psutil._compat import namedtuple
def convert_bytes(n):
@@ -30,9 +29,10 @@ def convert_bytes(n):
if n >= prefix[s]:
value = float(n) / prefix[s]
return '%.1f%s' % (value, s)
+ return n
def print_(a, b):
- if sys.stdout.isatty():
+ if sys.stdout.isatty() and os.name == 'posix':
fmt = '\x1b[1;32m%-17s\x1b[0m %s' %(a, b)
else:
fmt = '%-15s %s' %(a, b)
@@ -45,7 +45,8 @@ def run(pid):
else:
parent = ''
started = datetime.datetime.fromtimestamp(p.create_time).strftime('%Y-%M-%d %H:%M')
- io = p.get_io_counters()
+ if hasattr(p, 'get_io_counters'):
+ io = p.get_io_counters()
mem = p.get_memory_info()
mem = '%s%% (resident=%s, virtual=%s) ' %(round(p.get_memory_percent(), 1),
convert_bytes(mem.rss),
@@ -99,7 +100,12 @@ def run(pid):
if connections:
print_('open connections', '')
for conn in connections:
- type = 'TCP' if conn.type == socket.SOCK_STREAM else 'UDP'
+ if conn.type == socket.SOCK_STREAM:
+ type = 'TCP'
+ elif conn.type == socket.SOCK_DGRAM:
+ type = 'UDP'
+ else:
+ type = 'UNIX'
lip, lport = conn.local_address
if not conn.remote_address:
rip, rport = '*', '*'

Powered by Google App Engine
This is Rietveld 408576698