diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2016-07-18 19:07:16 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-07-20 10:23:29 +0100 |
commit | 1a18f5ceb478f766b53850451549333f655621ea (patch) | |
tree | 148b165bde3b8e7bebcef3b046357dfed6704d8d /lib | |
parent | a4463e2ff3c7d234320176d671719243292f1af0 (diff) | |
download | bitbake-contrib-1a18f5ceb478f766b53850451549333f655621ea.tar.gz |
bitbake: xmlrpc: implement check of connection to server
Implemented check_connection function. The purpose of this function
is to check if bitbake server is accessible and functional.
To check this this function tries to connect to bitbake server and
run getVariable command.
This API is going to be used to implement autoloading of bitbake
server.
[YOCTO #5534]
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bb/server/xmlrpc.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/bb/server/xmlrpc.py b/lib/bb/server/xmlrpc.py index 57c59a82d..4131b5267 100644 --- a/lib/bb/server/xmlrpc.py +++ b/lib/bb/server/xmlrpc.py @@ -85,6 +85,23 @@ def _create_server(host, port, timeout = 60): s = xmlrpc.client.ServerProxy("http://%s:%d/" % (host, port), transport=t, allow_none=True, use_builtin_types=True) return s, t +def check_connection(remote, timeout): + try: + host, port = remote.split(":") + port = int(port) + except Exception as e: + bb.warn("Failed to read remote definition (%s)" % str(e)) + raise e + + server, _transport = _create_server(host, port, timeout) + try: + ret, err = server.runCommand(['getVariable', 'TOPDIR']) + if err or not ret: + return False + except ConnectionError: + return False + return True + class BitBakeServerCommands(): def __init__(self, server): |