Skip to content

Commit

Permalink
Use pwd by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
Heinrich Kuttler committed Aug 19, 2020
1 parent 3838529 commit 8593513
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions filesizeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
DU_COMMAND = "du -a"
BLOCKSIZE = 512
else:
# gdu is installed. Let's use it.
DU_COMMAND = "g" + DU_COMMAND


Expand Down Expand Up @@ -299,10 +300,7 @@ def __init__(self, mainwin, _dir, draw_frame):
self.write_path()
self.set_cursor(0, 0)
while True:
try:
ch = self._mainwin.getch()
except KeyboardInterrupt:
break
ch = self._mainwin.getch()
if ch == ord("q"):
break
elif ch == ord("f"):
Expand Down Expand Up @@ -368,7 +366,7 @@ def load_dir(self, d):
with subprocess.Popen(
DU_COMMAND.split(), stdout=subprocess.PIPE, close_fds=True, text=True
) as du:
self._parent_dir = self.create_tree(du.stdout, sys.argv[1])
self._parent_dir = self.create_tree(du.stdout, d)
maxyx = self._mainwin.getmaxyx()
win = self._mainwin.derwin(maxyx[0] - 1, maxyx[1], 0, 0)
win.bkgdset(" ", curses.color_pair(0))
Expand Down Expand Up @@ -476,19 +474,24 @@ def create_tree(self, sizefile, directory):


def main():
# set usage
(options, args) = parser.parse_args()
if len(args) != 1:
options, args = parser.parse_args()

if len(args) > 1:
parser.print_usage()
sys.exit(1)
if not os.path.isdir(args[0]):
print("invalid directory: " + args[0])

directory = args[0] if args else os.getcwd()

if not os.path.isdir(directory):
print("invalid directory:", directory)
sys.exit(1)

try:
curses.wrapper(fsvViewer, args[0], options.draw_frames)
except fsvError:
print(str(sys.exc_info()[1]))
curses.wrapper(fsvViewer, directory, options.draw_frames)
except KeyboardInterrupt:
return
except fsvError as e:
print(e)
sys.exit(2)


Expand Down

0 comments on commit 8593513

Please sign in to comment.