summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorDan McGregor <dan.mcgregor@usask.ca>2015-02-04 10:09:12 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-08 08:00:26 +0000
commit7c3b9a9a9fe0bcad7d7d3f0af84d6eb8546904f7 (patch)
tree0aea2ed7b6ec7b9901f6be00cc7f4fdd5f5ee76f /meta/lib
parentb7d91d30a59d591b96de5fad4a8fbf1f8158c40b (diff)
downloadpoky-7c3b9a9a9fe0bcad7d7d3f0af84d6eb8546904f7.tar.gz
terminal.py: add tmux new window option
Add a new terminal type that makes a new window in the running tmux session instead of splitting the window. 80x25 is not enough to run menuconfig inside a split window, so add the option to create a new window instead. Use the new window option by default when the split window would be less than 19 lines high. (From OE-Core rev: d7ef9e49b1c687279f6eb2c7abc32ff915714177) Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/terminal.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index 17d09045e4..54e3ffc1e8 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -116,6 +116,24 @@ class TmuxRunning(Terminal):
116 if not os.getenv('TMUX'): 116 if not os.getenv('TMUX'):
117 raise UnsupportedTerminal('tmux is not running') 117 raise UnsupportedTerminal('tmux is not running')
118 118
119 if not check_tmux_pane_size('tmux'):
120 raise UnsupportedTerminal('tmux pane too small')
121
122 Terminal.__init__(self, sh_cmd, title, env, d)
123
124class TmuxNewWindow(Terminal):
125 """Open a new window in the current running tmux session"""
126 name = 'tmux-new-window'
127 command = 'tmux new-window -n "{title}" "{command}"'
128 priority = 2.70
129
130 def __init__(self, sh_cmd, title=None, env=None, d=None):
131 if not bb.utils.which(os.getenv('PATH'), 'tmux'):
132 raise UnsupportedTerminal('tmux is not installed')
133
134 if not os.getenv('TMUX'):
135 raise UnsupportedTerminal('tmux is not running')
136
119 Terminal.__init__(self, sh_cmd, title, env, d) 137 Terminal.__init__(self, sh_cmd, title, env, d)
120 138
121class Tmux(Terminal): 139class Tmux(Terminal):
@@ -184,6 +202,23 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
184 if pipe.returncode != 0: 202 if pipe.returncode != 0:
185 raise ExecutionError(sh_cmd, pipe.returncode, output) 203 raise ExecutionError(sh_cmd, pipe.returncode, output)
186 204
205def check_tmux_pane_size(tmux):
206 import subprocess as sub
207 try:
208 p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux,
209 shell=True,stdout=sub.PIPE,stderr=sub.PIPE)
210 out, err = p.communicate()
211 size = int(out.strip())
212 except OSError as exc:
213 import errno
214 if exc.errno == errno.ENOENT:
215 return None
216 else:
217 raise
218 if size/2 >= 19:
219 return True
220 return False
221
187def check_konsole_version(konsole): 222def check_konsole_version(konsole):
188 import subprocess as sub 223 import subprocess as sub
189 try: 224 try: