Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b091134

Browse files
committed
During display, if EPIPE is raised, it's probably because a pager was
killed. Discard the error in that case, but propogate it otherwise.
1 parent 787451b commit b091134

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Tools/scripts/dutree.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env python
22
# Format du output in a tree shape
33

4-
import os, string, sys
4+
import os, string, sys, errno
55

66
def main():
77
p = os.popen('du ' + string.join(sys.argv[1:]), 'r')
@@ -16,7 +16,11 @@ def main():
1616
if comps[0] == '': comps[0] = '/'
1717
if comps[len(comps)-1] == '': del comps[len(comps)-1]
1818
total, d = store(size, comps, total, d)
19-
display(total, d)
19+
try:
20+
display(total, d)
21+
except IOError, e:
22+
if e.errno != errno.EPIPE:
23+
raise
2024

2125
def store(size, comps, total, d):
2226
if comps == []:
@@ -52,4 +56,5 @@ def show(total, d, prefix):
5256
if d.has_key(key):
5357
show(tsub, d[key][1], psub)
5458

55-
main()
59+
if __name__ == "__main__":
60+
main()

0 commit comments

Comments
 (0)