[OE-core] [PATCH] terminal: Support old tmux version (<1.9) when querying height value

leonardo.sandoval.gonzalez at linux.intel.com leonardo.sandoval.gonzalez at linux.intel.com
Tue Nov 3 22:34:14 UTC 2015


From: Leonardo Sandoval <leonardo.sandoval.gonzalez at linux.intel.com>

Old tmux version (< 1.9) does not support nested formats on the -F parameter, so
if nested format does not give any answer, do the query in two steps.

Tested on tmux 1.6.

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez at linux.intel.com>
---
 meta/lib/oe/terminal.py |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index 52a8913..686b1ce 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -218,11 +218,24 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
 
 def check_tmux_pane_size(tmux):
     import subprocess as sub
+    size = 0
     try:
         p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux,
                 shell=True,stdout=sub.PIPE,stderr=sub.PIPE)
         out, err = p.communicate()
-        size = int(out.strip())
+        try:
+            size = int(out.strip())
+        except ValueError:
+            # Older tmux versions (< 1.9) does not support nested formats,
+            # so try it in two steps
+            p = sub.Popen('%s list-panes -F "#{?pane_active,yes,no}"' % tmux,
+                shell=True,stdout=sub.PIPE,stderr=sub.PIPE)
+            out, err = p.communicate()
+            if "yes" in out.strip():
+                p = sub.Popen('%s list-panes -F "#{pane_height}"' % tmux,
+                              shell=True,stdout=sub.PIPE,stderr=sub.PIPE)
+                out, err = p.communicate()
+                size = int(out.strip())
     except OSError as exc:
         import errno
         if exc.errno == errno.ENOENT:
-- 
1.7.10.4




More information about the Openembedded-core mailing list