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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/psutil/psutil/__init__.py ('k') | third_party/psutil/psutil/_compat.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #/usr/bin/env python
2 #
3 #$Id: _common.py 1142 2011-10-05 18:45:49Z g.rodola $
4 #
5 # Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
6 # Use of this source code is governed by a BSD-style license that can be
7 # found in the LICENSE file.
8
9 """Common objects shared by all _ps* modules."""
10
11 from psutil._compat import namedtuple
12
13 def usage_percent(used, total, _round=None):
14 """Calculate percentage usage of 'used' against 'total'."""
15 try:
16 ret = (float(used) / total) * 100
17 except ZeroDivisionError:
18 ret = 0
19 if _round is not None:
20 return round(ret, _round)
21 else:
22 return ret
23
24
25 class constant(int):
26 """A constant type; overrides base int to provide a useful name on str()."""
27
28 def __new__(cls, value, name, doc=None):
29 inst = super(constant, cls).__new__(cls, value)
30 inst._name = name
31 if doc is not None:
32 inst.__doc__ = doc
33 return inst
34
35 def __str__(self):
36 return self._name
37
38 STATUS_RUNNING = constant(0, "running")
39 STATUS_SLEEPING = constant(1, "sleeping")
40 STATUS_DISK_SLEEP = constant(2, "disk sleep")
41 STATUS_STOPPED = constant(3, "stopped")
42 STATUS_TRACING_STOP = constant(4, "tracing stop")
43 STATUS_ZOMBIE = constant(5, "zombie")
44 STATUS_DEAD = constant(6, "dead")
45 STATUS_WAKE_KILL = constant(7, "wake kill")
46 STATUS_WAKING = constant(8, "waking")
47 STATUS_IDLE = constant(9, "idle") # BSD
48 STATUS_LOCKED = constant(10, "locked") # BSD
49 STATUS_WAITING = constant(11, "waiting") # BSD
50
51
52 # system
53 ntuple_sys_cputimes = namedtuple('cputimes', 'user nice system idle iowait irq s oftirq')
54 ntuple_sysmeminfo = namedtuple('usage', 'total used free percent')
55 ntuple_diskinfo = namedtuple('usage', 'total used free percent')
56 ntuple_partition = namedtuple('partition', 'device mountpoint fstype')
57 ntuple_net_iostat = namedtuple('iostat', 'bytes_sent bytes_recv packets_sent pac kets_recv')
58 ntuple_disk_iostat = namedtuple('iostat', 'read_count write_count read_bytes wri te_bytes read_time write_time')
59
60 # processes
61 ntuple_meminfo = namedtuple('meminfo', 'rss vms')
62 ntuple_cputimes = namedtuple('cputimes', 'user system')
63 ntuple_openfile = namedtuple('openfile', 'path fd')
64 ntuple_connection = namedtuple('connection', 'fd family type local_address remot e_address status')
65 ntuple_thread = namedtuple('thread', 'id user_time system_time')
66 ntuple_uids = namedtuple('user', 'real effective saved')
67 ntuple_gids = namedtuple('group', 'real effective saved')
68 ntuple_io = namedtuple('io', 'read_count write_count read_bytes write_bytes')
69 ntuple_ionice = namedtuple('ionice', 'ioclass value')
OLDNEW
« 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