diff options
author | Lianhao Lu <lianhao.lu@intel.com> | 2012-03-07 15:36:45 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-08 12:16:29 -0800 |
commit | e189a7113ca44eb202d1da8139678ba9729286b4 (patch) | |
tree | 2009f03c5dfea00cba3067b3f18cb066772b4c15 /meta/lib/oe/prservice.py | |
parent | 10d6c4e056b4c3333f15e442af4283c99e5951e2 (diff) | |
download | poky-e189a7113ca44eb202d1da8139678ba9729286b4.tar.gz |
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.
(From OE-Core rev: 7588a4f2e2728da0ff7a773b18527f3711b138f2)
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.py | 18 |
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 @@ | |||
1 | import bb | 1 | import bb |
2 | 2 | ||
3 | def prserv_make_conn(d): | 3 | def prserv_make_conn(d, check = False): |
4 | import prserv.serv | 4 | import prserv.serv |
5 | host = d.getVar("PRSERV_HOST",True) | 5 | host = d.getVar("PRSERV_HOST",True) |
6 | port = d.getVar("PRSERV_PORT",True) | 6 | port = d.getVar("PRSERV_PORT",True) |
7 | try: | 7 | try: |
8 | conn = None | 8 | conn = None |
9 | conn = prserv.serv.PRServerConnection(host,int(port)) | 9 | conn = prserv.serv.PRServerConnection(host,int(port)) |
10 | if check: | ||
11 | if not conn.ping(): | ||
12 | raise Exception('service not available') | ||
10 | d.setVar("__PRSERV_CONN",conn) | 13 | d.setVar("__PRSERV_CONN",conn) |
11 | except Exception, exc: | 14 | except Exception, exc: |
12 | bb.fatal("Connecting to PR service %s:%s failed: %s" % (host, port, str(exc))) | 15 | 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): | |||
111 | f.write("PRAUTO_%s_%s = \"%s\"\n" % (str(datainfo[idx[i]]['version']),str(datainfo[idx[i]]['pkgarch']),str(datainfo[idx[i]]['value']))) | 114 | f.write("PRAUTO_%s_%s = \"%s\"\n" % (str(datainfo[idx[i]]['version']),str(datainfo[idx[i]]['pkgarch']),str(datainfo[idx[i]]['value']))) |
112 | f.close() | 115 | f.close() |
113 | bb.utils.unlockfile(lf) | 116 | bb.utils.unlockfile(lf) |
117 | |||
118 | def prserv_check_avail(d): | ||
119 | host = d.getVar("PRSERV_HOST",True) | ||
120 | port = d.getVar("PRSERV_PORT",True) | ||
121 | try: | ||
122 | if not host: | ||
123 | raise TypeError | ||
124 | else: | ||
125 | port = int(port) | ||
126 | except TypeError: | ||
127 | bb.fatal("Undefined or incorrect values of PRSERV_HOST or PRSERV_PORT") | ||
128 | else: | ||
129 | prserv_make_conn(d, True) | ||