diff options
| -rw-r--r-- | meta/lib/oe/terminal.py | 35 |
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 | |||
| 124 | class 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 | ||
| 121 | class Tmux(Terminal): | 139 | class 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 | ||
| 205 | def 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 | |||
| 187 | def check_konsole_version(konsole): | 222 | def check_konsole_version(konsole): |
| 188 | import subprocess as sub | 223 | import subprocess as sub |
| 189 | try: | 224 | try: |
