blob: 538a633fe59ad09f42ad4a182f080fdc1ba39110 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#
2# BitBake Base Server Code
3#
4# Copyright (C) 2006 - 2007 Michael 'Mickey' Lauer
5# Copyright (C) 2006 - 2008 Richard Purdie
6# Copyright (C) 2013 Alexandru Damian
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
21""" Base code for Bitbake server process
22
23Have a common base for that all Bitbake server classes ensures a consistent
24approach to the interface, and minimize risks associated with code duplication.
25
26"""
27
28""" BaseImplServer() the base class for all XXServer() implementations.
29
30 These classes contain the actual code that runs the server side, i.e.
31 listens for the commands and executes them. Although these implementations
32 contain all the data of the original bitbake command, i.e the cooker instance,
33 they may well run on a different process or even machine.
34
35"""
36
37class BaseImplServer():
38 def __init__(self):
39 self._idlefuns = {}
40
41 def addcooker(self, cooker):
42 self.cooker = cooker
43
44 def register_idle_function(self, function, data):
45 """Register a function to be called while the server is idle"""
46 assert hasattr(function, '__call__')
47 self._idlefuns[function] = data
48
49
50
51""" BitBakeBaseServerConnection class is the common ancestor to all
52 BitBakeServerConnection classes.
53
54 These classes control the remote server. The only command currently
55 implemented is the terminate() command.
56
57"""
58
59class BitBakeBaseServerConnection():
60 def __init__(self, serverImpl):
61 pass
62
63 def terminate(self):
64 pass
65
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050066 def setupEventQueue(self):
67 pass
68
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069
70""" BitBakeBaseServer class is the common ancestor to all Bitbake servers
71
72 Derive this class in order to implement a BitBakeServer which is the
73 controlling stub for the actual server implementation
74
75"""
76class BitBakeBaseServer(object):
77 def initServer(self):
78 self.serverImpl = None # we ensure a runtime crash if not overloaded
79 self.connection = None
80 return
81
82 def addcooker(self, cooker):
83 self.cooker = cooker
84 self.serverImpl.addcooker(cooker)
85
86 def getServerIdleCB(self):
87 return self.serverImpl.register_idle_function
88
89 def saveConnectionDetails(self):
90 return
91
92 def detach(self):
93 return
94
95 def establishConnection(self, featureset):
96 raise "Must redefine the %s.establishConnection()" % self.__class__.__name__
97
98 def endSession(self):
99 self.connection.terminate()