1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

terminal: pass data store all the way through to terminal class

Passing the data store will be needed for firing a custom event
for the screen class.

(From OE-Core rev: 5ccff8d44626bfd3d1af2a7f81f0567997277809)

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Jason Wessel
2012-09-17 17:43:50 -05:00
committed by Richard Purdie
parent e1c1ee19e0
commit 6e0713a3e7
2 changed files with 13 additions and 13 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ def oe_terminal(command, title, d):
bb.fatal('Devshell usage disabled with OE_TERMINAL') bb.fatal('Devshell usage disabled with OE_TERMINAL')
elif terminal != 'auto': elif terminal != 'auto':
try: try:
oe.terminal.spawn(terminal, command, title) oe.terminal.spawn(terminal, command, title, None, d)
return return
except oe.terminal.UnsupportedTerminal: except oe.terminal.UnsupportedTerminal:
bb.warn('Unsupported terminal "%s", defaulting to "auto"' % bb.warn('Unsupported terminal "%s", defaulting to "auto"' %
@@ -34,7 +34,7 @@ def oe_terminal(command, title, d):
bb.fatal('Unable to spawn terminal %s: %s' % (terminal, exc)) bb.fatal('Unable to spawn terminal %s: %s' % (terminal, exc))
try: try:
oe.terminal.spawn_preferred(command, title) oe.terminal.spawn_preferred(command, title, None, d)
except oe.terminal.NoSupportedTerminals: except oe.terminal.NoSupportedTerminals:
bb.fatal('No valid terminal found, unable to open devshell') bb.fatal('No valid terminal found, unable to open devshell')
except oe.terminal.ExecutionError as exc: except oe.terminal.ExecutionError as exc:
+11 -11
View File
@@ -27,7 +27,7 @@ class Registry(oe.classutils.ClassRegistry):
class Terminal(Popen): class Terminal(Popen):
__metaclass__ = Registry __metaclass__ = Registry
def __init__(self, sh_cmd, title=None, env=None): def __init__(self, sh_cmd, title=None, env=None, d=None):
fmt_sh_cmd = self.format_command(sh_cmd, title) fmt_sh_cmd = self.format_command(sh_cmd, title)
try: try:
Popen.__init__(self, fmt_sh_cmd, env=env) Popen.__init__(self, fmt_sh_cmd, env=env)
@@ -46,7 +46,7 @@ class Terminal(Popen):
return [element.format(**fmt) for element in self.command] return [element.format(**fmt) for element in self.command]
class XTerminal(Terminal): class XTerminal(Terminal):
def __init__(self, sh_cmd, title=None, env=None): def __init__(self, sh_cmd, title=None, env=None, d=None):
Terminal.__init__(self, sh_cmd, title, env) Terminal.__init__(self, sh_cmd, title, env)
if not os.environ.get('DISPLAY'): if not os.environ.get('DISPLAY'):
raise UnsupportedTerminal(self.name) raise UnsupportedTerminal(self.name)
@@ -59,7 +59,7 @@ class Xfce(XTerminal):
command = 'Terminal -T "{title}" -e "{command}"' command = 'Terminal -T "{title}" -e "{command}"'
priority = 2 priority = 2
def __init__(self, command, title=None, env=None): def __init__(self, command, title=None, env=None, d=None):
# Upstream binary name is Terminal but Debian/Ubuntu use # Upstream binary name is Terminal but Debian/Ubuntu use
# xfce4-terminal to avoid possible(?) conflicts # xfce4-terminal to avoid possible(?) conflicts
distro = distro_name() distro = distro_name()
@@ -67,20 +67,20 @@ class Xfce(XTerminal):
cmd = 'xfce4-terminal -T "{title}" -e "{command}"' cmd = 'xfce4-terminal -T "{title}" -e "{command}"'
else: else:
cmd = command cmd = command
XTerminal.__init__(self, cmd, title, env) XTerminal.__init__(self, cmd, title, env, d)
class Konsole(XTerminal): class Konsole(XTerminal):
command = 'konsole -T "{title}" -e {command}' command = 'konsole -T "{title}" -e {command}'
priority = 2 priority = 2
def __init__(self, sh_cmd, title=None, env=None): def __init__(self, sh_cmd, title=None, env=None, d=None):
# Check version # Check version
vernum = check_konsole_version("konsole") vernum = check_konsole_version("konsole")
if vernum: if vernum:
if vernum.split('.')[0] == "2": if vernum.split('.')[0] == "2":
logger.debug(1, 'Konsole from KDE 4.x will not work as devshell, skipping') logger.debug(1, 'Konsole from KDE 4.x will not work as devshell, skipping')
raise UnsupportedTerminal(self.name) raise UnsupportedTerminal(self.name)
XTerminal.__init__(self, sh_cmd, title, env) XTerminal.__init__(self, sh_cmd, title, env, d)
class XTerm(XTerminal): class XTerm(XTerminal):
command = 'xterm -T "{title}" -e {command}' command = 'xterm -T "{title}" -e {command}'
@@ -93,7 +93,7 @@ class Rxvt(XTerminal):
class Screen(Terminal): class Screen(Terminal):
command = 'screen -D -m -t "{title}" -S devshell {command}' command = 'screen -D -m -t "{title}" -S devshell {command}'
def __init__(self, sh_cmd, title=None, env=None): def __init__(self, sh_cmd, title=None, env=None, d=None):
s_id = "devshell_%i" % os.getpid() s_id = "devshell_%i" % os.getpid()
self.command = "screen -D -m -t \"{title}\" -S %s {command}" % s_id self.command = "screen -D -m -t \"{title}\" -S %s {command}" % s_id
Terminal.__init__(self, sh_cmd, title, env) Terminal.__init__(self, sh_cmd, title, env)
@@ -104,18 +104,18 @@ class Screen(Terminal):
def prioritized(): def prioritized():
return Registry.prioritized() return Registry.prioritized()
def spawn_preferred(sh_cmd, title=None, env=None): def spawn_preferred(sh_cmd, title=None, env=None, d=None):
"""Spawn the first supported terminal, by priority""" """Spawn the first supported terminal, by priority"""
for terminal in prioritized(): for terminal in prioritized():
try: try:
spawn(terminal.name, sh_cmd, title, env) spawn(terminal.name, sh_cmd, title, env, d)
break break
except UnsupportedTerminal: except UnsupportedTerminal:
continue continue
else: else:
raise NoSupportedTerminals() raise NoSupportedTerminals()
def spawn(name, sh_cmd, title=None, env=None): def spawn(name, sh_cmd, title=None, env=None, d=None):
"""Spawn the specified terminal, by name""" """Spawn the specified terminal, by name"""
logger.debug(1, 'Attempting to spawn terminal "%s"', name) logger.debug(1, 'Attempting to spawn terminal "%s"', name)
try: try:
@@ -123,7 +123,7 @@ def spawn(name, sh_cmd, title=None, env=None):
except KeyError: except KeyError:
raise UnsupportedTerminal(name) raise UnsupportedTerminal(name)
pipe = terminal(sh_cmd, title, env) pipe = terminal(sh_cmd, title, env, d)
output = pipe.communicate()[0] output = pipe.communicate()[0]
if pipe.returncode != 0: if pipe.returncode != 0:
raise ExecutionError(sh_cmd, pipe.returncode, output) raise ExecutionError(sh_cmd, pipe.returncode, output)