Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH 0/1] Webhob: webservice client
@ 2012-06-16  1:23 Xiaotong lv
  2012-06-16  1:23 ` [PATCH 1/1] " Xiaotong lv
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaotong lv @ 2012-06-16  1:23 UTC (permalink / raw)
  To: bitbake-devel

this is  a webservice python client based on suds.
if client is other different language. such as java, php, etc.
we can use their corresponding webservice client program to call bitbake.


The following changes since commit cbe94009a060bc680bf196732642e295151b8ef9:

  Webhob: a general helper interface based on webservice (2012-06-06 21:03:11 -0400)

are available in the git repository at:
  git://git.yoctoproject.org/poky-contrib xtlv/webhob-webservice
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=xtlv/webhob-webservice

Xiaotong lv (1):
  Webhob: webservice client

 .../bb/ui/webservice_client/client_webservice.py   |   63 ++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)
 create mode 100644 bitbake/lib/bb/ui/webservice_client/client_webservice.py

-- 
1.7.4.4




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] Webhob: webservice client
  2012-06-16  1:23 [PATCH 0/1] Webhob: webservice client Xiaotong lv
@ 2012-06-16  1:23 ` Xiaotong lv
  0 siblings, 0 replies; 2+ messages in thread
From: Xiaotong lv @ 2012-06-16  1:23 UTC (permalink / raw)
  To: bitbake-devel

A webservice client wrapper class.

Signed-off-by: Xiaotong Lv <xiaotongx.lv@intel.com>
---
 .../bb/ui/webservice_client/client_webservice.py   |   63 ++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)
 create mode 100644 bitbake/lib/bb/ui/webservice_client/client_webservice.py

diff --git a/bitbake/lib/bb/ui/webservice_client/client_webservice.py b/bitbake/lib/bb/ui/webservice_client/client_webservice.py
new file mode 100644
index 0000000..e70ce36
--- /dev/null
+++ b/bitbake/lib/bb/ui/webservice_client/client_webservice.py
@@ -0,0 +1,63 @@
+import sys
+import traceback
+try:
+    from suds.client import Client, WebFault
+except ImportError as e:
+    sys.exit('Error:Install suds python lib firstly\n%s' % str(e))
+try:
+    import simplejson as json
+except ImportError:
+    import json
+
+class Connection:
+    def __init__(self, wsUrl, cache=None):
+        self.wsUrl = wsUrl
+        self.cache = cache
+        try:
+            self.client = Client(wsUrl, cache=self.cache)
+        except Exception, e:
+            sys.exit(str(e))
+
+    def runCommand(self, command):
+        if not isinstance(command, list) or not command:
+            raise ValueError('command must be list type, and be not empty')
+        params = {}
+        param_type = []
+        params['function'] = command.pop(0)
+        for i in command:
+            if isinstance(i, list):
+                param_type.append(('list'," ".join(i)))
+            elif isinstance(i, bool):
+                param_type.append(('bool',bool(i)))
+            elif isinstance(i, str):
+                param_type.append(('string',str(i)))
+
+        if param_type:
+            params['param_type'] = {'string':[type for type, param in param_type]}
+            params['params'] = {'string':[param for type, param in param_type]}
+
+        try:
+            return self.client.service.runCommand(params)
+        except WebFault, f:
+            print f.fault
+        except Exception, e:
+            print e
+            traceback.print_exc()
+
+    def getEvent(self):
+        try:
+            event = self.client.service.getEvent()
+            if isinstance(event, unicode):
+                event = event.encode('utf-8')
+            o_event = json.loads(event)
+            return o_event['events']
+        except WebFault, f:
+            print f.fault
+        except Exception, e:
+            print e
+            traceback.print_exc()
+
+#only testing
+if __name__ == '__main__':
+    server = Connection('http://localhost:8888/?wsdl')
+    print server.runCommand(['getVariable', 'BBLAYERS'])
-- 
1.7.4.4




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-15  1:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-16  1:23 [PATCH 0/1] Webhob: webservice client Xiaotong lv
2012-06-16  1:23 ` [PATCH 1/1] " Xiaotong lv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox