summaryrefslogtreecommitdiff
path: root/meta/lib/oe/prservice.py
diff options
context:
space:
mode:
authorLianhao Lu <lianhao.lu@intel.com>2012-03-07 15:36:45 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-08 12:16:25 -0800
commit7588a4f2e2728da0ff7a773b18527f3711b138f2 (patch)
tree1a77d6734f425861e99139d6e6e2cad119e14334 /meta/lib/oe/prservice.py
parente27af1f273e9a7348dd8f5542df9206acd9210f3 (diff)
downloadopenembedded-core-7588a4f2e2728da0ff7a773b18527f3711b138f2.tar.gz
openembedded-core-7588a4f2e2728da0ff7a773b18527f3711b138f2.tar.bz2
openembedded-core-7588a4f2e2728da0ff7a773b18527f3711b138f2.zip
prservice: Added sanity check for prservice connection.
Fixed bug [YOCTO #2052]. Added sanity check for variables of PRSERV_HOST and PRSERV_PORT, also for the connection availabity of prservice. Signed-off-by: Lianhao Lu <lianhao.lu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/prservice.py')
-rw-r--r--meta/lib/oe/prservice.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/meta/lib/oe/prservice.py b/meta/lib/oe/prservice.py
index fa6718e914..16785ce83d 100644
--- a/meta/lib/oe/prservice.py
+++ b/meta/lib/oe/prservice.py
@@ -1,12 +1,15 @@
import bb
-def prserv_make_conn(d):
+def prserv_make_conn(d, check = False):
import prserv.serv
host = d.getVar("PRSERV_HOST",True)
port = d.getVar("PRSERV_PORT",True)
try:
conn = None
conn = prserv.serv.PRServerConnection(host,int(port))
+ if check:
+ if not conn.ping():
+ raise Exception('service not available')
d.setVar("__PRSERV_CONN",conn)
except Exception, exc:
bb.fatal("Connecting to PR service %s:%s failed: %s" % (host, port, str(exc)))
@@ -111,3 +114,16 @@ def prserv_export_tofile(d, metainfo, datainfo, lockdown, nomax=False):
f.write("PRAUTO_%s_%s = \"%s\"\n" % (str(datainfo[idx[i]]['version']),str(datainfo[idx[i]]['pkgarch']),str(datainfo[idx[i]]['value'])))
f.close()
bb.utils.unlockfile(lf)
+
+def prserv_check_avail(d):
+ host = d.getVar("PRSERV_HOST",True)
+ port = d.getVar("PRSERV_PORT",True)
+ try:
+ if not host:
+ raise TypeError
+ else:
+ port = int(port)
+ except TypeError:
+ bb.fatal("Undefined or incorrect values of PRSERV_HOST or PRSERV_PORT")
+ else:
+ prserv_make_conn(d, True)