summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/terminal.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/terminal.py')
-rw-r--r--meta/lib/oe/terminal.py58
1 files changed, 30 insertions, 28 deletions
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index 0426e15834..3c6220dfce 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -62,28 +62,7 @@ class Gnome(XTerminal):
62 # Once fixed on the gnome-terminal project, this should be removed. 62 # Once fixed on the gnome-terminal project, this should be removed.
63 if os.getenv('LC_ALL'): os.putenv('LC_ALL','') 63 if os.getenv('LC_ALL'): os.putenv('LC_ALL','')
64 64
65 # We need to know when the command completes but gnome-terminal gives us no way 65 XTerminal.__init__(self, sh_cmd, title, env, d)
66 # to do this. We therefore write the pid to a file using a "phonehome" wrapper
67 # script, then monitor the pid until it exits. Thanks gnome!
68 import tempfile
69 pidfile = tempfile.NamedTemporaryFile(delete = False).name
70 try:
71 sh_cmd = "oe-gnome-terminal-phonehome " + pidfile + " " + sh_cmd
72 XTerminal.__init__(self, sh_cmd, title, env, d)
73 while os.stat(pidfile).st_size <= 0:
74 continue
75 with open(pidfile, "r") as f:
76 pid = int(f.readline())
77 finally:
78 os.unlink(pidfile)
79
80 import time
81 while True:
82 try:
83 os.kill(pid, 0)
84 time.sleep(0.1)
85 except OSError:
86 return
87 66
88class Mate(XTerminal): 67class Mate(XTerminal):
89 command = 'mate-terminal -t "{title}" -x {command}' 68 command = 'mate-terminal -t "{title}" -x {command}'
@@ -237,12 +216,35 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
237 except KeyError: 216 except KeyError:
238 raise UnsupportedTerminal(name) 217 raise UnsupportedTerminal(name)
239 218
240 pipe = terminal(sh_cmd, title, env, d) 219 # We need to know when the command completes but some terminals (at least
241 output = pipe.communicate()[0] 220 # gnome and tmux) gives us no way to do this. We therefore write the pid
242 if output: 221 # to a file using a "phonehome" wrapper script, then monitor the pid
243 output = output.decode("utf-8") 222 # until it exits.
244 if pipe.returncode != 0: 223 import tempfile
245 raise ExecutionError(sh_cmd, pipe.returncode, output) 224 pidfile = tempfile.NamedTemporaryFile(delete = False).name
225 try:
226 sh_cmd = "oe-gnome-terminal-phonehome " + pidfile + " " + sh_cmd
227 pipe = terminal(sh_cmd, title, env, d)
228 output = pipe.communicate()[0]
229 if output:
230 output = output.decode("utf-8")
231 if pipe.returncode != 0:
232 raise ExecutionError(sh_cmd, pipe.returncode, output)
233
234 while os.stat(pidfile).st_size <= 0:
235 continue
236 with open(pidfile, "r") as f:
237 pid = int(f.readline())
238 finally:
239 os.unlink(pidfile)
240
241 import time
242 while True:
243 try:
244 os.kill(pid, 0)
245 time.sleep(0.1)
246 except OSError:
247 return
246 248
247def check_tmux_pane_size(tmux): 249def check_tmux_pane_size(tmux):
248 import subprocess as sub 250 import subprocess as sub