From: Jos Collin Date: Mon, 27 Jan 2025 06:10:43 +0000 (+0530) Subject: cephfs-top: exception when terminal size greater than PAD_WIDTH X-Git-Tag: v20.0.0~185^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=fa12ce661f3f4c68c96f7981fbfb5dee397ac63c;p=ceph.git cephfs-top: exception when terminal size greater than PAD_WIDTH Fixes: https://tracker.ceph.com/issues/69669 Signed-off-by: Jos Collin --- diff --git a/src/tools/cephfs/top/cephfs-top b/src/tools/cephfs/top/cephfs-top index 45900f9a025b0..a814174f3391f 100755 --- a/src/tools/cephfs/top/cephfs-top +++ b/src/tools/cephfs/top/cephfs-top @@ -360,12 +360,6 @@ class FSTop(FSTopBase): # requested it will raise an exception pass - # Check the window size before creating the pad. For large windows, - # PAD_WIDTH = window width. - h, w = self.stdscr.getmaxyx() - if (w > DEFAULT_PAD_WIDTH): - self.PAD_WIDTH = w - self.fstop_pad = curses.newpad(self.PAD_HEIGHT, self.PAD_WIDTH) self.run_all_display() def display_fs_menu(self, stdscr, selected_row_idx): @@ -964,8 +958,13 @@ class FSTop(FSTopBase): top, left = 0, 0 # where to place pad vscrollOffset, hscrollOffset = 0, 0 # scroll offsets - # calculate the initial viewport height and width + # Check the window size before creating the pad. For large windows, PAD_WIDTH=window width. windowsize = self.stdscr.getmaxyx() + if (windowsize[1] > DEFAULT_PAD_WIDTH): + self.PAD_WIDTH = windowsize[1] + self.fstop_pad = curses.newpad(self.PAD_HEIGHT, self.PAD_WIDTH) + + # calculate the initial viewport height and width self.viewportHeight, self.viewportWidth = windowsize[0] - 1, windowsize[1] - 1 # create header subpad @@ -1098,8 +1097,13 @@ class FSTop(FSTopBase): top, left = 0, 0 # where to place pad vscrollOffset, hscrollOffset = 0, 0 # scroll offsets - # calculate the initial viewport height and width + # Check the window size before creating the pad. For large windows, PAD_WIDTH=window width. windowsize = self.stdscr.getmaxyx() + if (windowsize[1] > DEFAULT_PAD_WIDTH): + self.PAD_WIDTH = windowsize[1] + self.fstop_pad = curses.newpad(self.PAD_HEIGHT, self.PAD_WIDTH) + + # calculate the initial viewport height and width self.viewportHeight, self.viewportWidth = windowsize[0] - 1, windowsize[1] - 1 # create header subpad