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

Unified Diff: third_party/psutil/psutil/_common.py

Issue 8159001: Update third_party/psutil and fix the licence issue with it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove the suppression and unnecessary files. Created 9 years, 2 months 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
« no previous file with comments | « third_party/psutil/psutil/__init__.py ('k') | third_party/psutil/psutil/_compat.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/psutil/psutil/_common.py
diff --git a/third_party/psutil/psutil/_common.py b/third_party/psutil/psutil/_common.py
new file mode 100644
index 0000000000000000000000000000000000000000..e08011d0a8bcc479ec4e636a6c949e0487739106
--- /dev/null
+++ b/third_party/psutil/psutil/_common.py
@@ -0,0 +1,69 @@
+#/usr/bin/env python
+#
+#$Id: _common.py 1142 2011-10-05 18:45:49Z 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
+# found in the LICENSE file.
+
+"""Common objects shared by all _ps* modules."""
+
+from psutil._compat import namedtuple
+
+def usage_percent(used, total, _round=None):
+ """Calculate percentage usage of 'used' against 'total'."""
+ try:
+ ret = (float(used) / total) * 100
+ except ZeroDivisionError:
+ ret = 0
+ if _round is not None:
+ return round(ret, _round)
+ else:
+ return ret
+
+
+class constant(int):
+ """A constant type; overrides base int to provide a useful name on str()."""
+
+ def __new__(cls, value, name, doc=None):
+ inst = super(constant, cls).__new__(cls, value)
+ inst._name = name
+ if doc is not None:
+ inst.__doc__ = doc
+ return inst
+
+ def __str__(self):
+ return self._name
+
+STATUS_RUNNING = constant(0, "running")
+STATUS_SLEEPING = constant(1, "sleeping")
+STATUS_DISK_SLEEP = constant(2, "disk sleep")
+STATUS_STOPPED = constant(3, "stopped")
+STATUS_TRACING_STOP = constant(4, "tracing stop")
+STATUS_ZOMBIE = constant(5, "zombie")
+STATUS_DEAD = constant(6, "dead")
+STATUS_WAKE_KILL = constant(7, "wake kill")
+STATUS_WAKING = constant(8, "waking")
+STATUS_IDLE = constant(9, "idle") # BSD
+STATUS_LOCKED = constant(10, "locked") # BSD
+STATUS_WAITING = constant(11, "waiting") # BSD
+
+
+# system
+ntuple_sys_cputimes = namedtuple('cputimes', 'user nice system idle iowait irq softirq')
+ntuple_sysmeminfo = namedtuple('usage', 'total used free percent')
+ntuple_diskinfo = namedtuple('usage', 'total used free percent')
+ntuple_partition = namedtuple('partition', 'device mountpoint fstype')
+ntuple_net_iostat = namedtuple('iostat', 'bytes_sent bytes_recv packets_sent packets_recv')
+ntuple_disk_iostat = namedtuple('iostat', 'read_count write_count read_bytes write_bytes read_time write_time')
+
+# processes
+ntuple_meminfo = namedtuple('meminfo', 'rss vms')
+ntuple_cputimes = namedtuple('cputimes', 'user system')
+ntuple_openfile = namedtuple('openfile', 'path fd')
+ntuple_connection = namedtuple('connection', 'fd family type local_address remote_address status')
+ntuple_thread = namedtuple('thread', 'id user_time system_time')
+ntuple_uids = namedtuple('user', 'real effective saved')
+ntuple_gids = namedtuple('group', 'real effective saved')
+ntuple_io = namedtuple('io', 'read_count write_count read_bytes write_bytes')
+ntuple_ionice = namedtuple('ionice', 'ioclass value')
« no previous file with comments | « third_party/psutil/psutil/__init__.py ('k') | third_party/psutil/psutil/_compat.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698