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

Side by Side Diff: third_party/psutil/examples/disk_usage.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/docs/index.html ('k') | third_party/psutil/examples/iotop.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: disk_usage.py 1143 2011-10-05 19:11:59Z 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 """
10 List all mounted disk partitions a-la "df -h" command.
11 """
12
13 import sys
14 import psutil
15
16 def convert_bytes(n):
17 if n == 0:
18 return "0B"
19 symbols = ('k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
20 prefix = {}
21 for i, s in enumerate(symbols):
22 prefix[s] = 1 << (i+1)*10
23 for s in reversed(symbols):
24 if n >= prefix[s]:
25 value = float(n) / prefix[s]
26 return '%.1f%s' % (value, s)
27
28
29 def main():
30 templ = "%-17s %8s %8s %8s %5s%% %9s %s"
31 print templ % ("Device", "Total", "Used", "Free", "Use ", "Type", "Mount")
32 for part in psutil.disk_partitions(all=False):
33 usage = psutil.disk_usage(part.mountpoint)
34 print templ % (part.device,
35 convert_bytes(usage.total),
36 convert_bytes(usage.used),
37 convert_bytes(usage.free),
38 int(usage.percent),
39 part.fstype,
40 part.mountpoint)
41
42 if __name__ == '__main__':
43 sys.exit(main())
OLDNEW
« no previous file with comments | « third_party/psutil/docs/index.html ('k') | third_party/psutil/examples/iotop.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698