diff options
author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2015-11-06 17:25:08 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-11-25 08:08:08 +0000 |
commit | e864f71f4cc2e1cedfd36a8b9ab526fdb76fbb7d (patch) | |
tree | f4e58a9d31765984b4e4258f0965debb6b524445 | |
parent | 5056581b166b5ab61591557a655a647ba66332b3 (diff) | |
download | poky-e864f71f4cc2e1cedfd36a8b9ab526fdb76fbb7d.tar.gz |
terminal: Open a new window instead of split on older tmux versions (<1.9)
If an old version is detected (<1.9), create a new window instead of split:
the reason is that there is no easy way to get the active pane height if no
nested formats are supported.
(From OE-Core rev: 457bd6297ae99627c5f596c3c09086d787d5a5ab)
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oe/terminal.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py index 52a891388a..a4a8c97022 100644 --- a/meta/lib/oe/terminal.py +++ b/meta/lib/oe/terminal.py | |||
@@ -131,7 +131,7 @@ class TmuxRunning(Terminal): | |||
131 | raise UnsupportedTerminal('tmux is not running') | 131 | raise UnsupportedTerminal('tmux is not running') |
132 | 132 | ||
133 | if not check_tmux_pane_size('tmux'): | 133 | if not check_tmux_pane_size('tmux'): |
134 | raise UnsupportedTerminal('tmux pane too small') | 134 | raise UnsupportedTerminal('tmux pane too small or tmux < 1.9 version is being used') |
135 | 135 | ||
136 | Terminal.__init__(self, sh_cmd, title, env, d) | 136 | Terminal.__init__(self, sh_cmd, title, env, d) |
137 | 137 | ||
@@ -218,6 +218,12 @@ def spawn(name, sh_cmd, title=None, env=None, d=None): | |||
218 | 218 | ||
219 | def check_tmux_pane_size(tmux): | 219 | def check_tmux_pane_size(tmux): |
220 | import subprocess as sub | 220 | import subprocess as sub |
221 | # On older tmux versions (<1.9), return false. The reason | ||
222 | # is that there is no easy way to get the height of the active panel | ||
223 | # on current window without nested formats (available from version 1.9) | ||
224 | vernum = check_terminal_version("tmux") | ||
225 | if vernum and LooseVersion(vernum) < '1.9': | ||
226 | return False | ||
221 | try: | 227 | try: |
222 | p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux, | 228 | p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux, |
223 | shell=True,stdout=sub.PIPE,stderr=sub.PIPE) | 229 | shell=True,stdout=sub.PIPE,stderr=sub.PIPE) |
@@ -229,14 +235,16 @@ def check_tmux_pane_size(tmux): | |||
229 | return None | 235 | return None |
230 | else: | 236 | else: |
231 | raise | 237 | raise |
232 | if size/2 >= 19: | 238 | |
233 | return True | 239 | return size/2 >= 19 |
234 | return False | ||
235 | 240 | ||
236 | def check_terminal_version(terminalName): | 241 | def check_terminal_version(terminalName): |
237 | import subprocess as sub | 242 | import subprocess as sub |
238 | try: | 243 | try: |
239 | p = sub.Popen(['sh', '-c', '%s --version' % terminalName],stdout=sub.PIPE,stderr=sub.PIPE) | 244 | cmdversion = '%s --version' % terminalName |
245 | if terminalName.startswith('tmux'): | ||
246 | cmdversion = '%s -V' % terminalName | ||
247 | p = sub.Popen(['sh', '-c', cmdversion], stdout=sub.PIPE,stderr=sub.PIPE) | ||
240 | out, err = p.communicate() | 248 | out, err = p.communicate() |
241 | ver_info = out.rstrip().split('\n') | 249 | ver_info = out.rstrip().split('\n') |
242 | except OSError as exc: | 250 | except OSError as exc: |
@@ -251,6 +259,8 @@ def check_terminal_version(terminalName): | |||
251 | vernum = ver.split(' ')[-1] | 259 | vernum = ver.split(' ')[-1] |
252 | if ver.startswith('GNOME Terminal'): | 260 | if ver.startswith('GNOME Terminal'): |
253 | vernum = ver.split(' ')[-1] | 261 | vernum = ver.split(' ')[-1] |
262 | if ver.startswith('tmux'): | ||
263 | vernum = ver.split()[-1] | ||
254 | return vernum | 264 | return vernum |
255 | 265 | ||
256 | def distro_name(): | 266 | def distro_name(): |