* [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal
@ 2012-09-17 22:43 Jason Wessel
2012-09-17 22:43 ` [PATCH 1/4] progress.py: Fix traceback when running goggle ui Jason Wessel
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Jason Wessel @ 2012-09-17 22:43 UTC (permalink / raw)
To: bitbake-devel
This is a series of 4 patches, 2 for bitbake and 2 for oe-core. On
the bitbake side the idea is to have a new type of event which can
exec a command or print a log message if there is no controlling
terminal available.
When a controlling terminal is available the knotty UI can directly
execute the command on the controlling terminal, instead of printing
something, which occurs in all the other UI's. What is really nice
about this is that you don't have to spawn screen in separate
terminals when you only want to use a single terminal to a build
server.
--
lib/bb/event.py | 9 +++++++++
lib/bb/ui/crumbs/progress.py | 3 +++
lib/bb/ui/crumbs/runningbuild.py | 15 +++++++++++++++
lib/bb/ui/knotty.py | 19 +++++++++++++++++++
lib/bb/ui/ncurses.py | 2 ++
meta/classes/terminal.bbclass | 4 ++--
meta/lib/oe/terminal.py | 33 +++++++++++++++++++--------------
7 files changed, 69 insertions(+), 16 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] progress.py: Fix traceback when running goggle ui
2012-09-17 22:43 [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal Jason Wessel
@ 2012-09-17 22:43 ` Jason Wessel
2012-09-17 22:43 ` [PATCH 2/4] event.py, knotty.py, ncurses.py, runningbuild.py: Add support for LogExecTTY event Jason Wessel
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jason Wessel @ 2012-09-17 22:43 UTC (permalink / raw)
To: bitbake-devel
The following traceback appears when running the following command after the
devshell is exited.
bitbake -u goggle -c devshell busybox
-- traceback --
Traceback (most recent call last):
File "/work/bitbake/lib/bb/ui/goggle.py", line 35, in event_handle_idle_func
build.handle_event (event, pbar)
File "/work/bitbake/lib/bb/ui/crumbs/runningbuild.py", line 299, in handle_event
pbar.set_text(event.msg)
AttributeError: 'ProgressBar' object has no attribute 'set_text'
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
lib/bb/ui/crumbs/progress.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/bb/ui/crumbs/progress.py b/lib/bb/ui/crumbs/progress.py
index 0c7ad96..1d28a11 100644
--- a/lib/bb/ui/crumbs/progress.py
+++ b/lib/bb/ui/crumbs/progress.py
@@ -11,6 +11,9 @@ class ProgressBar(gtk.Dialog):
self.vbox.pack_start(self.progress)
self.show_all()
+ def set_text(self, msg):
+ self.progress.set_text(msg)
+
def update(self, x, y):
self.progress.set_fraction(float(x)/float(y))
self.progress.set_text("%2d %%" % (x*100/y))
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] event.py, knotty.py, ncurses.py, runningbuild.py: Add support for LogExecTTY event
2012-09-17 22:43 [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal Jason Wessel
2012-09-17 22:43 ` [PATCH 1/4] progress.py: Fix traceback when running goggle ui Jason Wessel
@ 2012-09-17 22:43 ` Jason Wessel
2012-09-17 22:43 ` [PATCH 3/4] terminal: pass data store all the way through to terminal class Jason Wessel
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jason Wessel @ 2012-09-17 22:43 UTC (permalink / raw)
To: bitbake-devel
The LogExecTTY even is intended to provide the ability to spawn a task
on a the controlling tty, if a tty is availble. When a controlling
tty is not availble the previous behavior is preserved where a warning
is issued about the action an end user must execute.
All the available UI's were tested against the new event type.
This feature is primarily intended for hooking up a screen client
session automatically on the controlling tty to allow for a more
streamlined end user experience when using a pure command line driven
environment. The changes that send the LogExecTTY event are in the
oe-core side.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
lib/bb/event.py | 9 +++++++++
lib/bb/ui/crumbs/runningbuild.py | 15 +++++++++++++++
lib/bb/ui/knotty.py | 19 +++++++++++++++++++
lib/bb/ui/ncurses.py | 2 ++
4 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/lib/bb/event.py b/lib/bb/event.py
index ab62d4d..e62f2f8 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -509,6 +509,15 @@ class MsgFatal(MsgBase):
class MsgPlain(MsgBase):
"""General output"""
+class LogExecTTY(Event):
+ """Send event containing program to spawn on tty of the logger"""
+ def __init__(self, msg, prog, sleep_delay, retries):
+ Event.__init__(self)
+ self.msg = msg
+ self.prog = prog
+ self.sleep_delay = sleep_delay
+ self.retries = retries
+
class LogHandler(logging.Handler):
"""Dispatch logging messages as bitbake events"""
diff --git a/lib/bb/ui/crumbs/runningbuild.py b/lib/bb/ui/crumbs/runningbuild.py
index a57d6db..700fd65 100644
--- a/lib/bb/ui/crumbs/runningbuild.py
+++ b/lib/bb/ui/crumbs/runningbuild.py
@@ -375,6 +375,21 @@ class RunningBuild (gobject.GObject):
msg += ("%s\n" % reason)
self.emit("no-provider", msg)
self.emit("log", msg)
+ elif isinstance(event, bb.event.LogExecTTY):
+ icon = "dialog-warning"
+ color = HobColors.WARNING
+ if self.sequential or not parent:
+ tree_add = self.model.append
+ else:
+ tree_add = self.model.prepend
+ tree_add(parent,
+ (None,
+ package,
+ task,
+ event.msg,
+ icon,
+ color,
+ 0))
else:
if not isinstance(event, (bb.event.BuildBase,
bb.event.StampUpdate,
diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index 858cacf..d81ad5d 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -27,6 +27,7 @@ import logging
import progressbar
import signal
import bb.msg
+import time
import fcntl
import struct
import copy
@@ -216,6 +217,10 @@ def main(server, eventHandler, tf = TerminalFilter):
includelogs = server.runCommand(["getVariable", "BBINCLUDELOGS"])
loglines = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"])
consolelogfile = server.runCommand(["getVariable", "BB_CONSOLELOG"])
+ if sys.stdin.isatty() and sys.stdout.isatty():
+ log_exec_tty = True
+ else:
+ log_exec_tty = False
helper = uihelper.BBUIHelper()
@@ -271,6 +276,20 @@ def main(server, eventHandler, tf = TerminalFilter):
if not main.shutdown:
main.shutdown = 1
+ if isinstance(event, bb.event.LogExecTTY):
+ if log_exec_tty:
+ tries = event.retries
+ while tries:
+ print "Trying to run: %s" % event.prog
+ if os.system(event.prog) == 0:
+ break
+ time.sleep(event.sleep_delay)
+ tries -= 1
+ if tries:
+ continue
+ logger.warn(event.msg)
+ continue
+
if isinstance(event, logging.LogRecord):
if event.levelno >= format.ERROR:
errors = errors + 1
diff --git a/lib/bb/ui/ncurses.py b/lib/bb/ui/ncurses.py
index f573b95..f6ea7f9 100644
--- a/lib/bb/ui/ncurses.py
+++ b/lib/bb/ui/ncurses.py
@@ -318,6 +318,8 @@ class NCursesUI:
if isinstance(event, bb.cooker.CookerExit):
exitflag = True
+ if isinstance(event, bb.event.LogExecTTY):
+ mw.appendText('WARN: ' + event.msg + '\n')
if helper.needUpdate:
activetasks, failedtasks = helper.getTasks()
taw.erase()
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] terminal: pass data store all the way through to terminal class
2012-09-17 22:43 [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal Jason Wessel
2012-09-17 22:43 ` [PATCH 1/4] progress.py: Fix traceback when running goggle ui Jason Wessel
2012-09-17 22:43 ` [PATCH 2/4] event.py, knotty.py, ncurses.py, runningbuild.py: Add support for LogExecTTY event Jason Wessel
@ 2012-09-17 22:43 ` Jason Wessel
2012-09-17 22:43 ` [PATCH 4/4] terminal: Send LogExecTTY event to spawn screen Jason Wessel
2012-09-24 14:32 ` [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal Richard Purdie
4 siblings, 0 replies; 6+ messages in thread
From: Jason Wessel @ 2012-09-17 22:43 UTC (permalink / raw)
To: bitbake-devel
Passing the data store will be needed for firing a custom event
for the screen class.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
meta/classes/terminal.bbclass | 4 ++--
meta/lib/oe/terminal.py | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass
index 3cfc84b..2cd6f4c 100644
--- a/meta/classes/terminal.bbclass
+++ b/meta/classes/terminal.bbclass
@@ -25,7 +25,7 @@ def oe_terminal(command, title, d):
bb.fatal('Devshell usage disabled with OE_TERMINAL')
elif terminal != 'auto':
try:
- oe.terminal.spawn(terminal, command, title)
+ oe.terminal.spawn(terminal, command, title, None, d)
return
except oe.terminal.UnsupportedTerminal:
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))
try:
- oe.terminal.spawn_preferred(command, title)
+ oe.terminal.spawn_preferred(command, title, None, d)
except oe.terminal.NoSupportedTerminals:
bb.fatal('No valid terminal found, unable to open devshell')
except oe.terminal.ExecutionError as exc:
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index d66309f..c71d6ad 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -28,7 +28,7 @@ class Registry(oe.classutils.ClassRegistry):
class Terminal(Popen):
__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)
try:
Popen.__init__(self, fmt_sh_cmd, env=env)
@@ -47,7 +47,7 @@ class Terminal(Popen):
return [element.format(**fmt) for element in self.command]
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)
if not os.environ.get('DISPLAY'):
raise UnsupportedTerminal(self.name)
@@ -60,7 +60,7 @@ class Xfce(XTerminal):
command = 'Terminal -T "{title}" -e "{command}"'
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
# xfce4-terminal to avoid possible(?) conflicts
distro = distro_name()
@@ -68,20 +68,20 @@ class Xfce(XTerminal):
cmd = 'xfce4-terminal -T "{title}" -e "{command}"'
else:
cmd = command
- XTerminal.__init__(self, cmd, title, env)
+ XTerminal.__init__(self, cmd, title, env, d)
class Konsole(XTerminal):
command = 'konsole -T "{title}" -e {command}'
priority = 2
- def __init__(self, sh_cmd, title=None, env=None):
+ def __init__(self, sh_cmd, title=None, env=None, d=None):
# Check version
vernum = check_konsole_version("konsole")
if vernum:
if vernum.split('.')[0] == "2":
logger.debug(1, 'Konsole from KDE 4.x will not work as devshell, skipping')
raise UnsupportedTerminal(self.name)
- XTerminal.__init__(self, sh_cmd, title, env)
+ XTerminal.__init__(self, sh_cmd, title, env, d)
class XTerm(XTerminal):
command = 'xterm -T "{title}" -e {command}'
@@ -94,7 +94,7 @@ class Rxvt(XTerminal):
class Screen(Terminal):
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()
self.command = "screen -D -m -t \"{title}\" -S %s {command}" % s_id
Terminal.__init__(self, sh_cmd, title, env)
@@ -105,18 +105,18 @@ class Screen(Terminal):
def 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"""
for terminal in prioritized():
try:
- spawn(terminal.name, sh_cmd, title, env)
+ spawn(terminal.name, sh_cmd, title, env, d)
break
except UnsupportedTerminal:
continue
else:
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"""
logger.debug(1, 'Attempting to spawn terminal "%s"', name)
try:
@@ -124,7 +124,7 @@ def spawn(name, sh_cmd, title=None, env=None):
except KeyError:
raise UnsupportedTerminal(name)
- pipe = terminal(sh_cmd, title, env)
+ pipe = terminal(sh_cmd, title, env, d)
output = pipe.communicate()[0]
if pipe.returncode != 0:
raise ExecutionError(sh_cmd, pipe.returncode, output)
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] terminal: Send LogExecTTY event to spawn screen
2012-09-17 22:43 [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal Jason Wessel
` (2 preceding siblings ...)
2012-09-17 22:43 ` [PATCH 3/4] terminal: pass data store all the way through to terminal class Jason Wessel
@ 2012-09-17 22:43 ` Jason Wessel
2012-09-24 14:32 ` [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal Richard Purdie
4 siblings, 0 replies; 6+ messages in thread
From: Jason Wessel @ 2012-09-17 22:43 UTC (permalink / raw)
To: bitbake-devel
Bitbake has the ability to request to run a command
and if it is not possible fall back to emitting a
log message. This can be used to start a screen
client automatically on the controling tty if
the UI has an interactive tty.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
meta/lib/oe/terminal.py | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index c71d6ad..1e74315 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -97,9 +97,14 @@ class Screen(Terminal):
def __init__(self, sh_cmd, title=None, env=None, d=None):
s_id = "devshell_%i" % os.getpid()
self.command = "screen -D -m -t \"{title}\" -S %s {command}" % s_id
- Terminal.__init__(self, sh_cmd, title, env)
- logger.warn('Screen started. Please connect in another terminal with '
- '"screen -r devshell %s"' % s_id)
+ Terminal.__init__(self, sh_cmd, title, env, d)
+ msg = 'Screen started. Please connect in another terminal with ' \
+ '"screen -r %s"' % s_id
+ if (d):
+ bb.event.fire(bb.event.LogExecTTY(msg, "screen -r %s" % s_id,
+ 0.5, 10), d)
+ else:
+ logger.warn(msg)
def prioritized():
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal
2012-09-17 22:43 [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal Jason Wessel
` (3 preceding siblings ...)
2012-09-17 22:43 ` [PATCH 4/4] terminal: Send LogExecTTY event to spawn screen Jason Wessel
@ 2012-09-24 14:32 ` Richard Purdie
4 siblings, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2012-09-24 14:32 UTC (permalink / raw)
To: Jason Wessel; +Cc: bitbake-devel
On Mon, 2012-09-17 at 17:43 -0500, Jason Wessel wrote:
> This is a series of 4 patches, 2 for bitbake and 2 for oe-core. On
> the bitbake side the idea is to have a new type of event which can
> exec a command or print a log message if there is no controlling
> terminal available.
>
> When a controlling terminal is available the knotty UI can directly
> execute the command on the controlling terminal, instead of printing
> something, which occurs in all the other UI's. What is really nice
> about this is that you don't have to spawn screen in separate
> terminals when you only want to use a single terminal to a build
> server.
Merged to master, thanks.
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-09-24 14:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17 22:43 [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal Jason Wessel
2012-09-17 22:43 ` [PATCH 1/4] progress.py: Fix traceback when running goggle ui Jason Wessel
2012-09-17 22:43 ` [PATCH 2/4] event.py, knotty.py, ncurses.py, runningbuild.py: Add support for LogExecTTY event Jason Wessel
2012-09-17 22:43 ` [PATCH 3/4] terminal: pass data store all the way through to terminal class Jason Wessel
2012-09-17 22:43 ` [PATCH 4/4] terminal: Send LogExecTTY event to spawn screen Jason Wessel
2012-09-24 14:32 ` [PATCH 0/4] Add ability to auto spawn screen on a controlling terminal Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.