[oe-commits] [bitbake] 01/03: bitbake: xmlrpc: implement check of connection to server

git at git.openembedded.org git at git.openembedded.org
Tue Jul 19 08:01:16 UTC 2016


rpurdie pushed a commit to branch master-next
in repository bitbake.

commit 192e8a8d3888c447dcc61da0e76199233380c4d4
Author: Ed Bartosh <ed.bartosh at linux.intel.com>
AuthorDate: Mon Jul 18 19:07:16 2016 +0300

    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 at linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/server/xmlrpc.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/bb/server/xmlrpc.py b/lib/bb/server/xmlrpc.py
index 57c59a8..4131b52 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):

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list