Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraleherbau2011-05-05 08:10:33 +0000
committeraleherbau2011-05-05 08:10:33 +0000
commit3fe0ead0b4ba9bbe58a1d16305e46e808eab5d46 (patch)
tree41f17e4684938d2aa259223fe97c3ff9cf53d7b6
parent837458856781c52e4b635897c787180c15b58ce6 (diff)
downloadorg.eclipse.tcf-3fe0ead0b4ba9bbe58a1d16305e46e808eab5d46.tar.gz
org.eclipse.tcf-3fe0ead0b4ba9bbe58a1d16305e46e808eab5d46.tar.xz
org.eclipse.tcf-3fe0ead0b4ba9bbe58a1d16305e46e808eab5d46.zip
TCF Python: Allow callables (functions) as service callbacks
-rw-r--r--python/src/tcf/services/__init__.py13
-rw-r--r--python/src/tcf/services/remote/BreakpointsProxy.py10
-rw-r--r--python/src/tcf/services/remote/ExpressionsProxy.py6
-rw-r--r--python/src/tcf/services/remote/FileSystemProxy.py21
-rw-r--r--python/src/tcf/services/remote/LineNumbersProxy.py2
-rw-r--r--python/src/tcf/services/remote/LocatorProxy.py9
-rw-r--r--python/src/tcf/services/remote/ProcessesProxy.py113
-rw-r--r--python/src/tcf/services/remote/RegistersProxy.py7
-rw-r--r--python/src/tcf/services/remote/RunControlProxy.py4
-rw-r--r--python/src/tcf/services/remote/StackTraceProxy.py2
-rw-r--r--python/src/tcf/services/remote/SymbolsProxy.py8
-rw-r--r--python/src/tcf/tests/BasicTests.py56
12 files changed, 163 insertions, 88 deletions
diff --git a/python/src/tcf/services/__init__.py b/python/src/tcf/services/__init__.py
index bb5c30618..9febd3f00 100644
--- a/python/src/tcf/services/__init__.py
+++ b/python/src/tcf/services/__init__.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import threading, exceptions
+import threading, exceptions, collections
from tcf import protocol
_providers = []
@@ -67,11 +67,22 @@ def getServiceManagerID():
# so its ID is same as agent ID.
return protocol.getAgentID()
+class GenericCallback(object):
+ def __init__(self, callback):
+ self.callback = callback
+ def __getattr__(self, attr):
+ if attr.startswith("done"):
+ return self.callback
+
class Service(object):
def getName(self):
raise exceptions.NotImplementedError("Abstract method")
def __str__(self):
return self.getName()
+ def _makeCallback(self, done):
+ if isinstance(done, collections.Callable):
+ return GenericCallback(done)
+ return done
class ZeroCopy(Service):
def getName(self):
diff --git a/python/src/tcf/services/remote/BreakpointsProxy.py b/python/src/tcf/services/remote/BreakpointsProxy.py
index 3458e52bd..35cec5c5b 100644
--- a/python/src/tcf/services/remote/BreakpointsProxy.py
+++ b/python/src/tcf/services/remote/BreakpointsProxy.py
@@ -55,24 +55,31 @@ class BreakpointsProxy(breakpoints.BreakpointsService):
self.listeners = {}
def set(self, properties, done):
+ done = self._makeCallback(done)
return BPCommand(self, "set", done, properties).token
def add(self, properties, done):
+ done = self._makeCallback(done)
return BPCommand(self, "add", done, properties).token
def change(self, properties, done):
+ done = self._makeCallback(done)
return BPCommand(self, "change", done, properties).token
def disable(self, ids, done):
+ done = self._makeCallback(done)
return BPCommand(self, "disable", done, ids).token
def enable(self, ids, done):
+ done = self._makeCallback(done)
return BPCommand(self, "enable", done, ids).token
def remove(self, ids, done):
+ done = self._makeCallback(done)
return BPCommand(self, "remove", done, ids).token
def getIDs(self, done):
+ done = self._makeCallback(done)
service = self
class GetIDsCommand(Command):
def __init__(self):
@@ -87,6 +94,7 @@ class BreakpointsProxy(breakpoints.BreakpointsService):
return GetIDsCommand().token
def getProperties(self, id, done):
+ done = self._makeCallback(done)
service = self
class GetPropertiesCommand(Command):
def __init__(self):
@@ -101,6 +109,7 @@ class BreakpointsProxy(breakpoints.BreakpointsService):
return GetPropertiesCommand().token
def getStatus(self, id, done):
+ done = self._makeCallback(done)
service = self
class GetStatusCommand(Command):
def __init__(self):
@@ -115,6 +124,7 @@ class BreakpointsProxy(breakpoints.BreakpointsService):
return GetStatusCommand().token
def getCapabilities(self, id, done):
+ done = self._makeCallback(done)
service = self
class GetCapabilitiesCommand(Command):
def __init__(self):
diff --git a/python/src/tcf/services/remote/ExpressionsProxy.py b/python/src/tcf/services/remote/ExpressionsProxy.py
index 601adab02..48a2d313d 100644
--- a/python/src/tcf/services/remote/ExpressionsProxy.py
+++ b/python/src/tcf/services/remote/ExpressionsProxy.py
@@ -19,6 +19,7 @@ class ExpressionsProxy(expressions.ExpressionsService):
self.channel = channel
def assign(self, id, value, done):
+ done = self._makeCallback(done)
service = self
value = bytearray(value)
class AssignCommand(Command):
@@ -32,6 +33,7 @@ class ExpressionsProxy(expressions.ExpressionsService):
return AssignCommand().token
def create(self, parent_id, language, expression, done):
+ done = self._makeCallback(done)
service = self
class CreateCommand(Command):
def __init__(self):
@@ -46,6 +48,7 @@ class ExpressionsProxy(expressions.ExpressionsService):
return CreateCommand().token
def dispose(self, id, done):
+ done = self._makeCallback(done)
service = self
class DisposeCommand(Command):
def __init__(self):
@@ -58,6 +61,7 @@ class ExpressionsProxy(expressions.ExpressionsService):
return DisposeCommand().token
def evaluate(self, id, done):
+ done = self._makeCallback(done)
service = self
class EvalCommand(Command):
def __init__(self):
@@ -73,6 +77,7 @@ class ExpressionsProxy(expressions.ExpressionsService):
return EvalCommand().token
def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
service = self
class GetChildrenCommand(Command):
def __init__(self):
@@ -87,6 +92,7 @@ class ExpressionsProxy(expressions.ExpressionsService):
return GetChildrenCommand().token
def getContext(self, id, done):
+ done = self._makeCallback(done)
service = self
class GetContextCommand(Command):
def __init__(self):
diff --git a/python/src/tcf/services/remote/FileSystemProxy.py b/python/src/tcf/services/remote/FileSystemProxy.py
index 128a3b729..ad626b6e6 100644
--- a/python/src/tcf/services/remote/FileSystemProxy.py
+++ b/python/src/tcf/services/remote/FileSystemProxy.py
@@ -63,6 +63,7 @@ class FileSystemProxy(filesystem.FileSystemService):
def close(self, handle, done):
assert handle.getService() is self
+ done = self._makeCallback(done)
id = handle.id
service = self
class CloseCommand(FileSystemCommand):
@@ -79,6 +80,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return CloseCommand().token
def setstat(self, path, attrs, done):
+ done = self._makeCallback(done)
dt = _toObject(attrs)
service = self
class SetStatCommand(FileSystemCommand):
@@ -95,6 +97,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return SetStatCommand().token
def fsetstat(self, handle, attrs, done):
+ done = self._makeCallback(done)
assert handle.getService() is self
id = handle.id
dt = _toObject(attrs)
@@ -113,6 +116,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return FSetStatCommand().token
def stat(self, path, done):
+ done = self._makeCallback(done)
service = self
class StatCommand(FileSystemCommand):
def __init__(self):
@@ -130,6 +134,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return StatCommand().token
def fstat(self, handle, done):
+ done = self._makeCallback(done)
assert handle.getService() is self
id = handle.id
service = self
@@ -149,6 +154,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return FStatCommand().token
def lstat(self, path, done):
+ done = self._makeCallback(done)
service = self
class LStatCommand(FileSystemCommand):
def __init__(self):
@@ -166,6 +172,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return LStatCommand().token
def mkdir(self, path, attrs, done):
+ done = self._makeCallback(done)
dt = _toObject(attrs)
service = self
class MkDirCommand(FileSystemCommand):
@@ -182,6 +189,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return MkDirCommand().token
def open(self, file_name, flags, attrs, done):
+ done = self._makeCallback(done)
dt = _toObject(attrs)
service = self
class OpenCommand(FileSystemCommand):
@@ -200,6 +208,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return OpenCommand().token
def opendir(self, path, done):
+ done = self._makeCallback(done)
service = self
class OpenDirCommand(FileSystemCommand):
def __init__(self):
@@ -218,6 +227,7 @@ class FileSystemProxy(filesystem.FileSystemService):
def read(self, handle, offset, len, done):
assert handle.getService() is self
+ done = self._makeCallback(done)
id = handle.id
service = self
class ReadCommand(FileSystemCommand):
@@ -240,6 +250,7 @@ class FileSystemProxy(filesystem.FileSystemService):
def readdir(self, handle, done):
assert handle.getService() is self
+ done = self._makeCallback(done)
id = handle.id
service = self
class ReadDirCommand(FileSystemCommand):
@@ -261,6 +272,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return ReadDirCommand().token
def roots(self, done):
+ done = self._makeCallback(done)
service = self
class RootCommand(FileSystemCommand):
def __init__(self):
@@ -279,6 +291,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return RootCommand().token
def readlink(self, path, done):
+ done = self._makeCallback(done)
service = self
class ReadLinkCommand(FileSystemCommand):
def __init__(self):
@@ -297,6 +310,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return ReadLinkCommand().token
def realpath(self, path, done):
+ done = self._makeCallback(done)
service = self
class RealPathCommand(FileSystemCommand):
def __init__(self):
@@ -315,6 +329,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return RealPathCommand().token
def remove(self, file_name, done):
+ done = self._makeCallback(done)
service = self
class RemoveCommand(FileSystemCommand):
def __init__(self):
@@ -330,6 +345,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return RemoveCommand().token
def rename(self, old_path, new_path, done):
+ done = self._makeCallback(done)
service = self
class RenameCommand(FileSystemCommand):
def __init__(self):
@@ -345,6 +361,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return RenameCommand().token
def rmdir(self, path, done):
+ done = self._makeCallback(done)
service = self
class RmDirCommand(FileSystemCommand):
def __init__(self):
@@ -360,6 +377,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return RmDirCommand().token
def symlink(self, link_path, target_path, done):
+ done = self._makeCallback(done)
service = self
class SymLinkCommand(FileSystemCommand):
def __init__(self):
@@ -376,6 +394,7 @@ class FileSystemProxy(filesystem.FileSystemService):
def write(self, handle, offset, data, data_pos, data_size, done):
assert handle.getService() is self
+ done = self._makeCallback(done)
id = handle.id
binary = bytearray(data[data_pos:data_pos+data_size])
service = self
@@ -393,6 +412,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return WriteCommand().token
def copy(self, src_path, dst_path, copy_permissions, copy_uidgid, done):
+ done = self._makeCallback(done)
service = self
class CopyCommand(FileSystemCommand):
def __init__(self):
@@ -409,6 +429,7 @@ class FileSystemProxy(filesystem.FileSystemService):
return CopyCommand().token
def user(self, done):
+ done = self._makeCallback(done)
service = self
class UserCommand(FileSystemCommand):
def __init__(self):
diff --git a/python/src/tcf/services/remote/LineNumbersProxy.py b/python/src/tcf/services/remote/LineNumbersProxy.py
index 84c4aa9ca..32211ddf2 100644
--- a/python/src/tcf/services/remote/LineNumbersProxy.py
+++ b/python/src/tcf/services/remote/LineNumbersProxy.py
@@ -18,6 +18,7 @@ class LineNumbersProxy(linenumbers.LineNumbersService):
self.channel = channel
def mapToSource(self, context_id, start_address, end_address, done):
+ done = self._makeCallback(done)
service = self
class MapCommand(Command):
def __init__(self):
@@ -33,6 +34,7 @@ class LineNumbersProxy(linenumbers.LineNumbersService):
return MapCommand().token
def mapToMemory(self, context_id, file, line, column, done):
+ done = self._makeCallback(done)
service = self
class MapCommand(Command):
def __init__(self):
diff --git a/python/src/tcf/services/remote/LocatorProxy.py b/python/src/tcf/services/remote/LocatorProxy.py
index faf5ee585..4926ee987 100644
--- a/python/src/tcf/services/remote/LocatorProxy.py
+++ b/python/src/tcf/services/remote/LocatorProxy.py
@@ -82,12 +82,11 @@ class ChannelEventListener(channel.EventListener):
self.channel.terminate(x)
class LocatorProxy(locator.LocatorService):
- peers = {}
- listeners = []
- get_peers_done = False
-
def __init__(self, channel):
self.channel = channel;
+ self.peers = {}
+ self.listeners = []
+ self.get_peers_done = False
self.event_listener = ChannelEventListener(self)
channel.addEventListener(self, self.event_listener)
@@ -95,6 +94,7 @@ class LocatorProxy(locator.LocatorService):
return self.peers
def redirect(self, peer, done):
+ done = self._makeCallback(done)
service = self
class RedirectCommand(Command):
def __init__(self):
@@ -107,6 +107,7 @@ class LocatorProxy(locator.LocatorService):
return RedirectCommand().token
def sync(self, done):
+ done = self._makeCallback(done)
service = self
class SyncCommand(Command):
def __init__(self):
diff --git a/python/src/tcf/services/remote/ProcessesProxy.py b/python/src/tcf/services/remote/ProcessesProxy.py
index c816465cd..b4155ffef 100644
--- a/python/src/tcf/services/remote/ProcessesProxy.py
+++ b/python/src/tcf/services/remote/ProcessesProxy.py
@@ -14,38 +14,42 @@ from tcf import channel
from tcf.services import processes
from tcf.channel.Command import Command
-class ChannelEventListener(channel.EventListener):
- def __init__(self, service, listener):
+class ProcessContext(processes.ProcessContext):
+ def __init__(self, service, props):
+ super(ProcessContext, self).__init__(props)
self.service = service
- self.listener = listener
- def event(self, name, data):
- try:
- args = channel.fromJSONSequence(data)
- if name == "exited":
- assert len(args) == 2
- self.listener.exited(args[0], args[1])
- else:
- raise IOError("Processes service: unknown event: " + name);
- except exceptions.Exception as x:
- self.service.channel.terminate(x)
+
+ def attach(self, done):
+ return self._command("attach", done)
+
+ def detach(self, done):
+ return self._command("detach", done)
+
+ def terminate(self, done):
+ return self._command("terminate", done)
+
+ def _command(self, command, done):
+ service = self.service
+ done = service._makeCallback(done)
+ id = self.getID()
+ class _Command(Command):
+ def __init__(self):
+ super(_Command, self).__init__(service.channel, service,
+ command, (id,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneCommand(self.token, error)
+ return _Command().token
class ProcessesProxy(processes.ProcessesService):
def __init__(self, channel):
self.channel = channel
self.listeners = {}
- def addListener(self, listener):
- l = ChannelEventListener(self, listener)
- self.channel.addEventListener(self, l)
- self.listeners[listener] = l
-
- def removeListener(self, listener):
- l = self.listeners.get(listener)
- if l:
- del self.listeners[listener]
- self.channel.removeEventListener(self, l)
-
def getChildren(self, parent_context_id, attached_only, done):
+ done = self._makeCallback(done)
service = self
class GetChildrenCommand(Command):
def __init__(self):
@@ -61,6 +65,7 @@ class ProcessesProxy(processes.ProcessesService):
return GetChildrenCommand().token
def getContext(self, context_id, done):
+ done = self._makeCallback(done)
service = self
class GetContextCommand(Command):
def __init__(self):
@@ -75,6 +80,7 @@ class ProcessesProxy(processes.ProcessesService):
return GetContextCommand().token
def getEnvironment(self, done):
+ done = self._makeCallback(done)
service = self
class GetEnvCommand(Command):
def __init__(self):
@@ -89,6 +95,7 @@ class ProcessesProxy(processes.ProcessesService):
return GetEnvCommand().token
def start(self, directory, file, command_line, environment, attach, done):
+ done = self._makeCallback(done)
service = self
env = _toEnvStringArray(environment)
class StartCommand(Command):
@@ -105,6 +112,7 @@ class ProcessesProxy(processes.ProcessesService):
return StartCommand().token
def getSignalList(self, context_id, done):
+ done = self._makeCallback(done)
service = self
class GetSignalsCommand(Command):
def __init__(self):
@@ -120,6 +128,7 @@ class ProcessesProxy(processes.ProcessesService):
return GetSignalsCommand().token
def getSignalMask(self, context_id, done):
+ done = self._makeCallback(done)
service = self
class GetSignalMaskCommand(Command):
def __init__(self):
@@ -137,6 +146,7 @@ class ProcessesProxy(processes.ProcessesService):
return GetSignalMaskCommand().token
def setSignalMask(self, context_id, dont_stop, dont_pass, done):
+ done = self._makeCallback(done)
service = self
class SetSignalMaskCommand(Command):
def __init__(self):
@@ -150,6 +160,7 @@ class ProcessesProxy(processes.ProcessesService):
return SetSignalMaskCommand().token
def signal(self, context_id, signal, done):
+ done = self._makeCallback(done)
service = self
class SignalCommand(Command):
def __init__(self):
@@ -162,6 +173,32 @@ class ProcessesProxy(processes.ProcessesService):
done.doneCommand(self.token, error)
return SignalCommand().token
+ def addListener(self, listener):
+ l = ChannelEventListener(self, listener)
+ self.channel.addEventListener(self, l)
+ self.listeners[listener] = l
+
+ def removeListener(self, listener):
+ l = self.listeners.get(listener)
+ if l:
+ del self.listeners[listener]
+ self.channel.removeEventListener(self, l)
+
+class ChannelEventListener(channel.EventListener):
+ def __init__(self, service, listener):
+ self.service = service
+ self.listener = listener
+ def event(self, name, data):
+ try:
+ args = channel.fromJSONSequence(data)
+ if name == "exited":
+ assert len(args) == 2
+ self.listener.exited(args[0], args[1])
+ else:
+ raise IOError("Processes service: unknown event: " + name);
+ except exceptions.Exception as x:
+ self.service.channel.terminate(x)
+
def _toEnvStringArray(map):
arr = []
if not map: return arr
@@ -177,31 +214,3 @@ def _toEnvMap(arr):
if i >= 0: map[str[:i]] = str[i + 1:]
else: map[str] = ""
return map
-
-class ProcessContext(processes.ProcessContext):
- def __init__(self, service, props):
- super(ProcessContext, self).__init__(props)
- self.service = service
-
- def attach(self, done):
- return self._command("attach", done)
-
- def detach(self, done):
- return self._command("detach", done)
-
- def terminate(self, done):
- return self._command("terminate", done)
-
- def _command(self, command, done):
- service = self.service
- id = self.getID()
- class _Command(Command):
- def __init__(self):
- super(_Command, self).__init__(service.channel, service,
- command, (id,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneCommand(self.token, error)
- return _Command().token
diff --git a/python/src/tcf/services/remote/RegistersProxy.py b/python/src/tcf/services/remote/RegistersProxy.py
index d75605cd9..ae2cfd4e0 100644
--- a/python/src/tcf/services/remote/RegistersProxy.py
+++ b/python/src/tcf/services/remote/RegistersProxy.py
@@ -25,6 +25,7 @@ class Context(registers.RegistersContext):
def get(self, done):
service = self.service
+ done = service._makeCallback(done)
id = self.getID()
class GetCommand(Command):
def __init__(self):
@@ -40,6 +41,7 @@ class Context(registers.RegistersContext):
def set(self, value, done):
service = self.service
+ done = service._makeCallback(done)
id = self.getID()
binary = bytearray(value)
class SetCommand(Command):
@@ -54,6 +56,7 @@ class Context(registers.RegistersContext):
def search(self, filter, done):
service = self.service
+ done = service._makeCallback(done)
id = self.getID()
class SearchCommand(Command):
def __init__(self):
@@ -73,6 +76,7 @@ class RegistersProxy(registers.RegistersService):
self.listeners = {}
def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
service = self
class GetChildrenCommand(Command):
def __init__(self):
@@ -87,6 +91,7 @@ class RegistersProxy(registers.RegistersService):
return GetChildrenCommand().token
def getContext(self, id, done):
+ done = self._makeCallback(done)
service = self
class GetContextCommand(Command):
def __init__(self):
@@ -101,6 +106,7 @@ class RegistersProxy(registers.RegistersService):
return GetContextCommand().token
def getm(self, locs, done):
+ done = self._makeCallback(done)
service = self
class GetMCommand(Command):
def __init__(self):
@@ -115,6 +121,7 @@ class RegistersProxy(registers.RegistersService):
return GetMCommand().token
def setm(self, locs, value, done):
+ done = self._makeCallback(done)
service = self
binary = bytearray(value)
class SetMCommand(Command):
diff --git a/python/src/tcf/services/remote/RunControlProxy.py b/python/src/tcf/services/remote/RunControlProxy.py
index e9b53226e..d7606c74a 100644
--- a/python/src/tcf/services/remote/RunControlProxy.py
+++ b/python/src/tcf/services/remote/RunControlProxy.py
@@ -21,6 +21,7 @@ class RunContext(runcontrol.RunControlContext):
def getState(self, done):
service = self.service
+ done = service._makeCallback(done)
id = self.getID()
class GetStateCommand(Command):
def __init__(self):
@@ -57,6 +58,7 @@ class RunContext(runcontrol.RunControlContext):
def _command(self, cmd, args, done):
service = self.service
+ done = service._makeCallback(done)
class RCCommand(Command):
def __init__(self, cmd, args):
super(RCCommand, self).__init__(service.channel, service, cmd, args)
@@ -121,6 +123,7 @@ class RunControlProxy(runcontrol.RunControlService):
self.channel.removeEventListener(self, l)
def getContext(self, context_id, done):
+ done = self._makeCallback(done)
service = self
class GetContextCommand(Command):
def __init__(self):
@@ -135,6 +138,7 @@ class RunControlProxy(runcontrol.RunControlService):
return GetContextCommand().token
def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
service = self
class GetChildrenCommand(Command):
def __init__(self):
diff --git a/python/src/tcf/services/remote/StackTraceProxy.py b/python/src/tcf/services/remote/StackTraceProxy.py
index 350db8295..b551af36f 100644
--- a/python/src/tcf/services/remote/StackTraceProxy.py
+++ b/python/src/tcf/services/remote/StackTraceProxy.py
@@ -17,6 +17,7 @@ class StackTraceProxy(stacktrace.StackTraceService):
self.channel = channel
def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
service = self
class GetChildrenCommand(Command):
def __init__(self):
@@ -31,6 +32,7 @@ class StackTraceProxy(stacktrace.StackTraceService):
return GetChildrenCommand().token
def getContext(self, ids, done):
+ done = self._makeCallback(done)
service = self
class GetContextCommand(Command):
def __init__(self):
diff --git a/python/src/tcf/services/remote/SymbolsProxy.py b/python/src/tcf/services/remote/SymbolsProxy.py
index 7debc1bc7..67b9e9e9f 100644
--- a/python/src/tcf/services/remote/SymbolsProxy.py
+++ b/python/src/tcf/services/remote/SymbolsProxy.py
@@ -28,6 +28,7 @@ class SymbolsProxy(symbols.SymbolsService):
self.channel = channel
def getContext(self, id, done):
+ done = self._makeCallback(done)
service = self
class GetContextCommand(Command):
def __init__(self):
@@ -42,6 +43,7 @@ class SymbolsProxy(symbols.SymbolsService):
return GetContextCommand().token
def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
service = self
class GetChildrenCommand(Command):
def __init__(self):
@@ -56,6 +58,7 @@ class SymbolsProxy(symbols.SymbolsService):
return GetChildrenCommand().token
def find(self, context_id, ip, name, done):
+ done = self._makeCallback(done)
service = self
class FindCommand(Command):
def __init__(self):
@@ -70,6 +73,7 @@ class SymbolsProxy(symbols.SymbolsService):
return FindCommand().token
def findByAddr(self, context_id, addr, done):
+ done = self._makeCallback(done)
service = self
class FindByAddrCommand(Command):
def __init__(self):
@@ -84,6 +88,7 @@ class SymbolsProxy(symbols.SymbolsService):
return FindByAddrCommand().token
def list(self, context_id, done):
+ done = self._makeCallback(done)
service = self
class ListCommand(Command):
def __init__(self):
@@ -98,6 +103,7 @@ class SymbolsProxy(symbols.SymbolsService):
return ListCommand().token
def findFrameInfo(self, context_id, address, done):
+ done = self._makeCallback(done)
service = self
class FindFrameInfoCommand(Command):
def __init__(self):
@@ -111,5 +117,5 @@ class SymbolsProxy(symbols.SymbolsService):
assert len(args) == 5
error = self.toError(args[0])
address, size, fp_cmds, reg_cmds = args[1:4]
- done.doneList(self.token, error, address, size, fp_cmds, reg_cmds)
+ done.doneFindFrameInfo(self.token, error, address, size, fp_cmds, reg_cmds)
return FindFrameInfoCommand().token
diff --git a/python/src/tcf/tests/BasicTests.py b/python/src/tcf/tests/BasicTests.py
index 3a15ee98f..917ddcc07 100644
--- a/python/src/tcf/tests/BasicTests.py
+++ b/python/src/tcf/tests/BasicTests.py
@@ -144,32 +144,29 @@ def testRunControl(c):
def testBreakpoints(c):
from tcf.services import breakpoints
- def r3():
+ def testBPQuery():
bps = c.getRemoteService(breakpoints.NAME)
- class DoneGetIDs(breakpoints.DoneGetIDs):
- def doneGetIDs(self, token, error, ids):
+ def doneGetIDs(token, error, ids):
+ if error:
+ protocol.log("Error from Breakpoints.getIDs", error)
+ return
+ print "Breakpoints :", ids
+ def doneGetProperties(token, error, props):
if error:
- protocol.log("Error from Breakpoints.getIDs", error)
+ protocol.log("Error from Breakpoints.getProperties", error)
return
- print "Breakpoints :", ids
- class DoneGetProperties(breakpoints.DoneGetProperties):
- def doneGetProperties(self, token, error, props):
- if error:
- protocol.log("Error from Breakpoints.getProperties", error)
- return
- print "Breakpoint Properties: ", props
- class DoneGetStatus(breakpoints.DoneGetStatus):
- def doneGetProperties(self, token, error, props):
- if error:
- protocol.log("Error from Breakpoints.getStatus", error)
- return
- print "Breakpoint Status: ", props
- for id in ids:
- bps.getProperties(id, DoneGetProperties())
- bps.getStatus(id, DoneGetStatus())
- bps.getIDs(DoneGetIDs())
- protocol.invokeLater(r3)
- def r4():
+ print "Breakpoint Properties: ", props
+ def doneGetStatus(token, error, props):
+ if error:
+ protocol.log("Error from Breakpoints.getStatus", error)
+ return
+ print "Breakpoint Status: ", props
+ for id in ids:
+ bps.getProperties(id, doneGetProperties)
+ bps.getStatus(id, doneGetStatus)
+ bps.getIDs(doneGetIDs)
+ protocol.invokeLater(testBPQuery)
+ def testBPSet():
bpsvc = c.getRemoteService(breakpoints.NAME)
class BPListener(breakpoints.BreakpointsListener):
def breakpointStatusChanged(self, id, status):
@@ -182,18 +179,17 @@ def testBreakpoints(c):
def contextRemoved(self, ids):
print "breakpointRemoved", ids
bpsvc.addListener(BPListener())
- class DoneSet(breakpoints.DoneCommand):
- def doneCommand(self, token, error):
- if error:
- protocol.log("Error from Breakpoints.set", error)
- return
+ def doneSet(token, error):
+ if error:
+ protocol.log("Error from Breakpoints.set", error)
+ return
bp = {
breakpoints.PROP_ID : "python:1",
breakpoints.PROP_ENABLED : True,
breakpoints.PROP_LOCATION : "sysClkRateGet"
}
- bpsvc.set([bp], DoneSet())
- protocol.invokeLater(r4)
+ bpsvc.set([bp], doneSet)
+ protocol.invokeLater(testBPSet)
def testStackTrace(c):
from tcf.services import stacktrace

Back to the top