summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/progressbar/progressbar.py
diff options
context:
space:
mode:
authorBenjamin Szőke <egyszeregy@freemail.hu>2025-01-25 13:27:49 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-08-19 11:33:23 +0100
commitd23ce1b4dbf9a32e7a8c1380b57956b6b2ada514 (patch)
tree5246a333786a083e47a61e3f6384b431c89bd3b5 /bitbake/lib/progressbar/progressbar.py
parent5dce840ba8f409490cca5dce9fe504c9115fb4e5 (diff)
downloadpoky-d23ce1b4dbf9a32e7a8c1380b57956b6b2ada514.tar.gz
bitbake: progressbar: Add self._fd_console to use for self._handle_resize()
Introduce self._fd_console as a dedicated attribute of self._handle_resize(). (Bitbake rev: f8c76eb89d52b1c28407f0b52dfe4318faa47cd2) Signed-off-by: Benjamin Szőke <egyszeregy@freemail.hu> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/progressbar/progressbar.py')
-rw-r--r--bitbake/lib/progressbar/progressbar.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/bitbake/lib/progressbar/progressbar.py b/bitbake/lib/progressbar/progressbar.py
index d4da10ab75..eccc45849b 100644
--- a/bitbake/lib/progressbar/progressbar.py
+++ b/bitbake/lib/progressbar/progressbar.py
@@ -110,18 +110,25 @@ class ProgressBar(object):
110 self.widgets = widgets 110 self.widgets = widgets
111 self.fd = fd 111 self.fd = fd
112 self.left_justify = left_justify 112 self.left_justify = left_justify
113 self._fd_console = None
113 114
114 self.signal_set = False 115 self.signal_set = False
115 if term_width is not None: 116 if term_width is not None:
116 self.term_width = term_width 117 self.term_width = term_width
117 else: 118 else:
118 try: 119 try:
120 # Check if given file descriptor is resizable for example belong
121 # to a terminal/console as STDOUT or STDERR. If file descriptor
122 # is resizable, let's allow to use for self._handle_resize()
123 # in a dedicated self._fd_console in order to be able to set
124 # temporarily/permanently self.fd to any StringIO or other
125 # file descriptor later.
126 self._fd_console = fd
119 self._handle_resize(None, None) 127 self._handle_resize(None, None)
120 signal.signal(signal.SIGWINCH, self._handle_resize) 128 signal.signal(signal.SIGWINCH, self._handle_resize)
121 self.signal_set = True 129 self.signal_set = True
122 except (SystemExit, KeyboardInterrupt): raise 130 except (SystemExit, KeyboardInterrupt): raise
123 except Exception as e: 131 except Exception as e:
124 print("DEBUG 5 %s" % e)
125 self.term_width = self._env_size() 132 self.term_width = self._env_size()
126 133
127 self.__iterable = None 134 self.__iterable = None
@@ -182,7 +189,7 @@ class ProgressBar(object):
182 def _handle_resize(self, signum=None, frame=None): 189 def _handle_resize(self, signum=None, frame=None):
183 """Tries to catch resize signals sent from the terminal.""" 190 """Tries to catch resize signals sent from the terminal."""
184 191
185 h, w = array('h', ioctl(self.fd, termios.TIOCGWINSZ, '\0' * 8))[:2] 192 h, w = array('h', ioctl(self._fd_console, termios.TIOCGWINSZ, '\0' * 8))[:2]
186 self.term_width = w 193 self.term_width = w
187 194
188 195