summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-03-26 22:36:00 (GMT)
committerFred Drake <fdrake@acm.org>1999-03-26 22:36:00 (GMT)
commitb091134e70f1476fdbd544ce14fd41c1853770f8 (patch)
tree3d6c3e9d0d975128799af7535a02c06b1c52ec93
parent787451b65f7c9c93b0bbbac10819494c484c6501 (diff)
downloadcpython-b091134e70f1476fdbd544ce14fd41c1853770f8.zip
cpython-b091134e70f1476fdbd544ce14fd41c1853770f8.tar.gz
cpython-b091134e70f1476fdbd544ce14fd41c1853770f8.tar.bz2
During display, if EPIPE is raised, it's probably because a pager was
killed. Discard the error in that case, but propogate it otherwise.
-rwxr-xr-xTools/scripts/dutree.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Tools/scripts/dutree.py b/Tools/scripts/dutree.py
index 3098f2b..5912382 100755
--- a/Tools/scripts/dutree.py
+++ b/Tools/scripts/dutree.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# Format du output in a tree shape
-import os, string, sys
+import os, string, sys, errno
def main():
p = os.popen('du ' + string.join(sys.argv[1:]), 'r')
@@ -16,7 +16,11 @@ def main():
if comps[0] == '': comps[0] = '/'
if comps[len(comps)-1] == '': del comps[len(comps)-1]
total, d = store(size, comps, total, d)
- display(total, d)
+ try:
+ display(total, d)
+ except IOError, e:
+ if e.errno != errno.EPIPE:
+ raise
def store(size, comps, total, d):
if comps == []:
@@ -52,4 +56,5 @@ def show(total, d, prefix):
if d.has_key(key):
show(tsub, d[key][1], psub)
-main()
+if __name__ == "__main__":
+ main()