wip
This commit is contained in:
parent
5aea99819a
commit
b4ebb9c5d3
39
tkdu.py
39
tkdu.py
@ -19,6 +19,7 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
from argparse import ArgumentParser
|
||||||
import tkinter
|
import tkinter
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@ -141,7 +142,7 @@ def allocate(path, files, canvas, x, y, w, h, first, depth):
|
|||||||
color = colors[haskids]
|
color = colors[haskids]
|
||||||
if item[2] is None:
|
if item[2] is None:
|
||||||
continue
|
continue
|
||||||
x, y, w, h = pos = item[2]
|
x, y, w, h = item[2]
|
||||||
if w > 3*BORDER and h > 3*BORDER:
|
if w > 3*BORDER and h > 3*BORDER:
|
||||||
tk_call(canvas._w,
|
tk_call(canvas._w,
|
||||||
"create", "rectangle",
|
"create", "rectangle",
|
||||||
@ -407,7 +408,7 @@ def setdepth(e, c, i):
|
|||||||
reconfigure(e)
|
reconfigure(e)
|
||||||
|
|
||||||
|
|
||||||
def main(f=sys.stdin):
|
def old_main(f=sys.stdin):
|
||||||
files = {}
|
files = {}
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
sz, name = line[:-1].split(None, 1)
|
sz, name = line[:-1].split(None, 1)
|
||||||
@ -474,7 +475,6 @@ class DirDialog(tkinter.filedialog.LoadFileDialog):
|
|||||||
self.set_filter(dir, pat)
|
self.set_filter(dir, pat)
|
||||||
names.sort()
|
names.sort()
|
||||||
subdirs = [os.pardir]
|
subdirs = [os.pardir]
|
||||||
matchingfiles = []
|
|
||||||
for name in names:
|
for name in names:
|
||||||
fullname = os.path.join(dir, name)
|
fullname = os.path.join(dir, name)
|
||||||
if os.path.isdir(fullname):
|
if os.path.isdir(fullname):
|
||||||
@ -520,22 +520,49 @@ def main_builtin_du(args):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if p == "-":
|
if p == "-":
|
||||||
main()
|
old_main()
|
||||||
else:
|
else:
|
||||||
p = abspath(p)
|
p = abspath(p)
|
||||||
if os.path.isfile(p):
|
if os.path.isfile(p):
|
||||||
if p.endswith('.gz'):
|
if p.endswith('.gz'):
|
||||||
# gzipped file
|
# gzipped file
|
||||||
main(gzip.open(p, 'r'))
|
old_main(gzip.open(p, 'r'))
|
||||||
else:
|
else:
|
||||||
main(open(p, 'r'))
|
old_main(open(p, 'r'))
|
||||||
else:
|
else:
|
||||||
putname(files, p, du(p, files))
|
putname(files, p, du(p, files))
|
||||||
doit(p, files)
|
doit(p, files)
|
||||||
|
|
||||||
|
|
||||||
|
argp = ArgumentParser(
|
||||||
|
prog='tkdu',
|
||||||
|
description='''Interactive explorer of `du` utility program.
|
||||||
|
'Useful when you need to interactively inspect disk usage
|
||||||
|
'on remote system but dont have `ncdu` or alike installed''',
|
||||||
|
epilog='''
|
||||||
|
Controls:
|
||||||
|
* Press `q` to quit
|
||||||
|
* LMB: zoom in to item
|
||||||
|
* RMB: zoom out one level
|
||||||
|
* Press `1`..`9`: Show that many nested levels
|
||||||
|
* Press `0`: Show man nested levels
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
|
argp.add_argument(
|
||||||
|
'du_output',
|
||||||
|
help='du output file in plain text, gzipped or not'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = argp.parse_args()
|
||||||
|
print(args)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
main()
|
||||||
main_builtin_du(sys.argv)
|
main_builtin_du(sys.argv)
|
||||||
|
|
||||||
# vim:sts=4:sw=4:
|
# vim:sts=4:sw=4:
|
||||||
|
Loading…
Reference in New Issue
Block a user