summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbitbake/bin/bitbake6
-rw-r--r--bitbake/lib/bb/server/none.py203
2 files changed, 3 insertions, 206 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index ac35b94e3b..a868557a1a 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -167,7 +167,7 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
167 parser.add_option("-u", "--ui", help = "userinterface to use", 167 parser.add_option("-u", "--ui", help = "userinterface to use",
168 action = "store", dest = "ui") 168 action = "store", dest = "ui")
169 169
170 parser.add_option("-t", "--servertype", help = "Choose which server to use, none, process or xmlrpc", 170 parser.add_option("-t", "--servertype", help = "Choose which server to use, process or xmlrpc",
171 action = "store", dest = "servertype") 171 action = "store", dest = "servertype")
172 172
173 parser.add_option("", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not", 173 parser.add_option("", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not",
@@ -191,7 +191,7 @@ def main():
191 191
192 ui_main = get_ui(configuration) 192 ui_main = get_ui(configuration)
193 193
194 # Server type can be xmlrpc, process or none currently, if nothing is specified, 194 # Server type can be xmlrpc or process currently, if nothing is specified,
195 # the default server is process 195 # the default server is process
196 if configParams.servertype: 196 if configParams.servertype:
197 server_type = configParams.servertype 197 server_type = configParams.servertype
@@ -203,7 +203,7 @@ def main():
203 server = getattr(module, server_type) 203 server = getattr(module, server_type)
204 except AttributeError: 204 except AttributeError:
205 sys.exit("FATAL: Invalid server type '%s' specified.\n" 205 sys.exit("FATAL: Invalid server type '%s' specified.\n"
206 "Valid interfaces: xmlrpc, process [default], none." % servertype) 206 "Valid interfaces: xmlrpc, process [default]." % servertype)
207 207
208 if configParams.server_only: 208 if configParams.server_only:
209 if configParams.servertype != "xmlrpc": 209 if configParams.servertype != "xmlrpc":
diff --git a/bitbake/lib/bb/server/none.py b/bitbake/lib/bb/server/none.py
deleted file mode 100644
index f5fd4d4f7b..0000000000
--- a/bitbake/lib/bb/server/none.py
+++ /dev/null
@@ -1,203 +0,0 @@
1#
2# BitBake 'dummy' Passthrough Server
3#
4# Copyright (C) 2006 - 2007 Michael 'Mickey' Lauer
5# Copyright (C) 2006 - 2008 Richard Purdie
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 2 as
9# published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20"""
21 This module implements a passthrough server for BitBake.
22
23 Use register_idle_function() to add a function which the server
24 calls from within idle_commands when no requests are pending. Make sure
25 that those functions are non-blocking or else you will introduce latency
26 in the server's main loop.
27"""
28
29import time
30import bb
31import signal
32
33DEBUG = False
34
35import inspect, select
36
37class BitBakeServerCommands():
38 def __init__(self, server):
39 self.server = server
40
41 def runCommand(self, command):
42 """
43 Run a cooker command on the server
44 """
45 #print "Running Command %s" % command
46 return self.cooker.command.runCommand(command)
47
48 def terminateServer(self):
49 """
50 Trigger the server to quit
51 """
52 self.server.server_exit()
53 #print "Server (cooker) exitting"
54 return
55
56 def ping(self):
57 """
58 Dummy method which can be used to check the server is still alive
59 """
60 return True
61
62eventQueue = []
63
64class BBUIEventQueue:
65 class event:
66 def __init__(self, parent):
67 self.parent = parent
68 @staticmethod
69 def send(event):
70 bb.server.none.eventQueue.append(event)
71 @staticmethod
72 def quit():
73 return
74
75 def __init__(self, BBServer):
76 self.eventQueue = bb.server.none.eventQueue
77 self.BBServer = BBServer
78 self.EventHandle = bb.event.register_UIHhandler(self)
79
80 def __popEvent(self):
81 if len(self.eventQueue) == 0:
82 return None
83 return self.eventQueue.pop(0)
84
85 def getEvent(self):
86 if len(self.eventQueue) == 0:
87 self.BBServer.idle_commands(0)
88 return self.__popEvent()
89
90 def waitEvent(self, delay):
91 event = self.__popEvent()
92 if event:
93 return event
94 self.BBServer.idle_commands(delay)
95 return self.__popEvent()
96
97 def queue_event(self, event):
98 self.eventQueue.append(event)
99
100 def system_quit( self ):
101 bb.event.unregister_UIHhandler(self.EventHandle)
102
103# Dummy signal handler to ensure we break out of sleep upon SIGCHLD
104def chldhandler(signum, stackframe):
105 pass
106
107class BitBakeNoneServer():
108 # remove this when you're done with debugging
109 # allow_reuse_address = True
110
111 def __init__(self):
112 self._idlefuns = {}
113 self.commands = BitBakeServerCommands(self)
114
115 def addcooker(self, cooker):
116 self.cooker = cooker
117 self.commands.cooker = cooker
118
119 def register_idle_function(self, function, data):
120 """Register a function to be called while the server is idle"""
121 assert hasattr(function, '__call__')
122 self._idlefuns[function] = data
123
124 def idle_commands(self, delay):
125 #print "Idle queue length %s" % len(self._idlefuns)
126 #print "Idle timeout, running idle functions"
127 #if len(self._idlefuns) == 0:
128 nextsleep = delay
129 for function, data in self._idlefuns.items():
130 try:
131 retval = function(self, data, False)
132 #print "Idle function returned %s" % (retval)
133 if retval is False:
134 del self._idlefuns[function]
135 elif retval is True:
136 nextsleep = None
137 elif nextsleep is None:
138 continue
139 elif retval < nextsleep:
140 nextsleep = retval
141 except SystemExit:
142 raise
143 except:
144 import traceback
145 traceback.print_exc()
146 self.commands.runCommand(["stateShutdown"])
147 pass
148 if nextsleep is not None:
149 #print "Sleeping for %s (%s)" % (nextsleep, delay)
150 signal.signal(signal.SIGCHLD, chldhandler)
151 time.sleep(nextsleep)
152 signal.signal(signal.SIGCHLD, signal.SIG_DFL)
153
154 def server_exit(self):
155 # Tell idle functions we're exiting
156 for function, data in self._idlefuns.items():
157 try:
158 retval = function(self, data, True)
159 except:
160 pass
161
162class BitBakeServerConnection():
163 def __init__(self, server):
164 self.server = server.server
165 self.connection = self.server.commands
166 self.events = bb.server.none.BBUIEventQueue(self.server)
167 for event in bb.event.ui_queue:
168 self.events.queue_event(event)
169
170 def terminate(self):
171 try:
172 self.events.system_quit()
173 except:
174 pass
175 try:
176 self.connection.terminateServer()
177 except:
178 pass
179
180class BitBakeServer(object):
181 def initServer(self):
182 self.server = BitBakeNoneServer()
183
184 def addcooker(self, cooker):
185 self.cooker = cooker
186 self.server.addcooker(cooker)
187
188 def getServerIdleCB(self):
189 return self.server.register_idle_function
190
191 def saveConnectionDetails(self):
192 return
193
194 def detach(self):
195 return
196
197 def establishConnection(self):
198 self.connection = BitBakeServerConnection(self)
199 return self.connection
200
201 def launchUI(self, uifunc, *args):
202 return bb.cooker.server_main(self.cooker, uifunc, *args)
203