Lines 1-21
Link Here
|
1 |
--- pydf.orig 2009-11-10 00:38:15.000000000 +0100 |
1 |
--- pydf.old 2010-10-05 23:50:06.000000000 +0200 |
2 |
+++ pydf 2009-11-10 02:13:13.000000000 +0100 |
2 |
+++ pydf 2010-10-06 00:28:36.000000000 +0200 |
3 |
@@ -1,4 +1,4 @@ |
3 |
@@ -1,6 +1,6 @@ |
4 |
-#! /usr/bin/python |
4 |
-#! /usr/bin/python |
5 |
+#! %%PYTHON_CMD%% |
5 |
+#! %%PYTHON_CMD%% |
6 |
|
6 |
|
7 |
import sys, os, string, types, commands, struct |
7 |
-import sys, os, string, subprocess, struct |
|
|
8 |
+import sys, os, string, struct |
8 |
from optparse import OptionParser |
9 |
from optparse import OptionParser |
9 |
@@ -169,7 +169,7 @@ |
10 |
|
|
|
11 |
from math import log |
12 |
@@ -10,6 +10,14 @@ |
13 |
# will not give the same result for broken symbolic links, but who cares... |
14 |
os.path.lexists = os.path.exists |
15 |
|
16 |
+if sys.version_info < (3, 0): |
17 |
+ # getoutput() and getstatusoutput() methods have |
18 |
+ # been moved from commands to the subprocess module |
19 |
+ # with Python >= 3.x |
20 |
+ import commands as cmd |
21 |
+else: |
22 |
+ import subprocess as cmd |
23 |
+ |
24 |
str_ljust = str.ljust |
25 |
str_rjust = str.rjust |
26 |
str_center = str.center |
27 |
@@ -61,7 +69,7 @@ |
28 |
|
29 |
|
30 |
def get_terminal_width_resize(): |
31 |
- c = subprocess.getoutput('resize').split('\n') |
32 |
+ c = cmd.getoutput('resize').split('\n') |
33 |
c = [x for x in c if x.startswith('COLUMNS=')] |
34 |
if c: |
35 |
c = c[0] |
36 |
@@ -167,7 +175,7 @@ |
10 |
#end of default definitions |
37 |
#end of default definitions |
11 |
|
38 |
|
12 |
# read configuration file |
39 |
# read configuration file |
13 |
-for conffile in ["/etc/pydfrc", os.environ['HOME']+"/.pydfrc"]: |
40 |
-for conffile in ["/etc/pydfrc", os.environ['HOME']+"/.pydfrc"]: |
14 |
+for conffile in ["%%PREFIX%/etc/pydfrc", os.environ['HOME']+"/.pydfrc"]: |
41 |
+for conffile in ["%%PREFIX%/etc/pydfrc", os.environ['HOME']+"/.pydfrc"]: |
15 |
if os.path.isfile(conffile): |
42 |
if os.path.isfile(conffile): |
16 |
execfile(conffile) |
43 |
exec(compile(open(conffile).read(), conffile, 'exec')) |
17 |
|
44 |
|
18 |
@@ -294,11 +294,12 @@ |
45 |
@@ -290,7 +298,7 @@ |
|
|
46 |
break |
47 |
else: |
48 |
# fallback, first try to parse mount output |
49 |
- status, mout = subprocess.getstatusoutput('mount') |
50 |
+ status, mout = cmd.getstatusoutput('mount') |
51 |
if status !=0: |
52 |
return dummy_result |
53 |
mlines = mout.split('\n') |
54 |
@@ -300,11 +308,16 @@ |
19 |
continue |
55 |
continue |
20 |
device, on = line.split(' on ', 1) |
56 |
device, on = line.split(' on ', 1) |
21 |
device = device.split()[0] |
57 |
device = device.split()[0] |
Lines 23-50
Link Here
|
23 |
+ onparts = on.rstrip(")").split(" (") |
59 |
+ onparts = on.rstrip(")").split(" (") |
24 |
on = onparts[0] |
60 |
on = onparts[0] |
25 |
- # option format: (a,b,..) |
61 |
- # option format: (a,b,..) |
26 |
- opts = onparts[-1][1:-1].split(",") |
62 |
- opts = onparts[-1][1:-1].split(',') |
27 |
- r[on] = (device, '', opts) |
63 |
- r[on] = (device, '', opts) |
28 |
+ # option format: (fstype, a, b, ..) |
64 |
+ l = onparts[1].split(", ") |
29 |
+ typ, opts = onparts[1].split(", ", 1) |
65 |
+ if len(l) == 2: |
|
|
66 |
+ typ, opts = l |
67 |
+ else: |
68 |
+ typ = l[0] |
69 |
+ opts = '' |
30 |
+ opts = opts.split(", ") |
70 |
+ opts = opts.split(", ") |
31 |
+ r[on] = (device, typ, opts) |
71 |
+ r[on] = (device, typ, opts) |
32 |
|
72 |
|
33 |
if r: |
73 |
if r: |
34 |
return r |
74 |
return r |
35 |
@@ -335,9 +336,9 @@ |
75 |
@@ -334,7 +347,11 @@ |
|
|
76 |
def get_row_mp(mp): |
77 |
if mp: |
78 |
if mp in mountpoints: |
79 |
- device, fstype, opts = mountpoints[mp] |
80 |
+ if len(mountpoints[mp]) == 2: |
81 |
+ device, fstype = mountpoints[mp] |
82 |
+ opts = '' |
83 |
+ else: |
84 |
+ device, fstype, opts = mountpoints[mp] |
85 |
else: |
86 |
# oops, the mountpoint is not in /etc/mtab or equivalent |
87 |
# return dummy values |
88 |
@@ -346,9 +363,9 @@ |
89 |
status = os.statvfs(mp) |
36 |
except (OSError, IOError): |
90 |
except (OSError, IOError): |
37 |
status = 10*[0] |
91 |
status = DumbStatus() |
38 |
|
92 |
- fs_blocksize = status.f_bsize |
39 |
- fs_blocksize = status[F_BSIZE] |
93 |
+ fs_blocksize = status.f_frsize |
40 |
+ fs_blocksize = status[F_FRSIZE] |
|
|
41 |
if fs_blocksize == 0: |
94 |
if fs_blocksize == 0: |
42 |
- fs_blocksize = status[F_FRSIZE] |
95 |
- fs_blocksize = status.f_frsize |
43 |
+ fs_blocksize = status[F_BSIZE] |
96 |
+ fs_blocksize = status.f_bsize |
44 |
free = status[F_BFREE] |
97 |
free = status.f_bfree |
45 |
size = status[F_BLOCKS] |
98 |
size = status.f_blocks |
46 |
avail = status[F_BAVAIL] |
99 |
avail = status.f_bavail |
47 |
@@ -366,7 +367,7 @@ |
100 |
@@ -377,7 +394,7 @@ |
48 |
used_f = myformat(used, sizeformat, fs_blocksize) |
101 |
used_f = myformat(used, sizeformat, fs_blocksize) |
49 |
avail_f = myformat(avail, sizeformat, fs_blocksize) |
102 |
avail_f = myformat(avail, sizeformat, fs_blocksize) |
50 |
try: |
103 |
try: |
Lines 53-64
Link Here
|
53 |
perc_f = str(perc) |
106 |
perc_f = str(perc) |
54 |
except ZeroDivisionError: |
107 |
except ZeroDivisionError: |
55 |
perc = 0 |
108 |
perc = 0 |
56 |
@@ -435,7 +436,7 @@ |
109 |
@@ -446,7 +463,7 @@ |
57 |
"test if fs (as type) is a special one" |
110 |
"test if fs (as type) is a special one" |
58 |
"in addition, a filesystem is special if it has number of blocks equal to 0" |
111 |
"in addition, a filesystem is special if it has number of blocks equal to 0" |
59 |
fs = fs.lower() |
112 |
fs = fs.lower() |
60 |
- return fs in [ "tmpfs", "devpts", "proc", "sysfs", "usbfs" ] |
113 |
- return fs in [ "tmpfs", "devpts", "proc", "sysfs", "usbfs" ] |
61 |
+ return fs in [ "tmpfs", "devpts", "proc", "sysfs", "usbfs", "procfs", "devfs", "linprocfs" ] |
114 |
+ return fs in [ "tmpfs", "devpts", "proc", "sysfs", "usbfs", "procfs", "devfs", "linprocfs", "fdescfs" ] |
62 |
|
115 |
|
63 |
def get_table(mps): |
116 |
def get_table(mps): |
64 |
"table is a list of rows" |
117 |
"table is a list of rows" |