mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
During display, if EPIPE is raised, it's probably because a pager was
killed. Discard the error in that case, but propogate it otherwise.
This commit is contained in:
parent
787451b65f
commit
b091134e70
1 changed files with 8 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# Format du output in a tree shape
|
# Format du output in a tree shape
|
||||||
|
|
||||||
import os, string, sys
|
import os, string, sys, errno
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
p = os.popen('du ' + string.join(sys.argv[1:]), 'r')
|
p = os.popen('du ' + string.join(sys.argv[1:]), 'r')
|
||||||
|
@ -16,7 +16,11 @@ def main():
|
||||||
if comps[0] == '': comps[0] = '/'
|
if comps[0] == '': comps[0] = '/'
|
||||||
if comps[len(comps)-1] == '': del comps[len(comps)-1]
|
if comps[len(comps)-1] == '': del comps[len(comps)-1]
|
||||||
total, d = store(size, comps, total, d)
|
total, d = store(size, comps, total, d)
|
||||||
|
try:
|
||||||
display(total, d)
|
display(total, d)
|
||||||
|
except IOError, e:
|
||||||
|
if e.errno != errno.EPIPE:
|
||||||
|
raise
|
||||||
|
|
||||||
def store(size, comps, total, d):
|
def store(size, comps, total, d):
|
||||||
if comps == []:
|
if comps == []:
|
||||||
|
@ -52,4 +56,5 @@ def show(total, d, prefix):
|
||||||
if d.has_key(key):
|
if d.has_key(key):
|
||||||
show(tsub, d[key][1], psub)
|
show(tsub, d[key][1], psub)
|
||||||
|
|
||||||
main()
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue