From 5e0124f00d4e50dd84f988b1d8c4ff40b0e1b371 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 2 May 2013 15:46:11 +0100 Subject: 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 --- bitbake/lib/bb/cooker.py | 5 ++++- bitbake/lib/prserv/serv.py | 9 ++++++--- 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: # Empty the environment. The environment will be populated as # necessary from the data store. #bb.utils.empty_environment() - prserv.serv.auto_start(self.configuration.data) + try: + prserv.serv.auto_start(self.configuration.data) + except prserv.serv.PRServiceConfigError: + bb.event.fire(CookerExit(), self.configuration.event_data) return 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): else: return False +class PRServiceConfigError(Exception): + pass + def auto_start(d): global singleton if (not d.getVar('PRSERV_HOST', True)) or (not d.getVar('PRSERV_PORT', True)): - return True + return if is_local_special(d.getVar('PRSERV_HOST', True), int(d.getVar('PRSERV_PORT', True))) and not singleton: import bb.utils cachedir = (d.getVar("PERSISTENT_DIR", True) or d.getVar("CACHE", True)) if not cachedir: logger.critical("Please set the 'PERSISTENT_DIR' or 'CACHE' variable") - sys.exit(1) + raise PRServiceConfigError bb.utils.mkdirhier(cachedir) dbfile = os.path.join(cachedir, "prserv.sqlite3") logfile = os.path.join(cachedir, "prserv.log") @@ -292,7 +295,7 @@ def auto_start(d): return PRServerConnection(host,port).ping() except Exception: logger.critical("PRservice %s:%d not available" % (host, port)) - return False + raise PRServiceConfigError def auto_shutdown(d=None): global singleton -- cgit v1.2.3-54-g00ecf