summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorManuel Coutand2012-04-17 05:51:36 (EDT)
committer Anton Leherbauer2012-04-17 05:52:31 (EDT)
commitc79ef924abea4c3138594bbbd494a7144c2040ee (patch)
treebe9f17b2f99ccce494ee8d7aa6246a65123b06a3
parent20f8f18e4212c26d205f332712a0cc79ce15ef42 (diff)
downloadorg.eclipse.tcf-c79ef924abea4c3138594bbbd494a7144c2040ee.zip
org.eclipse.tcf-c79ef924abea4c3138594bbbd494a7144c2040ee.tar.gz
org.eclipse.tcf-c79ef924abea4c3138594bbbd494a7144c2040ee.tar.bz2
Bug 376883 - ContextQuery service is missing
-rw-r--r--python/src/tcf/services/contextquery.py65
-rw-r--r--python/src/tcf/services/remote/ContextQueryProxy.py59
2 files changed, 124 insertions, 0 deletions
diff --git a/python/src/tcf/services/contextquery.py b/python/src/tcf/services/contextquery.py
new file mode 100644
index 0000000..c93827a
--- /dev/null
+++ b/python/src/tcf/services/contextquery.py
@@ -0,0 +1,65 @@
+# *****************************************************************************
+# * Copyright (c) 2012 Wind River Systems, Inc. and others.
+# * All rights reserved. This program and the accompanying materials
+# * are made available under the terms of the Eclipse Public License v1.0
+# * which accompanies this distribution, and is available at
+# * http://www.eclipse.org/legal/epl-v10.html
+# *
+# * Contributors:
+# * Wind River Systems - initial API and implementation
+# *****************************************************************************
+
+"""
+TCF ContextQuery service interface.
+"""
+
+from tcf import services
+
+# Service name.
+NAME = "ContextQuery"
+
+
+class ContextQueryService(services.Service):
+ def getName(self):
+ return NAME
+
+ def query(self, querystr, done):
+ """
+ @param querystr - context query to be executed.
+ @param done - command result call back object.
+ @return - pending command handle.
+ @see DoneQuery
+ """
+ raise NotImplementedError("Abstract method")
+
+ def getAttrNames(self, done):
+ """
+ @param done - command result call back object.
+ @return - pending command handle.
+ @see DoneGetAttrNames
+ """
+ raise NotImplementedError("Abstract method")
+
+
+class DoneQuery(object):
+ "Call back interface for 'query' command."
+ def doneQuery(self, token, error, ctxList):
+ """
+ Called when 'query' command is done.
+ @param token - command handle.
+ @param error - error object or None.
+ @param ctxList - IDs of contexts matching the query.
+ """
+ pass
+
+
+class DoneGetAttrNames(object):
+ "Call back interface for 'getAttrNames' command."
+ def doneGetAttrNames(self, token, error, attrNameList):
+ """
+ Called when 'getAttrNames' command is done.
+ @param token - command handle.
+ @param error - error object or None.
+ @param attrNameList - List of the attributes supported by the agent.
+ """
+ pass
diff --git a/python/src/tcf/services/remote/ContextQueryProxy.py b/python/src/tcf/services/remote/ContextQueryProxy.py
new file mode 100644
index 0000000..2d3a420
--- /dev/null
+++ b/python/src/tcf/services/remote/ContextQueryProxy.py
@@ -0,0 +1,59 @@
+# *****************************************************************************
+# * Copyright (c) 2012 Wind River Systems, Inc. and others.
+# * All rights reserved. This program and the accompanying materials
+# * are made available under the terms of the Eclipse Public License v1.0
+# * which accompanies this distribution, and is available at
+# * http://www.eclipse.org/legal/epl-v10.html
+# *
+# * Contributors:
+# * Wind River Systems - initial API and implementation
+# *****************************************************************************
+
+from tcf.services import contextquery
+from tcf.channel.Command import Command
+
+
+class ContextQueryProxy(contextquery.ContextQueryService):
+ def __init__(self, channel):
+ self.channel = channel
+ self.listeners = {}
+
+ def query(self, querystr, done):
+ done = self._makeCallback(done)
+ service = self
+
+ class QueryCommand(Command):
+
+ def __init__(self):
+ super(QueryCommand, self).__init__(service.channel, service,
+ "query", (querystr,))
+
+ def done(self, error, args):
+ res = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ res = args[1]
+ done.doneQuery(self.token, error, res)
+ return QueryCommand().token
+
+ def getAttrNames(self, done):
+ done = self._makeCallback(done)
+ service = self
+
+ class GetAttrNamesCommand(Command):
+
+ def __init__(self):
+ super(GetAttrNamesCommand, self).__init__(service.channel,
+ service,
+ "getAttrNames",
+ None)
+
+ def done(self, error, args):
+ res = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ res = args[1]
+ done.doneGetAttrNames(self.token, error, res)
+ return GetAttrNamesCommand().token