summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-02 15:46:11 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-07 16:14:33 +0100
commit5e0124f00d4e50dd84f988b1d8c4ff40b0e1b371 (patch)
treef6882364f45c121c584ddfcd0abbb4a09fa4b547
parent2806646a263527ec0487ea160afd4bdc0a3c1703 (diff)
downloadpoky-5e0124f00d4e50dd84f988b1d8c4ff40b0e1b371.tar.gz
bitbake: prserv/cooker: Handle PRService errors cleanly
Current if the PR Service fails to start, bitbake carries on regardless or hangs with no error message. This adds an exception and then handles it correctly so the UIs correctly handle the error and exit cleanly. [YOCTO #4010] (Bitbake rev: 9c52c73fd2498e65be5f0da24dc2ae3803eb42eb) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/cooker.py5
-rw-r--r--bitbake/lib/prserv/serv.py9
2 files changed, 10 insertions, 4 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 7ca1ffdd94..c39d522c47 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1353,7 +1353,10 @@ class BBCooker:
1353 # Empty the environment. The environment will be populated as 1353 # Empty the environment. The environment will be populated as
1354 # necessary from the data store. 1354 # necessary from the data store.
1355 #bb.utils.empty_environment() 1355 #bb.utils.empty_environment()
1356 prserv.serv.auto_start(self.configuration.data) 1356 try:
1357 prserv.serv.auto_start(self.configuration.data)
1358 except prserv.serv.PRServiceConfigError:
1359 bb.event.fire(CookerExit(), self.configuration.event_data)
1357 return 1360 return
1358 1361
1359 def post_serve(self): 1362 def post_serve(self):
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 5567c6f574..316512d7ac 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -266,17 +266,20 @@ def is_local_special(host, port):
266 else: 266 else:
267 return False 267 return False
268 268
269class PRServiceConfigError(Exception):
270 pass
271
269def auto_start(d): 272def auto_start(d):
270 global singleton 273 global singleton
271 if (not d.getVar('PRSERV_HOST', True)) or (not d.getVar('PRSERV_PORT', True)): 274 if (not d.getVar('PRSERV_HOST', True)) or (not d.getVar('PRSERV_PORT', True)):
272 return True 275 return
273 276
274 if is_local_special(d.getVar('PRSERV_HOST', True), int(d.getVar('PRSERV_PORT', True))) and not singleton: 277 if is_local_special(d.getVar('PRSERV_HOST', True), int(d.getVar('PRSERV_PORT', True))) and not singleton:
275 import bb.utils 278 import bb.utils
276 cachedir = (d.getVar("PERSISTENT_DIR", True) or d.getVar("CACHE", True)) 279 cachedir = (d.getVar("PERSISTENT_DIR", True) or d.getVar("CACHE", True))
277 if not cachedir: 280 if not cachedir:
278 logger.critical("Please set the 'PERSISTENT_DIR' or 'CACHE' variable") 281 logger.critical("Please set the 'PERSISTENT_DIR' or 'CACHE' variable")
279 sys.exit(1) 282 raise PRServiceConfigError
280 bb.utils.mkdirhier(cachedir) 283 bb.utils.mkdirhier(cachedir)
281 dbfile = os.path.join(cachedir, "prserv.sqlite3") 284 dbfile = os.path.join(cachedir, "prserv.sqlite3")
282 logfile = os.path.join(cachedir, "prserv.log") 285 logfile = os.path.join(cachedir, "prserv.log")
@@ -292,7 +295,7 @@ def auto_start(d):
292 return PRServerConnection(host,port).ping() 295 return PRServerConnection(host,port).ping()
293 except Exception: 296 except Exception:
294 logger.critical("PRservice %s:%d not available" % (host, port)) 297 logger.critical("PRservice %s:%d not available" % (host, port))
295 return False 298 raise PRServiceConfigError
296 299
297def auto_shutdown(d=None): 300def auto_shutdown(d=None):
298 global singleton 301 global singleton