summaryrefslogtreecommitdiffstats
path: root/bitbake-dev/lib/bb/ui/knotty.py
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2008-09-30 15:08:33 +0000
committerRichard Purdie <richard@openedhand.com>2008-09-30 15:08:33 +0000
commitc30eddb243e7e65f67f656e62848a033cf6f2e5c (patch)
tree110dd95788b76f55d31cb8d30aac2de8400b6f4a /bitbake-dev/lib/bb/ui/knotty.py
parent5ef0510474004eeb2ae8a99b64e2febb1920e077 (diff)
downloadpoky-c30eddb243e7e65f67f656e62848a033cf6f2e5c.tar.gz
Add bitbake-dev to allow ease of testing and development of bitbake trunk
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@5337 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake-dev/lib/bb/ui/knotty.py')
-rw-r--r--bitbake-dev/lib/bb/ui/knotty.py157
1 files changed, 157 insertions, 0 deletions
diff --git a/bitbake-dev/lib/bb/ui/knotty.py b/bitbake-dev/lib/bb/ui/knotty.py
new file mode 100644
index 0000000000..9e89660307
--- /dev/null
+++ b/bitbake-dev/lib/bb/ui/knotty.py
@@ -0,0 +1,157 @@
1#
2# BitBake (No)TTY UI Implementation
3#
4# Handling output to TTYs or files (no TTY)
5#
6# Copyright (C) 2006-2007 Richard Purdie
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License version 2 as
10# published by the Free Software Foundation.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program; if not, write to the Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21import os
22import bb
23from bb import cooker
24
25import sys
26import time
27import itertools
28import xmlrpclib
29
30parsespin = itertools.cycle( r'|/-\\' )
31
32def init(server, eventHandler):
33
34 # Get values of variables which control our output
35 includelogs = server.runCommand(["readVariable", "BBINCLUDELOGS"])
36 loglines = server.runCommand(["readVariable", "BBINCLUDELOGS_LINES"])
37
38 try:
39 cmdline = server.runCommand(["getCmdLineAction"])
40 #print cmdline
41 if not cmdline:
42 return 1
43 ret = server.runCommand(cmdline)
44 if ret != True:
45 print "Couldn't get default commandline! %s" % ret
46 return 1
47 except xmlrpclib.Fault, x:
48 print "XMLRPC Fault getting commandline:\n %s" % x
49 return 1
50
51 shutdown = 0
52 return_value = 0
53 while True:
54 try:
55 event = eventHandler.waitEvent(0.25)
56 if event is None:
57 continue
58 #print event
59 if event[0].startswith('bb.event.Pkg'):
60 print "NOTE: %s" % event[1]['_message']
61 continue
62 if event[0].startswith('bb.msg.MsgPlain'):
63 print event[1]['_message']
64 continue
65 if event[0].startswith('bb.msg.MsgDebug'):
66 print 'DEBUG: ' + event[1]['_message']
67 continue
68 if event[0].startswith('bb.msg.MsgNote'):
69 print 'NOTE: ' + event[1]['_message']
70 continue
71 if event[0].startswith('bb.msg.MsgWarn'):
72 print 'WARNING: ' + event[1]['_message']
73 continue
74 if event[0].startswith('bb.msg.MsgError'):
75 return_value = 1
76 print 'ERROR: ' + event[1]['_message']
77 continue
78 if event[0].startswith('bb.build.TaskFailed'):
79 return_value = 1
80 logfile = event[1]['logfile']
81 if logfile:
82 print "ERROR: Logfile of failure stored in %s." % logfile
83 if includelogs:
84 print "Log data follows:"
85 f = open(logfile, "r")
86 lines = []
87 while True:
88 l = f.readline()
89 if l == '':
90 break
91 l = l.rstrip()
92 if loglines:
93 lines.append(' | %s' % l)
94 if len(lines) > int(loglines):
95 lines.pop(0)
96 else:
97 print '| %s' % l
98 f.close()
99 if lines:
100 for line in lines:
101 print line
102 if event[0].startswith('bb.build.Task'):
103 print "NOTE: %s" % event[1]['_message']
104 continue
105 if event[0].startswith('bb.event.ParseProgress'):
106 x = event[1]['sofar']
107 y = event[1]['total']
108 if os.isatty(sys.stdout.fileno()):
109 sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) )
110 sys.stdout.flush()
111 else:
112 if x == 1:
113 sys.stdout.write("Parsing .bb files, please wait...")
114 sys.stdout.flush()
115 if x == y:
116 sys.stdout.write("done.")
117 sys.stdout.flush()
118 if x == y:
119 print("\nParsing finished. %d cached, %d parsed, %d skipped, %d masked, %d errors."
120 % ( event[1]['cached'], event[1]['parsed'], event[1]['skipped'], event[1]['masked'], event[1]['errors']))
121 continue
122
123 if event[0] == 'bb.command.CookerCommandCompleted':
124 break
125 if event[0] == 'bb.command.CookerCommandFailed':
126 return_value = 1
127 print "Command execution failed: %s" % event[1]['error']
128 break
129 if event[0] == 'bb.cooker.CookerExit':
130 break
131
132 # ignore
133 if event[0].startswith('bb.event.BuildStarted'):
134 continue
135 if event[0].startswith('bb.event.BuildCompleted'):
136 continue
137 if event[0].startswith('bb.event.MultipleProviders'):
138 continue
139 if event[0].startswith('bb.runqueue.runQueue'):
140 continue
141 if event[0].startswith('bb.event.StampUpdate'):
142 continue
143 print "Unknown Event: %s" % event
144
145 except KeyboardInterrupt:
146 if shutdown == 2:
147 print "\nThird Keyboard Interrupt, exit.\n"
148 break
149 if shutdown == 1:
150 print "\nSecond Keyboard Interrupt, stopping...\n"
151 server.runCommand(["stateStop"])
152 if shutdown == 0:
153 print "\nKeyboard Interrupt, closing down...\n"
154 server.runCommand(["stateShutdown"])
155 shutdown = shutdown + 1
156 pass
157 return return_value