Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/tcf/services/remote')
-rw-r--r--python/src/tcf/services/remote/BreakpointsProxy.py298
-rw-r--r--python/src/tcf/services/remote/DiagnosticsProxy.py348
-rw-r--r--python/src/tcf/services/remote/DisassemblyProxy.py116
-rw-r--r--python/src/tcf/services/remote/ExpressionsProxy.py268
-rw-r--r--python/src/tcf/services/remote/FileSystemProxy.py1018
-rw-r--r--python/src/tcf/services/remote/LineNumbersProxy.py134
-rw-r--r--python/src/tcf/services/remote/LocatorProxy.py298
-rw-r--r--python/src/tcf/services/remote/MemoryMapProxy.py164
-rw-r--r--python/src/tcf/services/remote/MemoryProxy.py484
-rw-r--r--python/src/tcf/services/remote/PathMapProxy.py112
-rw-r--r--python/src/tcf/services/remote/ProcessesProxy.py430
-rw-r--r--python/src/tcf/services/remote/ProcessesV1Proxy.py64
-rw-r--r--python/src/tcf/services/remote/RegistersProxy.py352
-rw-r--r--python/src/tcf/services/remote/RunControlProxy.py316
-rw-r--r--python/src/tcf/services/remote/StackTraceProxy.py108
-rw-r--r--python/src/tcf/services/remote/StreamsProxy.py292
-rw-r--r--python/src/tcf/services/remote/SymbolsProxy.py242
-rw-r--r--python/src/tcf/services/remote/SysMonitorProxy.py154
-rw-r--r--python/src/tcf/services/remote/TerminalsProxy.py246
19 files changed, 2722 insertions, 2722 deletions
diff --git a/python/src/tcf/services/remote/BreakpointsProxy.py b/python/src/tcf/services/remote/BreakpointsProxy.py
index 7111c5a48..b7674a3b7 100644
--- a/python/src/tcf/services/remote/BreakpointsProxy.py
+++ b/python/src/tcf/services/remote/BreakpointsProxy.py
@@ -1,149 +1,149 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 import channel
-from tcf.services import breakpoints
-from tcf.channel.Command import Command
-
-class BPCommand(Command):
- def __init__(self, service, cmd, cb, *args):
- super(BPCommand, self).__init__(service.channel, service, cmd, args)
- self.__cb = cb
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- self.__cb.doneCommand(self.token, error)
-
-
-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 == "status":
- assert len(args) == 2
- self.listener.breakpointStatusChanged(args[0], args[1])
- elif name == "contextAdded":
- assert len(args) == 1
- self.listener.contextAdded(args[0])
- elif name == "contextChanged":
- assert len(args) == 1
- self.listener.contextChanged(args[0])
- elif name == "contextRemoved":
- assert len(args) == 1
- self.listener.contextRemoved(args[0])
- else:
- raise IOError("Breakpoints service: unknown event: " + name);
- except Exception as x:
- self.service.channel.terminate(x)
-
-class BreakpointsProxy(breakpoints.BreakpointsService):
- def __init__(self, channel):
- self.channel = channel
- 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):
- super(GetIDsCommand, self).__init__(service.channel, service, "getIDs", None)
- def done(self, error, args):
- ids = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- ids = args[1]
- done.doneGetIDs(self.token, error, ids)
- return GetIDsCommand().token
-
- def getProperties(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetPropertiesCommand(Command):
- def __init__(self):
- super(GetPropertiesCommand, self).__init__(service.channel, service, "getProperties", (id,))
- def done(self, error, args):
- map = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- map = args[1]
- done.doneGetProperties(self.token, error, map)
- return GetPropertiesCommand().token
-
- def getStatus(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetStatusCommand(Command):
- def __init__(self):
- super(GetStatusCommand, self).__init__(service.channel, service, "getStatus", (id,))
- def done(self, error, args):
- map = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- map = args[1]
- done.doneGetStatus(self.token, error, map)
- return GetStatusCommand().token
-
- def getCapabilities(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetCapabilitiesCommand(Command):
- def __init__(self):
- super(GetCapabilitiesCommand, self).__init__(service.channel, service, "getCapabilities", (id,))
- def done(self, error, args):
- map = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- map = args[1]
- done.doneGetCapabilities(self.token, error, map)
- return GetCapabilitiesCommand().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)
+# *******************************************************************************
+# * Copyright (c) 2011 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 import channel
+from tcf.services import breakpoints
+from tcf.channel.Command import Command
+
+class BPCommand(Command):
+ def __init__(self, service, cmd, cb, *args):
+ super(BPCommand, self).__init__(service.channel, service, cmd, args)
+ self.__cb = cb
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ self.__cb.doneCommand(self.token, error)
+
+
+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 == "status":
+ assert len(args) == 2
+ self.listener.breakpointStatusChanged(args[0], args[1])
+ elif name == "contextAdded":
+ assert len(args) == 1
+ self.listener.contextAdded(args[0])
+ elif name == "contextChanged":
+ assert len(args) == 1
+ self.listener.contextChanged(args[0])
+ elif name == "contextRemoved":
+ assert len(args) == 1
+ self.listener.contextRemoved(args[0])
+ else:
+ raise IOError("Breakpoints service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)
+
+class BreakpointsProxy(breakpoints.BreakpointsService):
+ def __init__(self, channel):
+ self.channel = channel
+ 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):
+ super(GetIDsCommand, self).__init__(service.channel, service, "getIDs", None)
+ def done(self, error, args):
+ ids = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ ids = args[1]
+ done.doneGetIDs(self.token, error, ids)
+ return GetIDsCommand().token
+
+ def getProperties(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetPropertiesCommand(Command):
+ def __init__(self):
+ super(GetPropertiesCommand, self).__init__(service.channel, service, "getProperties", (id,))
+ def done(self, error, args):
+ map = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ map = args[1]
+ done.doneGetProperties(self.token, error, map)
+ return GetPropertiesCommand().token
+
+ def getStatus(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetStatusCommand(Command):
+ def __init__(self):
+ super(GetStatusCommand, self).__init__(service.channel, service, "getStatus", (id,))
+ def done(self, error, args):
+ map = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ map = args[1]
+ done.doneGetStatus(self.token, error, map)
+ return GetStatusCommand().token
+
+ def getCapabilities(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetCapabilitiesCommand(Command):
+ def __init__(self):
+ super(GetCapabilitiesCommand, self).__init__(service.channel, service, "getCapabilities", (id,))
+ def done(self, error, args):
+ map = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ map = args[1]
+ done.doneGetCapabilities(self.token, error, map)
+ return GetCapabilitiesCommand().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)
diff --git a/python/src/tcf/services/remote/DiagnosticsProxy.py b/python/src/tcf/services/remote/DiagnosticsProxy.py
index 24305a1ca..944533ab6 100644
--- a/python/src/tcf/services/remote/DiagnosticsProxy.py
+++ b/python/src/tcf/services/remote/DiagnosticsProxy.py
@@ -1,174 +1,174 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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
-# *******************************************************************************
-
-import time
-from tcf import errors
-from tcf.services import diagnostics
-from tcf.channel.Command import Command
-
-class DiagnosticsProxy(diagnostics.DiagnosticsService):
- def __init__(self, channel):
- self.channel = channel
-
- def echo(self, s, done):
- done = self._makeCallback(done)
- service = self
- class EchoCommand(Command):
- def __init__(self):
- super(EchoCommand, self).__init__(service.channel, service, "echo", (s,))
- def done(self, error, args):
- str = None
- if not error:
- assert len(args) == 1
- str = args[0]
- done.doneEcho(self.token, error, str)
- return EchoCommand().token
-
- def echoFP(self, n, done):
- done = self._makeCallback(done)
- service = self
- class EchoFPCommand(Command):
- def __init__(self):
- super(EchoFPCommand, self).__init__(service.channel, service, "echoFP", (n,))
- def done(self, error, args):
- n = None
- if not error:
- assert len(args) == 1
- n = args[0]
- done.doneEchoFP(self.token, error, n)
- return EchoFPCommand().token
-
- def echoERR(self, err, done):
- map = None
- if isinstance(err, errors.ErrorReport):
- map = err.getAttributes()
- else:
- map = {
- errors.ERROR_TIME : int(time.time() * 1000),
- errors.ERROR_CODE : errors.TCF_ERROR_OTHER,
- errors.ERROR_FORMAT : err.message
- }
- done = self._makeCallback(done)
- service = self
- class EchoERRCommand(Command):
- def __init__(self):
- super(EchoERRCommand, self).__init__(service.channel, service, "echoERR", (map,))
- def done(self, error, args):
- err = None
- str = None
- if not error:
- assert len(args) == 2
- err = self.toError(args[0])
- str = args[1]
- done.doneEchoERR(self.token, error, err, str)
- return EchoERRCommand().token
-
- def getTestList(self, done):
- done = self._makeCallback(done)
- service = self
- class GetTestListCommand(Command):
- def __init__(self):
- super(GetTestListCommand, self).__init__(service.channel, service, "getTestList", None)
- def done(self, error, args):
- arr = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- arr = args[1]
- done.doneGetTestList(self.token, error, arr)
- return GetTestListCommand().token
-
- def runTest(self, s, done):
- done = self._makeCallback(done)
- service = self
- class RunTestCommand(Command):
- def __init__(self):
- super(RunTestCommand, self).__init__(service.channel, service, "runTest", (s,))
- def done(self, error, args):
- str = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- str = args[1]
- done.doneRunTest(self.token, error, str)
- return RunTestCommand().token
-
- def cancelTest(self, s, done):
- done = self._makeCallback(done)
- service = self
- class CancelTestCommand(Command):
- def __init__(self):
- super(CancelTestCommand, self).__init__(service.channel, service, "cancelTest", (s,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneCancelTest(self.token, error)
- return CancelTestCommand().token
-
- def getSymbol(self, context_id, symbol_name, done):
- done = self._makeCallback(done)
- service = self
- class GetSymbolCommand(Command):
- def __init__(self):
- super(GetSymbolCommand, self).__init__(service.channel, service, "getSymbol", (context_id, symbol_name))
- def done(self, error, args):
- sym = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- sym = _toSymbol(args[1])
- done.doneGetSymbol(self.token, error, sym)
- return GetSymbolCommand().token
-
- def createTestStreams(self, inp_buf_size, out_buf_size, done):
- done = self._makeCallback(done)
- service = self
- class CreateTestStreamsCommand(Command):
- def __init__(self):
- super(CreateTestStreamsCommand, self).__init__(service.channel, service, "createTestStreams", (inp_buf_size, out_buf_size))
- def done(self, error, args):
- inp_id = None
- out_id = None
- if not error:
- assert len(args) == 3
- error = self.toError(args[0])
- inp_id = args[1]
- out_id = args[2]
- done.doneCreateTestStreams(self.token, error, inp_id, out_id)
- return CreateTestStreamsCommand().token
-
- def disposeTestStream(self, id, done):
- done = self._makeCallback(done)
- service = self
- class DisposeTestStreamCommand(Command):
- def __init__(self):
- super(DisposeTestStreamCommand, self).__init__(service.channel, service, "disposeTestStream", (id,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneDisposeTestStream(self.token, error)
- return DisposeTestStreamCommand().token
-
- def not_implemented_command(self, done):
- done = self._makeCallback(done)
- service = self
- class NotImplementedCommand(Command):
- def __init__(self):
- super(NotImplementedCommand, self).__init__(service.channel, service, "not implemented command", None)
- def done(self, error, args):
- done.doneNotImplementedCommand(self.token, error)
- return NotImplementedCommand().token
-
-def _toSymbol(o):
- if o is None: return None
- return diagnostics.Symbol(o)
+# *******************************************************************************
+# * Copyright (c) 2011 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
+# *******************************************************************************
+
+import time
+from tcf import errors
+from tcf.services import diagnostics
+from tcf.channel.Command import Command
+
+class DiagnosticsProxy(diagnostics.DiagnosticsService):
+ def __init__(self, channel):
+ self.channel = channel
+
+ def echo(self, s, done):
+ done = self._makeCallback(done)
+ service = self
+ class EchoCommand(Command):
+ def __init__(self):
+ super(EchoCommand, self).__init__(service.channel, service, "echo", (s,))
+ def done(self, error, args):
+ str = None
+ if not error:
+ assert len(args) == 1
+ str = args[0]
+ done.doneEcho(self.token, error, str)
+ return EchoCommand().token
+
+ def echoFP(self, n, done):
+ done = self._makeCallback(done)
+ service = self
+ class EchoFPCommand(Command):
+ def __init__(self):
+ super(EchoFPCommand, self).__init__(service.channel, service, "echoFP", (n,))
+ def done(self, error, args):
+ n = None
+ if not error:
+ assert len(args) == 1
+ n = args[0]
+ done.doneEchoFP(self.token, error, n)
+ return EchoFPCommand().token
+
+ def echoERR(self, err, done):
+ map = None
+ if isinstance(err, errors.ErrorReport):
+ map = err.getAttributes()
+ else:
+ map = {
+ errors.ERROR_TIME : int(time.time() * 1000),
+ errors.ERROR_CODE : errors.TCF_ERROR_OTHER,
+ errors.ERROR_FORMAT : err.message
+ }
+ done = self._makeCallback(done)
+ service = self
+ class EchoERRCommand(Command):
+ def __init__(self):
+ super(EchoERRCommand, self).__init__(service.channel, service, "echoERR", (map,))
+ def done(self, error, args):
+ err = None
+ str = None
+ if not error:
+ assert len(args) == 2
+ err = self.toError(args[0])
+ str = args[1]
+ done.doneEchoERR(self.token, error, err, str)
+ return EchoERRCommand().token
+
+ def getTestList(self, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetTestListCommand(Command):
+ def __init__(self):
+ super(GetTestListCommand, self).__init__(service.channel, service, "getTestList", None)
+ def done(self, error, args):
+ arr = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ arr = args[1]
+ done.doneGetTestList(self.token, error, arr)
+ return GetTestListCommand().token
+
+ def runTest(self, s, done):
+ done = self._makeCallback(done)
+ service = self
+ class RunTestCommand(Command):
+ def __init__(self):
+ super(RunTestCommand, self).__init__(service.channel, service, "runTest", (s,))
+ def done(self, error, args):
+ str = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ str = args[1]
+ done.doneRunTest(self.token, error, str)
+ return RunTestCommand().token
+
+ def cancelTest(self, s, done):
+ done = self._makeCallback(done)
+ service = self
+ class CancelTestCommand(Command):
+ def __init__(self):
+ super(CancelTestCommand, self).__init__(service.channel, service, "cancelTest", (s,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneCancelTest(self.token, error)
+ return CancelTestCommand().token
+
+ def getSymbol(self, context_id, symbol_name, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetSymbolCommand(Command):
+ def __init__(self):
+ super(GetSymbolCommand, self).__init__(service.channel, service, "getSymbol", (context_id, symbol_name))
+ def done(self, error, args):
+ sym = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ sym = _toSymbol(args[1])
+ done.doneGetSymbol(self.token, error, sym)
+ return GetSymbolCommand().token
+
+ def createTestStreams(self, inp_buf_size, out_buf_size, done):
+ done = self._makeCallback(done)
+ service = self
+ class CreateTestStreamsCommand(Command):
+ def __init__(self):
+ super(CreateTestStreamsCommand, self).__init__(service.channel, service, "createTestStreams", (inp_buf_size, out_buf_size))
+ def done(self, error, args):
+ inp_id = None
+ out_id = None
+ if not error:
+ assert len(args) == 3
+ error = self.toError(args[0])
+ inp_id = args[1]
+ out_id = args[2]
+ done.doneCreateTestStreams(self.token, error, inp_id, out_id)
+ return CreateTestStreamsCommand().token
+
+ def disposeTestStream(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class DisposeTestStreamCommand(Command):
+ def __init__(self):
+ super(DisposeTestStreamCommand, self).__init__(service.channel, service, "disposeTestStream", (id,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneDisposeTestStream(self.token, error)
+ return DisposeTestStreamCommand().token
+
+ def not_implemented_command(self, done):
+ done = self._makeCallback(done)
+ service = self
+ class NotImplementedCommand(Command):
+ def __init__(self):
+ super(NotImplementedCommand, self).__init__(service.channel, service, "not implemented command", None)
+ def done(self, error, args):
+ done.doneNotImplementedCommand(self.token, error)
+ return NotImplementedCommand().token
+
+def _toSymbol(o):
+ if o is None: return None
+ return diagnostics.Symbol(o)
diff --git a/python/src/tcf/services/remote/DisassemblyProxy.py b/python/src/tcf/services/remote/DisassemblyProxy.py
index 0ef9bbb04..205f28d03 100644
--- a/python/src/tcf/services/remote/DisassemblyProxy.py
+++ b/python/src/tcf/services/remote/DisassemblyProxy.py
@@ -1,58 +1,58 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 disassembly
-from tcf.channel.Command import Command
-
-class DisassemblyProxy(disassembly.DisassemblyService):
- def __init__(self, channel):
- self.channel = channel
-
- def getCapabilities(self, context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetCapabilitiesCommand(Command):
- def __init__(self):
- super(GetCapabilitiesCommand, self).__init__(service.channel, service, "getCapabilities", (context_id,))
- def done(self, error, args):
- arr = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- arr = args[1]
- done.doneGetCapabilities(self.token, error, arr)
- return GetCapabilitiesCommand().token
-
- def disassemble(self, context_id, addr, size, params, done):
- done = self._makeCallback(done)
- service = self
- class DisassembleCommand(Command):
- def __init__(self):
- super(DisassembleCommand, self).__init__(service.channel, service, "disassemble", (context_id, addr, size, params))
- def done(self, error, args):
- arr = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- arr = _toDisassemblyArray(args[1])
- done.doneDisassemble(self.token, error, arr)
- return DisassembleCommand().token
-
-
-def _toDisassemblyArray(o):
- if o is None: return None
- return map(_toDisassemblyLine, o)
-
-def _toDisassemblyLine(m):
- addr = m.get("Address")
- size = m.get("Size")
- instruction = m.get("Instruction")
- return disassembly.DisassemblyLine(addr, size, instruction)
+# *******************************************************************************
+# * Copyright (c) 2011 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 disassembly
+from tcf.channel.Command import Command
+
+class DisassemblyProxy(disassembly.DisassemblyService):
+ def __init__(self, channel):
+ self.channel = channel
+
+ def getCapabilities(self, context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetCapabilitiesCommand(Command):
+ def __init__(self):
+ super(GetCapabilitiesCommand, self).__init__(service.channel, service, "getCapabilities", (context_id,))
+ def done(self, error, args):
+ arr = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ arr = args[1]
+ done.doneGetCapabilities(self.token, error, arr)
+ return GetCapabilitiesCommand().token
+
+ def disassemble(self, context_id, addr, size, params, done):
+ done = self._makeCallback(done)
+ service = self
+ class DisassembleCommand(Command):
+ def __init__(self):
+ super(DisassembleCommand, self).__init__(service.channel, service, "disassemble", (context_id, addr, size, params))
+ def done(self, error, args):
+ arr = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ arr = _toDisassemblyArray(args[1])
+ done.doneDisassemble(self.token, error, arr)
+ return DisassembleCommand().token
+
+
+def _toDisassemblyArray(o):
+ if o is None: return None
+ return map(_toDisassemblyLine, o)
+
+def _toDisassemblyLine(m):
+ addr = m.get("Address")
+ size = m.get("Size")
+ instruction = m.get("Instruction")
+ return disassembly.DisassemblyLine(addr, size, instruction)
diff --git a/python/src/tcf/services/remote/ExpressionsProxy.py b/python/src/tcf/services/remote/ExpressionsProxy.py
index 462756f3c..f8dfa8179 100644
--- a/python/src/tcf/services/remote/ExpressionsProxy.py
+++ b/python/src/tcf/services/remote/ExpressionsProxy.py
@@ -1,134 +1,134 @@
-# *******************************************************************************
-# * Copyright (c) 2011, 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 import channel
-from tcf.services import expressions
-from tcf.channel.Command import Command
-
-class ExpressionsProxy(expressions.ExpressionsService):
- def __init__(self, channel):
- self.channel = channel
- self.listeners = {}
-
- def assign(self, id, value, done):
- done = self._makeCallback(done)
- service = self
- value = bytearray(value)
- class AssignCommand(Command):
- def __init__(self):
- super(AssignCommand, self).__init__(service.channel, service, "assign", (id, value))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneAssign(self.token, error)
- return AssignCommand().token
-
- def create(self, parent_id, language, expression, done):
- done = self._makeCallback(done)
- service = self
- class CreateCommand(Command):
- def __init__(self):
- super(CreateCommand, self).__init__(service.channel, service, "create", (parent_id, language, expression))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- ctx = expressions.Expression(args[1])
- done.doneCreate(self.token, error, ctx)
- return CreateCommand().token
-
- def dispose(self, id, done):
- done = self._makeCallback(done)
- service = self
- class DisposeCommand(Command):
- def __init__(self):
- super(DisposeCommand, self).__init__(service.channel, service, "dispose", (id,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneDispose(self.token, error)
- return DisposeCommand().token
-
- def evaluate(self, id, done):
- done = self._makeCallback(done)
- service = self
- class EvalCommand(Command):
- def __init__(self):
- super(EvalCommand, self).__init__(service.channel, service, "evaluate", (id,))
- def done(self, error, args):
- value = None
- if not error:
- assert len(args) == 3
- value = channel.toByteArray(args[0])
- error = self.toError(args[1])
- props = args[2]
- done.doneEvaluate(self.token, error, expressions.Value(value, props))
- return EvalCommand().token
-
- def getChildren(self, parent_context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetChildrenCommand(Command):
- def __init__(self):
- super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
- def done(self, error, args):
- contexts = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- contexts = args[1]
- done.doneGetChildren(self.token, error, contexts)
- return GetChildrenCommand().token
-
- def getContext(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetContextCommand(Command):
- def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = expressions.Expression(service, args[1])
- done.doneGetContext(self.token, error, ctx)
- return GetContextCommand().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 == "valueChanged":
- assert len(args) == 1
- self.listener.valueChanged(args[0])
- else:
- raise IOError("Expressions service: unknown event: " + name);
- except Exception as x:
- self.service.channel.terminate(x)
+# *******************************************************************************
+# * Copyright (c) 2011, 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 import channel
+from tcf.services import expressions
+from tcf.channel.Command import Command
+
+class ExpressionsProxy(expressions.ExpressionsService):
+ def __init__(self, channel):
+ self.channel = channel
+ self.listeners = {}
+
+ def assign(self, id, value, done):
+ done = self._makeCallback(done)
+ service = self
+ value = bytearray(value)
+ class AssignCommand(Command):
+ def __init__(self):
+ super(AssignCommand, self).__init__(service.channel, service, "assign", (id, value))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneAssign(self.token, error)
+ return AssignCommand().token
+
+ def create(self, parent_id, language, expression, done):
+ done = self._makeCallback(done)
+ service = self
+ class CreateCommand(Command):
+ def __init__(self):
+ super(CreateCommand, self).__init__(service.channel, service, "create", (parent_id, language, expression))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ ctx = expressions.Expression(args[1])
+ done.doneCreate(self.token, error, ctx)
+ return CreateCommand().token
+
+ def dispose(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class DisposeCommand(Command):
+ def __init__(self):
+ super(DisposeCommand, self).__init__(service.channel, service, "dispose", (id,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneDispose(self.token, error)
+ return DisposeCommand().token
+
+ def evaluate(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class EvalCommand(Command):
+ def __init__(self):
+ super(EvalCommand, self).__init__(service.channel, service, "evaluate", (id,))
+ def done(self, error, args):
+ value = None
+ if not error:
+ assert len(args) == 3
+ value = channel.toByteArray(args[0])
+ error = self.toError(args[1])
+ props = args[2]
+ done.doneEvaluate(self.token, error, expressions.Value(value, props))
+ return EvalCommand().token
+
+ def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetChildrenCommand(Command):
+ def __init__(self):
+ super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
+ def done(self, error, args):
+ contexts = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ contexts = args[1]
+ done.doneGetChildren(self.token, error, contexts)
+ return GetChildrenCommand().token
+
+ def getContext(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = expressions.Expression(service, args[1])
+ done.doneGetContext(self.token, error, ctx)
+ return GetContextCommand().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 == "valueChanged":
+ assert len(args) == 1
+ self.listener.valueChanged(args[0])
+ else:
+ raise IOError("Expressions service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/FileSystemProxy.py b/python/src/tcf/services/remote/FileSystemProxy.py
index d0a274642..370625f69 100644
--- a/python/src/tcf/services/remote/FileSystemProxy.py
+++ b/python/src/tcf/services/remote/FileSystemProxy.py
@@ -1,509 +1,509 @@
-# *******************************************************************************
-# * Copyright (c) 2011, 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 import errors, channel
-from tcf.services import filesystem
-from tcf.channel.Command import Command
-
-class Status(filesystem.FileSystemException):
- def __init__(self, status_or_exception, message=None, attrs=None):
- if isinstance(status_or_exception, int):
- super(Status, self).__init__(message)
- self.status = status_or_exception
- self.attrs = attrs
- else:
- super(Status, self).__init__(status_or_exception)
- self.status = errors.TCF_ERROR_OTHER
- self.attrs = {}
-
- def getStatus(self):
- return self.status
-
- def getErrorCode(self):
- return self.attrs.get(errors.ERROR_CODE, 0)
-
- def getAltCode(self):
- return self.attrs.get(errors.ERROR_ALT_CODE, 0)
-
- def getAltOrg(self):
- return self.attrs.get(errors.ERROR_ALT_ORG)
-
- def getAttributes(self):
- return self.attrs
-
-class FileSystemCommand(Command):
- def __init__(self, service, command, args):
- super(FileSystemCommand, self).__init__(service.channel, service, command, args)
-
- def _toSFError(self, data):
- if data is None: return None
- error_code = map.get(errors.ERROR_CODE)
- cmd = self.getCommandString()
- if len(cmd) > 72: cmd = cmd[0, 72] + "..."
- s = Status(error_code,
- "TCF command exception:" +
- "\nCommand: " + cmd +
- "\nException: " + self.toErrorString(data) +
- "\nError code: " + error_code, map)
- caused_by = map.get(errors.ERROR_CAUSED_BY)
- if caused_by is not None: s.initCause(self.toError(caused_by, False))
- return s
-
-class FileSystemProxy(filesystem.FileSystemService):
- def __init__(self, channel):
- self.channel = channel
-
- def close(self, handle, done):
- assert handle.getService() is self
- done = self._makeCallback(done)
- id = handle.id
- service = self
- class CloseCommand(FileSystemCommand):
- def __init__(self):
- super(CloseCommand, self).__init__(service, "close", (id,))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneClose(self.token, s)
- return CloseCommand().token
-
- def setstat(self, path, attrs, done):
- done = self._makeCallback(done)
- dt = _toObject(attrs)
- service = self
- class SetStatCommand(FileSystemCommand):
- def __init__(self):
- super(SetStatCommand, self).__init__(service, "setstat", (path, dt))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneSetStat(self.token, s)
- return SetStatCommand().token
-
- def fsetstat(self, handle, attrs, done):
- done = self._makeCallback(done)
- assert handle.getService() is self
- id = handle.id
- dt = _toObject(attrs)
- service = self
- class FSetStatCommand(FileSystemCommand):
- def __init__(self):
- super(FSetStatCommand, self).__init__(service, "fsetstat", (id, dt))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneSetStat(self.token, s)
- return FSetStatCommand().token
-
- def stat(self, path, done):
- done = self._makeCallback(done)
- service = self
- class StatCommand(FileSystemCommand):
- def __init__(self):
- super(StatCommand, self).__init__(service, "stat", (path,))
- def done(self, error, args):
- s = None
- a = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 2
- s = self._toSFError(args[0])
- if not s: a = _toFileAttrs(args[1])
- done.doneStat(self.token, s, a)
- return StatCommand().token
-
- def fstat(self, handle, done):
- done = self._makeCallback(done)
- assert handle.getService() is self
- id = handle.id
- service = self
- class FStatCommand(FileSystemCommand):
- def __init__(self):
- super(FStatCommand, self).__init__(service, "fstat", (id,))
- def done(self, error, args):
- s = None
- a = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 2
- s = self._toSFError(args[0])
- if not s: a = _toFileAttrs(args[1])
- done.doneStat(self.token, s, a)
- return FStatCommand().token
-
- def lstat(self, path, done):
- done = self._makeCallback(done)
- service = self
- class LStatCommand(FileSystemCommand):
- def __init__(self):
- super(LStatCommand, self).__init__(service, "lstat", (path,))
- def done(self, error, args):
- s = None
- a = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 2
- s = self._toSFError(args[0])
- if not s: a = _toFileAttrs(args[1])
- done.doneStat(self.token, s, a)
- return LStatCommand().token
-
- def mkdir(self, path, attrs, done):
- done = self._makeCallback(done)
- dt = _toObject(attrs)
- service = self
- class MkDirCommand(FileSystemCommand):
- def __init__(self):
- super(MkDirCommand, self).__init__(service, "mkdir", (dt,))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneMkDir(self.token, s)
- return MkDirCommand().token
-
- def open(self, file_name, flags, attrs, done):
- done = self._makeCallback(done)
- dt = _toObject(attrs)
- service = self
- class OpenCommand(FileSystemCommand):
- def __init__(self):
- super(OpenCommand, self).__init__(service, "open", (file_name, flags, dt))
- def done(self, error, args):
- s = None
- h = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 2
- s = self._toSFError(args[0])
- if not s: h = service._toFileHandle(args[1])
- done.doneOpen(self.token, s, h)
- return OpenCommand().token
-
- def opendir(self, path, done):
- done = self._makeCallback(done)
- service = self
- class OpenDirCommand(FileSystemCommand):
- def __init__(self):
- super(OpenDirCommand, self).__init__(service, "opendir", (path,))
- def done(self, error, args):
- s = None
- h = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 2
- s = self._toSFError(args[0])
- if not s: h = service._toFileHandle(args[1])
- done.doneOpen(self.token, s, h)
- return OpenDirCommand().token
-
- def read(self, handle, offset, len, done):
- assert handle.getService() is self
- done = self._makeCallback(done)
- id = handle.id
- service = self
- class ReadCommand(FileSystemCommand):
- def __init__(self):
- super(ReadCommand, self).__init__(service, "read", (id, offset, len))
- def done(self, error, args):
- s = None
- b = None
- eof = False
- if error:
- s = Status(error)
- else:
- assert len(args) == 3
- s = self._toSFError(args[1])
- if not s:
- b = channel.toByteArray(args[0])
- eof = args[2]
- done.doneRead(self.token, s, b, eof)
- return ReadCommand().token
-
- def readdir(self, handle, done):
- assert handle.getService() is self
- done = self._makeCallback(done)
- id = handle.id
- service = self
- class ReadDirCommand(FileSystemCommand):
- def __init__(self):
- super(ReadDirCommand, self).__init__(service, "readdir", (id,))
- def done(self, error, args):
- s = None
- b = None
- eof = False
- if error:
- s = Status(error)
- else:
- assert len(args) == 3
- s = self._toSFError(args[1])
- if not s:
- b = _toDirEntryArray(args[0])
- eof = args[2]
- done.doneReadDir(self.token, s, b, eof)
- return ReadDirCommand().token
-
- def roots(self, done):
- done = self._makeCallback(done)
- service = self
- class RootCommand(FileSystemCommand):
- def __init__(self):
- super(RootCommand, self).__init__(service, "roots", None)
- def done(self, error, args):
- s = None
- b = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 2
- s = self._toSFError(args[1])
- if not s:
- b = _toDirEntryArray(args[0])
- done.doneRoots(self.token, s, b)
- return RootCommand().token
-
- def readlink(self, path, done):
- done = self._makeCallback(done)
- service = self
- class ReadLinkCommand(FileSystemCommand):
- def __init__(self):
- super(ReadLinkCommand, self).__init__(service, "readlink", (path,))
- def done(self, error, args):
- s = None
- p = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 2
- s = self._toSFError(args[0])
- if not s:
- p = args[1]
- done.doneReadLink(self.token, s, p)
- return ReadLinkCommand().token
-
- def realpath(self, path, done):
- done = self._makeCallback(done)
- service = self
- class RealPathCommand(FileSystemCommand):
- def __init__(self):
- super(RealPathCommand, self).__init__(service, "realpath", (path,))
- def done(self, error, args):
- s = None
- p = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 2
- s = self._toSFError(args[0])
- if not s:
- p = args[1]
- done.doneRealPath(self.token, s, p)
- return RealPathCommand().token
-
- def remove(self, file_name, done):
- done = self._makeCallback(done)
- service = self
- class RemoveCommand(FileSystemCommand):
- def __init__(self):
- super(RemoveCommand, self).__init__(service, "remove", (file_name,))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneRemove(self.token, s)
- return RemoveCommand().token
-
- def rename(self, old_path, new_path, done):
- done = self._makeCallback(done)
- service = self
- class RenameCommand(FileSystemCommand):
- def __init__(self):
- super(RenameCommand, self).__init__(service, "rename", (old_path, new_path))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneRename(self.token, s)
- return RenameCommand().token
-
- def rmdir(self, path, done):
- done = self._makeCallback(done)
- service = self
- class RmDirCommand(FileSystemCommand):
- def __init__(self):
- super(RmDirCommand, self).__init__(service, "rmdir", (path,))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneRemove(self.token, s)
- return RmDirCommand().token
-
- def symlink(self, link_path, target_path, done):
- done = self._makeCallback(done)
- service = self
- class SymLinkCommand(FileSystemCommand):
- def __init__(self):
- super(SymLinkCommand, self).__init__(service, "symlink", (link_path, target_path))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneSymLink(self.token, s)
- return SymLinkCommand().token
-
- 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
- class WriteCommand(FileSystemCommand):
- def __init__(self):
- super(WriteCommand, self).__init__(service, "write", (id, offset, binary))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneWrite(self.token, s)
- 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):
- super(CopyCommand, self).__init__(service, "copy",
- (id, src_path, dst_path, copy_permissions, copy_uidgid))
- def done(self, error, args):
- s = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 1
- s = self._toSFError(args[0])
- done.doneCopy(self.token, s)
- return CopyCommand().token
-
- def user(self, done):
- done = self._makeCallback(done)
- service = self
- class UserCommand(FileSystemCommand):
- def __init__(self):
- super(UserCommand, self).__init__(service, "user", None)
- def done(self, error, args):
- s = None
- r_uid = 0
- e_uid = 0
- r_gid = 0
- e_gid = 0
- home = None
- if error:
- s = Status(error)
- else:
- assert len(args) == 5
- r_uid, e_uid, r_gid, e_gid, home = args
- done.doneUser(self.token, s, r_uid, e_uid, r_gid, e_gid, home)
- return UserCommand().token
-
- def _toFileHandle(self, o):
- if o is None: return None
- return filesystem.FileHandle(self, o)
-
-def _toObject(attrs):
- if attrs is None: return None
- m = {}
- if attrs.attributes is not None: m.update(attrs.attributes)
- if (attrs.flags & filesystem.ATTR_SIZE) != 0:
- m["Size"] = attrs.size
- if (attrs.flags & filesystem.ATTR_UIDGID) != 0:
- m["UID"] = attrs.uid
- m["GID"] = attrs.gid
- if (attrs.flags & filesystem.ATTR_PERMISSIONS) != 0:
- m["Permissions"] = attrs.permissions
- if (attrs.flags & filesystem.ATTR_ACMODTIME) != 0:
- m["ATime"] = attrs.atime
- m["MTime"] = attrs.mtime
- return m
-
-def _toFileAttrs(m):
- if m is None: return None
- flags = 0
- size = 0
- uid = 0
- gid = 0
- permissions = 0
- atime = 0
- mtime = 0
- n = m.pop("Size", None)
- if n is not None:
- size = n
- flags |= filesystem.ATTR_SIZE
- n1 = m.pop("UID", None)
- n2 = m.pop("GID", None)
- if n1 is not None and n2 is not None:
- uid = n1
- gid = n2
- flags |= filesystem.ATTR_UIDGID
- n = m.pop("Permissions", None)
- if n is not None:
- permissions = n
- flags |= filesystem.ATTR_PERMISSIONS
- n1 = m.pop("ATime", None)
- n2 = m.pop("MTime", None)
- if n1 is not None and n2 is not None:
- atime = n1
- mtime = n2
- flags |= filesystem.ATTR_ACMODTIME
- return filesystem.FileAttrs(flags, size, uid, gid, permissions, atime, mtime, m)
-
-def _toDirEntryArray(o):
- if o is None: return None
- res = []
- for m in o:
- entry = filesystem.DirEntry(m.get("FileName"), m.get("LongName"), _toFileAttrs(m.get("Attrs")))
- res.append(entry)
- return res
+# *******************************************************************************
+# * Copyright (c) 2011, 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 import errors, channel
+from tcf.services import filesystem
+from tcf.channel.Command import Command
+
+class Status(filesystem.FileSystemException):
+ def __init__(self, status_or_exception, message=None, attrs=None):
+ if isinstance(status_or_exception, int):
+ super(Status, self).__init__(message)
+ self.status = status_or_exception
+ self.attrs = attrs
+ else:
+ super(Status, self).__init__(status_or_exception)
+ self.status = errors.TCF_ERROR_OTHER
+ self.attrs = {}
+
+ def getStatus(self):
+ return self.status
+
+ def getErrorCode(self):
+ return self.attrs.get(errors.ERROR_CODE, 0)
+
+ def getAltCode(self):
+ return self.attrs.get(errors.ERROR_ALT_CODE, 0)
+
+ def getAltOrg(self):
+ return self.attrs.get(errors.ERROR_ALT_ORG)
+
+ def getAttributes(self):
+ return self.attrs
+
+class FileSystemCommand(Command):
+ def __init__(self, service, command, args):
+ super(FileSystemCommand, self).__init__(service.channel, service, command, args)
+
+ def _toSFError(self, data):
+ if data is None: return None
+ error_code = map.get(errors.ERROR_CODE)
+ cmd = self.getCommandString()
+ if len(cmd) > 72: cmd = cmd[0, 72] + "..."
+ s = Status(error_code,
+ "TCF command exception:" +
+ "\nCommand: " + cmd +
+ "\nException: " + self.toErrorString(data) +
+ "\nError code: " + error_code, map)
+ caused_by = map.get(errors.ERROR_CAUSED_BY)
+ if caused_by is not None: s.initCause(self.toError(caused_by, False))
+ return s
+
+class FileSystemProxy(filesystem.FileSystemService):
+ def __init__(self, channel):
+ self.channel = channel
+
+ def close(self, handle, done):
+ assert handle.getService() is self
+ done = self._makeCallback(done)
+ id = handle.id
+ service = self
+ class CloseCommand(FileSystemCommand):
+ def __init__(self):
+ super(CloseCommand, self).__init__(service, "close", (id,))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneClose(self.token, s)
+ return CloseCommand().token
+
+ def setstat(self, path, attrs, done):
+ done = self._makeCallback(done)
+ dt = _toObject(attrs)
+ service = self
+ class SetStatCommand(FileSystemCommand):
+ def __init__(self):
+ super(SetStatCommand, self).__init__(service, "setstat", (path, dt))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneSetStat(self.token, s)
+ return SetStatCommand().token
+
+ def fsetstat(self, handle, attrs, done):
+ done = self._makeCallback(done)
+ assert handle.getService() is self
+ id = handle.id
+ dt = _toObject(attrs)
+ service = self
+ class FSetStatCommand(FileSystemCommand):
+ def __init__(self):
+ super(FSetStatCommand, self).__init__(service, "fsetstat", (id, dt))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneSetStat(self.token, s)
+ return FSetStatCommand().token
+
+ def stat(self, path, done):
+ done = self._makeCallback(done)
+ service = self
+ class StatCommand(FileSystemCommand):
+ def __init__(self):
+ super(StatCommand, self).__init__(service, "stat", (path,))
+ def done(self, error, args):
+ s = None
+ a = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 2
+ s = self._toSFError(args[0])
+ if not s: a = _toFileAttrs(args[1])
+ done.doneStat(self.token, s, a)
+ return StatCommand().token
+
+ def fstat(self, handle, done):
+ done = self._makeCallback(done)
+ assert handle.getService() is self
+ id = handle.id
+ service = self
+ class FStatCommand(FileSystemCommand):
+ def __init__(self):
+ super(FStatCommand, self).__init__(service, "fstat", (id,))
+ def done(self, error, args):
+ s = None
+ a = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 2
+ s = self._toSFError(args[0])
+ if not s: a = _toFileAttrs(args[1])
+ done.doneStat(self.token, s, a)
+ return FStatCommand().token
+
+ def lstat(self, path, done):
+ done = self._makeCallback(done)
+ service = self
+ class LStatCommand(FileSystemCommand):
+ def __init__(self):
+ super(LStatCommand, self).__init__(service, "lstat", (path,))
+ def done(self, error, args):
+ s = None
+ a = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 2
+ s = self._toSFError(args[0])
+ if not s: a = _toFileAttrs(args[1])
+ done.doneStat(self.token, s, a)
+ return LStatCommand().token
+
+ def mkdir(self, path, attrs, done):
+ done = self._makeCallback(done)
+ dt = _toObject(attrs)
+ service = self
+ class MkDirCommand(FileSystemCommand):
+ def __init__(self):
+ super(MkDirCommand, self).__init__(service, "mkdir", (dt,))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneMkDir(self.token, s)
+ return MkDirCommand().token
+
+ def open(self, file_name, flags, attrs, done):
+ done = self._makeCallback(done)
+ dt = _toObject(attrs)
+ service = self
+ class OpenCommand(FileSystemCommand):
+ def __init__(self):
+ super(OpenCommand, self).__init__(service, "open", (file_name, flags, dt))
+ def done(self, error, args):
+ s = None
+ h = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 2
+ s = self._toSFError(args[0])
+ if not s: h = service._toFileHandle(args[1])
+ done.doneOpen(self.token, s, h)
+ return OpenCommand().token
+
+ def opendir(self, path, done):
+ done = self._makeCallback(done)
+ service = self
+ class OpenDirCommand(FileSystemCommand):
+ def __init__(self):
+ super(OpenDirCommand, self).__init__(service, "opendir", (path,))
+ def done(self, error, args):
+ s = None
+ h = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 2
+ s = self._toSFError(args[0])
+ if not s: h = service._toFileHandle(args[1])
+ done.doneOpen(self.token, s, h)
+ return OpenDirCommand().token
+
+ def read(self, handle, offset, len, done):
+ assert handle.getService() is self
+ done = self._makeCallback(done)
+ id = handle.id
+ service = self
+ class ReadCommand(FileSystemCommand):
+ def __init__(self):
+ super(ReadCommand, self).__init__(service, "read", (id, offset, len))
+ def done(self, error, args):
+ s = None
+ b = None
+ eof = False
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 3
+ s = self._toSFError(args[1])
+ if not s:
+ b = channel.toByteArray(args[0])
+ eof = args[2]
+ done.doneRead(self.token, s, b, eof)
+ return ReadCommand().token
+
+ def readdir(self, handle, done):
+ assert handle.getService() is self
+ done = self._makeCallback(done)
+ id = handle.id
+ service = self
+ class ReadDirCommand(FileSystemCommand):
+ def __init__(self):
+ super(ReadDirCommand, self).__init__(service, "readdir", (id,))
+ def done(self, error, args):
+ s = None
+ b = None
+ eof = False
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 3
+ s = self._toSFError(args[1])
+ if not s:
+ b = _toDirEntryArray(args[0])
+ eof = args[2]
+ done.doneReadDir(self.token, s, b, eof)
+ return ReadDirCommand().token
+
+ def roots(self, done):
+ done = self._makeCallback(done)
+ service = self
+ class RootCommand(FileSystemCommand):
+ def __init__(self):
+ super(RootCommand, self).__init__(service, "roots", None)
+ def done(self, error, args):
+ s = None
+ b = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 2
+ s = self._toSFError(args[1])
+ if not s:
+ b = _toDirEntryArray(args[0])
+ done.doneRoots(self.token, s, b)
+ return RootCommand().token
+
+ def readlink(self, path, done):
+ done = self._makeCallback(done)
+ service = self
+ class ReadLinkCommand(FileSystemCommand):
+ def __init__(self):
+ super(ReadLinkCommand, self).__init__(service, "readlink", (path,))
+ def done(self, error, args):
+ s = None
+ p = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 2
+ s = self._toSFError(args[0])
+ if not s:
+ p = args[1]
+ done.doneReadLink(self.token, s, p)
+ return ReadLinkCommand().token
+
+ def realpath(self, path, done):
+ done = self._makeCallback(done)
+ service = self
+ class RealPathCommand(FileSystemCommand):
+ def __init__(self):
+ super(RealPathCommand, self).__init__(service, "realpath", (path,))
+ def done(self, error, args):
+ s = None
+ p = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 2
+ s = self._toSFError(args[0])
+ if not s:
+ p = args[1]
+ done.doneRealPath(self.token, s, p)
+ return RealPathCommand().token
+
+ def remove(self, file_name, done):
+ done = self._makeCallback(done)
+ service = self
+ class RemoveCommand(FileSystemCommand):
+ def __init__(self):
+ super(RemoveCommand, self).__init__(service, "remove", (file_name,))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneRemove(self.token, s)
+ return RemoveCommand().token
+
+ def rename(self, old_path, new_path, done):
+ done = self._makeCallback(done)
+ service = self
+ class RenameCommand(FileSystemCommand):
+ def __init__(self):
+ super(RenameCommand, self).__init__(service, "rename", (old_path, new_path))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneRename(self.token, s)
+ return RenameCommand().token
+
+ def rmdir(self, path, done):
+ done = self._makeCallback(done)
+ service = self
+ class RmDirCommand(FileSystemCommand):
+ def __init__(self):
+ super(RmDirCommand, self).__init__(service, "rmdir", (path,))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneRemove(self.token, s)
+ return RmDirCommand().token
+
+ def symlink(self, link_path, target_path, done):
+ done = self._makeCallback(done)
+ service = self
+ class SymLinkCommand(FileSystemCommand):
+ def __init__(self):
+ super(SymLinkCommand, self).__init__(service, "symlink", (link_path, target_path))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneSymLink(self.token, s)
+ return SymLinkCommand().token
+
+ 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
+ class WriteCommand(FileSystemCommand):
+ def __init__(self):
+ super(WriteCommand, self).__init__(service, "write", (id, offset, binary))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneWrite(self.token, s)
+ 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):
+ super(CopyCommand, self).__init__(service, "copy",
+ (id, src_path, dst_path, copy_permissions, copy_uidgid))
+ def done(self, error, args):
+ s = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 1
+ s = self._toSFError(args[0])
+ done.doneCopy(self.token, s)
+ return CopyCommand().token
+
+ def user(self, done):
+ done = self._makeCallback(done)
+ service = self
+ class UserCommand(FileSystemCommand):
+ def __init__(self):
+ super(UserCommand, self).__init__(service, "user", None)
+ def done(self, error, args):
+ s = None
+ r_uid = 0
+ e_uid = 0
+ r_gid = 0
+ e_gid = 0
+ home = None
+ if error:
+ s = Status(error)
+ else:
+ assert len(args) == 5
+ r_uid, e_uid, r_gid, e_gid, home = args
+ done.doneUser(self.token, s, r_uid, e_uid, r_gid, e_gid, home)
+ return UserCommand().token
+
+ def _toFileHandle(self, o):
+ if o is None: return None
+ return filesystem.FileHandle(self, o)
+
+def _toObject(attrs):
+ if attrs is None: return None
+ m = {}
+ if attrs.attributes is not None: m.update(attrs.attributes)
+ if (attrs.flags & filesystem.ATTR_SIZE) != 0:
+ m["Size"] = attrs.size
+ if (attrs.flags & filesystem.ATTR_UIDGID) != 0:
+ m["UID"] = attrs.uid
+ m["GID"] = attrs.gid
+ if (attrs.flags & filesystem.ATTR_PERMISSIONS) != 0:
+ m["Permissions"] = attrs.permissions
+ if (attrs.flags & filesystem.ATTR_ACMODTIME) != 0:
+ m["ATime"] = attrs.atime
+ m["MTime"] = attrs.mtime
+ return m
+
+def _toFileAttrs(m):
+ if m is None: return None
+ flags = 0
+ size = 0
+ uid = 0
+ gid = 0
+ permissions = 0
+ atime = 0
+ mtime = 0
+ n = m.pop("Size", None)
+ if n is not None:
+ size = n
+ flags |= filesystem.ATTR_SIZE
+ n1 = m.pop("UID", None)
+ n2 = m.pop("GID", None)
+ if n1 is not None and n2 is not None:
+ uid = n1
+ gid = n2
+ flags |= filesystem.ATTR_UIDGID
+ n = m.pop("Permissions", None)
+ if n is not None:
+ permissions = n
+ flags |= filesystem.ATTR_PERMISSIONS
+ n1 = m.pop("ATime", None)
+ n2 = m.pop("MTime", None)
+ if n1 is not None and n2 is not None:
+ atime = n1
+ mtime = n2
+ flags |= filesystem.ATTR_ACMODTIME
+ return filesystem.FileAttrs(flags, size, uid, gid, permissions, atime, mtime, m)
+
+def _toDirEntryArray(o):
+ if o is None: return None
+ res = []
+ for m in o:
+ entry = filesystem.DirEntry(m.get("FileName"), m.get("LongName"), _toFileAttrs(m.get("Attrs")))
+ res.append(entry)
+ return res
diff --git a/python/src/tcf/services/remote/LineNumbersProxy.py b/python/src/tcf/services/remote/LineNumbersProxy.py
index ad567d225..7452cc761 100644
--- a/python/src/tcf/services/remote/LineNumbersProxy.py
+++ b/python/src/tcf/services/remote/LineNumbersProxy.py
@@ -1,67 +1,67 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 linenumbers
-from tcf.channel.Command import Command
-
-class LineNumbersProxy(linenumbers.LineNumbersService):
-
- def __init__(self, channel):
- 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):
- super(MapCommand, self).__init__(service.channel, service,
- "mapToSource", (context_id, start_address, end_address))
- def done(self, error, args):
- arr = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- arr = _toCodeAreaArray(args[1])
- done.doneMapToSource(self.token, error, arr)
- return MapCommand().token
-
- def mapToMemory(self, context_id, file, line, column, done):
- done = self._makeCallback(done)
- service = self
- class MapCommand(Command):
- def __init__(self):
- super(MapCommand, self).__init__(service.channel, service,
- "mapToMemory", (context_id, file, line, column))
- def done(self, error, args):
- arr = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- arr = _toCodeAreaArray(args[1])
- done.doneMapToMemory(self.token, error, arr)
- return MapCommand().token
-
-def _toCodeAreaArray(o):
- if not o: return None
- arr = []
- directory = None
- file = None
- for area in o:
- directory = area.get("Dir", directory)
- file = area.get("File", file)
- arr.append(linenumbers.CodeArea(directory, file,
- area.get("SLine", 0), area.get("SCol", 0),
- area.get("ELine", 0), area.get("ECol", 0),
- area.get("SAddr"), area.get("EAddr"),
- area.get("ISA", 0),
- area.get("IsStmt"), area.get("BasicBlock"),
- area.get("PrologueEnd"), area.get("EpilogueBegin")))
- return arr
+# *******************************************************************************
+# * Copyright (c) 2011 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 linenumbers
+from tcf.channel.Command import Command
+
+class LineNumbersProxy(linenumbers.LineNumbersService):
+
+ def __init__(self, channel):
+ 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):
+ super(MapCommand, self).__init__(service.channel, service,
+ "mapToSource", (context_id, start_address, end_address))
+ def done(self, error, args):
+ arr = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ arr = _toCodeAreaArray(args[1])
+ done.doneMapToSource(self.token, error, arr)
+ return MapCommand().token
+
+ def mapToMemory(self, context_id, file, line, column, done):
+ done = self._makeCallback(done)
+ service = self
+ class MapCommand(Command):
+ def __init__(self):
+ super(MapCommand, self).__init__(service.channel, service,
+ "mapToMemory", (context_id, file, line, column))
+ def done(self, error, args):
+ arr = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ arr = _toCodeAreaArray(args[1])
+ done.doneMapToMemory(self.token, error, arr)
+ return MapCommand().token
+
+def _toCodeAreaArray(o):
+ if not o: return None
+ arr = []
+ directory = None
+ file = None
+ for area in o:
+ directory = area.get("Dir", directory)
+ file = area.get("File", file)
+ arr.append(linenumbers.CodeArea(directory, file,
+ area.get("SLine", 0), area.get("SCol", 0),
+ area.get("ELine", 0), area.get("ECol", 0),
+ area.get("SAddr"), area.get("EAddr"),
+ area.get("ISA", 0),
+ area.get("IsStmt"), area.get("BasicBlock"),
+ area.get("PrologueEnd"), area.get("EpilogueBegin")))
+ return arr
diff --git a/python/src/tcf/services/remote/LocatorProxy.py b/python/src/tcf/services/remote/LocatorProxy.py
index 8072118c1..d9963686e 100644
--- a/python/src/tcf/services/remote/LocatorProxy.py
+++ b/python/src/tcf/services/remote/LocatorProxy.py
@@ -1,149 +1,149 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 import protocol, peer, channel
-from tcf.services import locator
-from tcf.channel.Command import Command
-
-class Peer(peer.TransientPeer):
- def __init__(self, parent, attrs):
- super(Peer, self).__init__(attrs)
- self.parent = parent
- def openChannel(self):
- assert protocol.isDispatchThread()
- c = self.parent.openChannel()
- c.redirect(self.getID())
- return c
-
-class ChannelEventListener(channel.EventListener):
- def __init__(self, proxy):
- self.proxy = proxy
- self.channel = proxy.channel
- def event(self, name, data):
- try:
- args = channel.fromJSONSequence(data)
- if name == "peerAdded":
- assert len(args) == 1
- _peer = Peer(self.channel.getRemotePeer(), args[0])
- if self.proxy.peers.get(_peer.getID()):
- protocol.log("Invalid peerAdded event", Exception())
- return
- self.proxy.peers[_peer.getID()] = _peer
- for l in self.proxy.listeners:
- try:
- l.peerAdded(_peer)
- except Exception as x:
- protocol.log("Unhandled exception in Locator listener", x)
- elif name == "peerChanged":
- assert len(args) == 1
- m = args[0]
- if not m: raise Exception("Locator service: invalid peerChanged event - no peer ID")
- _peer = self.proxy.peers.get(m.get(peer.ATTR_ID))
- if not _peer: return
- self.proxy.peers[_peer.getID()] = _peer
- for l in self.proxy.listeners:
- try:
- l.peerChanged(_peer)
- except Exception as x:
- protocol.log("Unhandled exception in Locator listener", x)
- elif name == "peerRemoved":
- assert len(args) == 1
- id = args[0]
- _peer = self.proxy.peers.get(id)
- if not _peer: return
- del self.proxy.peers[id]
- for l in self.proxy.listeners:
- try:
- l.peerRemoved(id)
- except Exception as x:
- protocol.log("Unhandled exception in Locator listener", x)
- elif name == "peerHeartBeat":
- assert len(args) == 1
- id = args[0]
- _peer = self.proxy.peers.get(id)
- if not _peer: return
- for l in self.proxy.listeners:
- try:
- l.peerHeartBeat(id)
- except Exception as x:
- protocol.log("Unhandled exception in Locator listener", x)
- else:
- raise IOError("Locator service: unknown event: " + name)
- except Exception as x:
- self.channel.terminate(x)
-
-class LocatorProxy(locator.LocatorService):
- 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)
-
- def getPeers(self):
- return self.peers
-
- def redirect(self, _peer, done):
- done = self._makeCallback(done)
- service = self
- class RedirectCommand(Command):
- def __init__(self):
- super(RedirectCommand, self).__init__(service.channel, service, "redirect", [_peer])
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneRedirect(self.token, error)
- return RedirectCommand().token
-
- def sync(self, done):
- done = self._makeCallback(done)
- service = self
- class SyncCommand(Command):
- def __init__(self):
- super(SyncCommand, self).__init__(service.channel, service, "sync", None)
- def done(self, error, args):
- if error: service.channel.terminate(error)
- done.doneSync(self.token)
- return SyncCommand().token
-
- def addListener(self, listener):
- self.listeners.append(listener)
- if not self.get_peers_done:
- service = self
- class GetPeersCommand(Command):
- def __init__(self):
- super(GetPeersCommand, self).__init__(service.channel, service, "getPeers", None)
- def done(self, error, args):
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if error:
- protocol.log("Locator error", error)
- return
- c = args[1]
- if c:
- for m in c:
- id = m.get(peer.ATTR_ID)
- if service.peers.get(id): continue;
- _peer = Peer(service.channel.getRemotePeer(), m)
- service.peers[id] = _peer
- for l in service.listeners:
- try:
- l.peerAdded(_peer)
- except Exception as x:
- protocol.log("Unhandled exception in Locator listener", x)
- GetPeersCommand()
- self.get_peers_done = True
-
- def removeListener(self, listener):
- self.listeners.remove(listener)
+# *******************************************************************************
+# * Copyright (c) 2011 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 import protocol, peer, channel
+from tcf.services import locator
+from tcf.channel.Command import Command
+
+class Peer(peer.TransientPeer):
+ def __init__(self, parent, attrs):
+ super(Peer, self).__init__(attrs)
+ self.parent = parent
+ def openChannel(self):
+ assert protocol.isDispatchThread()
+ c = self.parent.openChannel()
+ c.redirect(self.getID())
+ return c
+
+class ChannelEventListener(channel.EventListener):
+ def __init__(self, proxy):
+ self.proxy = proxy
+ self.channel = proxy.channel
+ def event(self, name, data):
+ try:
+ args = channel.fromJSONSequence(data)
+ if name == "peerAdded":
+ assert len(args) == 1
+ _peer = Peer(self.channel.getRemotePeer(), args[0])
+ if self.proxy.peers.get(_peer.getID()):
+ protocol.log("Invalid peerAdded event", Exception())
+ return
+ self.proxy.peers[_peer.getID()] = _peer
+ for l in self.proxy.listeners:
+ try:
+ l.peerAdded(_peer)
+ except Exception as x:
+ protocol.log("Unhandled exception in Locator listener", x)
+ elif name == "peerChanged":
+ assert len(args) == 1
+ m = args[0]
+ if not m: raise Exception("Locator service: invalid peerChanged event - no peer ID")
+ _peer = self.proxy.peers.get(m.get(peer.ATTR_ID))
+ if not _peer: return
+ self.proxy.peers[_peer.getID()] = _peer
+ for l in self.proxy.listeners:
+ try:
+ l.peerChanged(_peer)
+ except Exception as x:
+ protocol.log("Unhandled exception in Locator listener", x)
+ elif name == "peerRemoved":
+ assert len(args) == 1
+ id = args[0]
+ _peer = self.proxy.peers.get(id)
+ if not _peer: return
+ del self.proxy.peers[id]
+ for l in self.proxy.listeners:
+ try:
+ l.peerRemoved(id)
+ except Exception as x:
+ protocol.log("Unhandled exception in Locator listener", x)
+ elif name == "peerHeartBeat":
+ assert len(args) == 1
+ id = args[0]
+ _peer = self.proxy.peers.get(id)
+ if not _peer: return
+ for l in self.proxy.listeners:
+ try:
+ l.peerHeartBeat(id)
+ except Exception as x:
+ protocol.log("Unhandled exception in Locator listener", x)
+ else:
+ raise IOError("Locator service: unknown event: " + name)
+ except Exception as x:
+ self.channel.terminate(x)
+
+class LocatorProxy(locator.LocatorService):
+ 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)
+
+ def getPeers(self):
+ return self.peers
+
+ def redirect(self, _peer, done):
+ done = self._makeCallback(done)
+ service = self
+ class RedirectCommand(Command):
+ def __init__(self):
+ super(RedirectCommand, self).__init__(service.channel, service, "redirect", [_peer])
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneRedirect(self.token, error)
+ return RedirectCommand().token
+
+ def sync(self, done):
+ done = self._makeCallback(done)
+ service = self
+ class SyncCommand(Command):
+ def __init__(self):
+ super(SyncCommand, self).__init__(service.channel, service, "sync", None)
+ def done(self, error, args):
+ if error: service.channel.terminate(error)
+ done.doneSync(self.token)
+ return SyncCommand().token
+
+ def addListener(self, listener):
+ self.listeners.append(listener)
+ if not self.get_peers_done:
+ service = self
+ class GetPeersCommand(Command):
+ def __init__(self):
+ super(GetPeersCommand, self).__init__(service.channel, service, "getPeers", None)
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if error:
+ protocol.log("Locator error", error)
+ return
+ c = args[1]
+ if c:
+ for m in c:
+ id = m.get(peer.ATTR_ID)
+ if service.peers.get(id): continue;
+ _peer = Peer(service.channel.getRemotePeer(), m)
+ service.peers[id] = _peer
+ for l in service.listeners:
+ try:
+ l.peerAdded(_peer)
+ except Exception as x:
+ protocol.log("Unhandled exception in Locator listener", x)
+ GetPeersCommand()
+ self.get_peers_done = True
+
+ def removeListener(self, listener):
+ self.listeners.remove(listener)
diff --git a/python/src/tcf/services/remote/MemoryMapProxy.py b/python/src/tcf/services/remote/MemoryMapProxy.py
index 8bf153bac..34aab1d5f 100644
--- a/python/src/tcf/services/remote/MemoryMapProxy.py
+++ b/python/src/tcf/services/remote/MemoryMapProxy.py
@@ -1,82 +1,82 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 import channel
-from tcf.services import memorymap
-from tcf.channel.Command import Command
-
-class MemoryMapProxy(memorymap.MemoryMapService):
- def __init__(self, channel):
- self.channel = channel
- self.listeners = {}
-
- def get(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetCommand(Command):
- def __init__(self):
- super(GetCommand, self).__init__(service.channel, service, "get", (id,))
- def done(self, error, args):
- map = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: map = _toMemoryMap(args[1])
- done.doneGet(self.token, error, map)
- return GetCommand().token
-
- def set(self, id, map, done):
- if isinstance(map, memorymap.MemoryRegion) or isinstance(map, dict):
- map = (map,)
- done = self._makeCallback(done)
- service = self
- class SetCommand(Command):
- def __init__(self):
- super(SetCommand, self).__init__(service.channel, service, "set", (id, map))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneSet(self.token, error)
- return SetCommand().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.pop(listener, None)
- if l: 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 == "changed":
- assert len(args) == 1
- self.listener.changed(args[0])
- else:
- raise IOError("MemoryMap service: unknown event: " + name);
- except Exception as x:
- self.service.channel.terminate(x)
-
-
-def _toMemoryMap(o):
- if o is None: return None
- return map(_toMemoryRegion, o)
-
-def _toMemoryRegion(o):
- if o is None: return None
- return memorymap.MemoryRegion(o)
+# *******************************************************************************
+# * Copyright (c) 2011 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 import channel
+from tcf.services import memorymap
+from tcf.channel.Command import Command
+
+class MemoryMapProxy(memorymap.MemoryMapService):
+ def __init__(self, channel):
+ self.channel = channel
+ self.listeners = {}
+
+ def get(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetCommand(Command):
+ def __init__(self):
+ super(GetCommand, self).__init__(service.channel, service, "get", (id,))
+ def done(self, error, args):
+ map = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: map = _toMemoryMap(args[1])
+ done.doneGet(self.token, error, map)
+ return GetCommand().token
+
+ def set(self, id, map, done):
+ if isinstance(map, memorymap.MemoryRegion) or isinstance(map, dict):
+ map = (map,)
+ done = self._makeCallback(done)
+ service = self
+ class SetCommand(Command):
+ def __init__(self):
+ super(SetCommand, self).__init__(service.channel, service, "set", (id, map))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneSet(self.token, error)
+ return SetCommand().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.pop(listener, None)
+ if l: 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 == "changed":
+ assert len(args) == 1
+ self.listener.changed(args[0])
+ else:
+ raise IOError("MemoryMap service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)
+
+
+def _toMemoryMap(o):
+ if o is None: return None
+ return map(_toMemoryRegion, o)
+
+def _toMemoryRegion(o):
+ if o is None: return None
+ return memorymap.MemoryRegion(o)
diff --git a/python/src/tcf/services/remote/MemoryProxy.py b/python/src/tcf/services/remote/MemoryProxy.py
index ebf8a2420..62f01bdcf 100644
--- a/python/src/tcf/services/remote/MemoryProxy.py
+++ b/python/src/tcf/services/remote/MemoryProxy.py
@@ -1,242 +1,242 @@
-# *******************************************************************************
-# * Copyright (c) 2011, 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 import errors, channel
-from tcf.services import memory
-from tcf.channel.Command import Command
-
-class Range(object):
- offs = 0
- size = 0
- stat = 0
- msg = None
- def __cmp__(self, o):
- if self.offs < o.offs: return -1
- if self.offs > o.offs: return +1
- return 0
-
-class MemoryErrorReport(errors.ErrorReport, memory.MemoryError, memory.ErrorOffset):
- def __init__(self, msg, attrs, addr, ranges):
- super(MemoryErrorReport, self).__init__(msg, attrs)
- if ranges is None:
- self.ranges = None
- else:
- self.ranges = []
- for m in ranges:
- r = Range()
- x = m.get(memory.ErrorOffset.RANGE_KEY_ADDR)
- if isinstance(x, str):
- y = int(x)
- else:
- y = x
- r.offs = y - addr
- r.size = m.get(memory.ErrorOffset.RANGE_KEY_SIZE)
- r.stat = m.get(memory.ErrorOffset.RANGE_KEY_STAT)
- r.msg = errors.toErrorString(m.get(memory.ErrorOffset.RANGE_KEY_MSG))
- assert r.offs >= 0
- assert r.size >= 0
- self.ranges.append(r)
- self.ranges.sort()
-
- def getMessage(self, offset):
- if self.ranges is None: return None
- l = 0
- h = len(self.ranges) - 1
- while l <= h:
- n = (l + h) / 2
- r = self.ranges[n]
- if r.offs > offset:
- h = n - 1
- elif offset >= r.offs + r.size:
- l = n + 1
- else:
- return r.msg
- return None
-
- def getStatus(self, offset):
- if self.ranges is None: return memory.ErrorOffset.BYTE_UNKNOWN
- l = 0
- h = len(self.ranges) - 1
- while l <= h:
- n = (l + h) / 2
- r = self.ranges[n]
- if r.offs > offset:
- h = n - 1
- elif offset >= r.offs + r.size:
- l = n + 1
- else:
- return r.stat
- return memory.ErrorOffset.BYTE_UNKNOWN
-
-
-class MemContext(memory.MemoryContext):
- def __init__(self, service, props):
- super(MemContext, self).__init__(props)
- self.service = service
-
- def fill(self, addr, word_size, value, size, mode, done):
- service = self.service
- id = self.getID()
- done = service._makeCallback(done)
- class FillCommand(MemoryCommand):
- def __init__(self):
- super(FillCommand, self).__init__(service,
- "fill", (id, addr, word_size, size, mode, value))
- def done(self, error, args):
- e = None
- if error:
- e = memory.MemoryError(error.message)
- else:
- assert len(args) == 2
- e = self.toMemoryError(args[0], args[1])
- done.doneMemory(self.token, e)
- return FillCommand().token
-
- def get(self, addr, word_size, buf, offs, size, mode, done):
- service = self.service
- id = self.getID()
- done = service._makeCallback(done)
- class GetCommand(MemoryCommand):
- def __init__(self):
- super(GetCommand, self).__init__(service,
- "get", (id, addr, word_size, size, mode))
- def done(self, error, args):
- e = None
- if error:
- e = memory.MemoryError(error.message)
- else:
- assert len(args) == 3
- bytes = channel.toByteArray(args[0])
- assert len(bytes) <= size
- buf[offs:offs+len(bytes)] = bytes
- e = self.toMemoryError(args[1], args[2])
- done.doneMemory(self.token, e)
- return GetCommand().token
-
- def set(self, addr, word_size, buf, offs, size, mode, done):
- service = self.service
- id = self.getID()
- done = service._makeCallback(done)
- class SetCommand(MemoryCommand):
- def __init__(self):
- super(SetCommand, self).__init__(service,
- "set", (id, addr, word_size, size, mode, bytearray(buf[offs:offs:size])))
- def done(self, error, args):
- e = None
- if error:
- e = memory.MemoryError(error.message)
- else:
- assert len(args) == 2
- e = self.toMemoryError(args[1], args[2])
- done.doneMemory(self.token, e)
- return SetCommand().token
-
-class MemoryProxy(memory.MemoryService):
- def __init__(self, channel):
- self.channel = channel
- self.listeners = {}
-
- def getContext(self, context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetContextCommand(Command):
- def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (context_id,))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = MemContext(service, args[1])
- done.doneGetContext(self.token, error, ctx)
- return GetContextCommand().token
-
- def getChildren(self, parent_context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetChildrenCommand(Command):
- def __init__(self):
- super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
- def done(self, error, args):
- contexts = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- contexts = args[1]
- done.doneGetChildren(self.token, error, contexts)
- return GetChildrenCommand().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 MemoryCommand(Command):
- def __init__(self, service, cmd, args):
- super(MemoryCommand, self).__init__(service.channel, service, cmd, args)
- def toMemoryError(self, addr, data, ranges):
- if data is None: return None
- code = data.get(errors.ERROR_CODE)
- cmd = self.getCommandString()
- if len(cmd) > 72: cmd = cmd[0:72] + "..."
- e = MemoryErrorReport(
- "TCF command exception:\nCommand: %s\nException: %s\nError code: " % (
- cmd, self.toErrorString(data), code),
- map, addr, ranges)
- caused_by = data.get(errors.ERROR_CAUSED_BY)
- if caused_by is not None: e.caused_by = self.toError(caused_by, False)
- return e
-
-
-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 == "contextAdded":
- assert len(args) == 1
- self.listener.contextAdded(_toContextArray(self.service, args[0]))
- elif name == "contextChanged":
- assert len(args) == 1
- self.listener.contextChanged(_toContextArray(self.service, args[0]))
- elif name == "contextRemoved":
- assert len(args) == 1
- self.listener.contextRemoved(args[0])
- elif name == "memoryChanged":
- assert len(args) == 2
- self.listener.memoryChanged(args[0], _toAddrArray(args[1]), _toSizeArray(args[1]))
- else:
- raise IOError("Memory service: unknown event: " + name);
- except Exception as x:
- self.service.channel.terminate(x)
-
-
-def _toContextArray(svc, o):
- if o is None: return None
- ctx = []
- for m in o: ctx.append(MemContext(svc, m))
- return ctx
-
-def _toSizeArray(o):
- if o is None: return None
- return map(lambda m: m.get("size", 0), o)
-
-def _toAddrArray(o):
- if o is None: return None
- return map(lambda m: m.get("addr"), o)
+# *******************************************************************************
+# * Copyright (c) 2011, 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 import errors, channel
+from tcf.services import memory
+from tcf.channel.Command import Command
+
+class Range(object):
+ offs = 0
+ size = 0
+ stat = 0
+ msg = None
+ def __cmp__(self, o):
+ if self.offs < o.offs: return -1
+ if self.offs > o.offs: return +1
+ return 0
+
+class MemoryErrorReport(errors.ErrorReport, memory.MemoryError, memory.ErrorOffset):
+ def __init__(self, msg, attrs, addr, ranges):
+ super(MemoryErrorReport, self).__init__(msg, attrs)
+ if ranges is None:
+ self.ranges = None
+ else:
+ self.ranges = []
+ for m in ranges:
+ r = Range()
+ x = m.get(memory.ErrorOffset.RANGE_KEY_ADDR)
+ if isinstance(x, str):
+ y = int(x)
+ else:
+ y = x
+ r.offs = y - addr
+ r.size = m.get(memory.ErrorOffset.RANGE_KEY_SIZE)
+ r.stat = m.get(memory.ErrorOffset.RANGE_KEY_STAT)
+ r.msg = errors.toErrorString(m.get(memory.ErrorOffset.RANGE_KEY_MSG))
+ assert r.offs >= 0
+ assert r.size >= 0
+ self.ranges.append(r)
+ self.ranges.sort()
+
+ def getMessage(self, offset):
+ if self.ranges is None: return None
+ l = 0
+ h = len(self.ranges) - 1
+ while l <= h:
+ n = (l + h) / 2
+ r = self.ranges[n]
+ if r.offs > offset:
+ h = n - 1
+ elif offset >= r.offs + r.size:
+ l = n + 1
+ else:
+ return r.msg
+ return None
+
+ def getStatus(self, offset):
+ if self.ranges is None: return memory.ErrorOffset.BYTE_UNKNOWN
+ l = 0
+ h = len(self.ranges) - 1
+ while l <= h:
+ n = (l + h) / 2
+ r = self.ranges[n]
+ if r.offs > offset:
+ h = n - 1
+ elif offset >= r.offs + r.size:
+ l = n + 1
+ else:
+ return r.stat
+ return memory.ErrorOffset.BYTE_UNKNOWN
+
+
+class MemContext(memory.MemoryContext):
+ def __init__(self, service, props):
+ super(MemContext, self).__init__(props)
+ self.service = service
+
+ def fill(self, addr, word_size, value, size, mode, done):
+ service = self.service
+ id = self.getID()
+ done = service._makeCallback(done)
+ class FillCommand(MemoryCommand):
+ def __init__(self):
+ super(FillCommand, self).__init__(service,
+ "fill", (id, addr, word_size, size, mode, value))
+ def done(self, error, args):
+ e = None
+ if error:
+ e = memory.MemoryError(error.message)
+ else:
+ assert len(args) == 2
+ e = self.toMemoryError(args[0], args[1])
+ done.doneMemory(self.token, e)
+ return FillCommand().token
+
+ def get(self, addr, word_size, buf, offs, size, mode, done):
+ service = self.service
+ id = self.getID()
+ done = service._makeCallback(done)
+ class GetCommand(MemoryCommand):
+ def __init__(self):
+ super(GetCommand, self).__init__(service,
+ "get", (id, addr, word_size, size, mode))
+ def done(self, error, args):
+ e = None
+ if error:
+ e = memory.MemoryError(error.message)
+ else:
+ assert len(args) == 3
+ bytes = channel.toByteArray(args[0])
+ assert len(bytes) <= size
+ buf[offs:offs+len(bytes)] = bytes
+ e = self.toMemoryError(args[1], args[2])
+ done.doneMemory(self.token, e)
+ return GetCommand().token
+
+ def set(self, addr, word_size, buf, offs, size, mode, done):
+ service = self.service
+ id = self.getID()
+ done = service._makeCallback(done)
+ class SetCommand(MemoryCommand):
+ def __init__(self):
+ super(SetCommand, self).__init__(service,
+ "set", (id, addr, word_size, size, mode, bytearray(buf[offs:offs:size])))
+ def done(self, error, args):
+ e = None
+ if error:
+ e = memory.MemoryError(error.message)
+ else:
+ assert len(args) == 2
+ e = self.toMemoryError(args[1], args[2])
+ done.doneMemory(self.token, e)
+ return SetCommand().token
+
+class MemoryProxy(memory.MemoryService):
+ def __init__(self, channel):
+ self.channel = channel
+ self.listeners = {}
+
+ def getContext(self, context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (context_id,))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = MemContext(service, args[1])
+ done.doneGetContext(self.token, error, ctx)
+ return GetContextCommand().token
+
+ def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetChildrenCommand(Command):
+ def __init__(self):
+ super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
+ def done(self, error, args):
+ contexts = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ contexts = args[1]
+ done.doneGetChildren(self.token, error, contexts)
+ return GetChildrenCommand().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 MemoryCommand(Command):
+ def __init__(self, service, cmd, args):
+ super(MemoryCommand, self).__init__(service.channel, service, cmd, args)
+ def toMemoryError(self, addr, data, ranges):
+ if data is None: return None
+ code = data.get(errors.ERROR_CODE)
+ cmd = self.getCommandString()
+ if len(cmd) > 72: cmd = cmd[0:72] + "..."
+ e = MemoryErrorReport(
+ "TCF command exception:\nCommand: %s\nException: %s\nError code: " % (
+ cmd, self.toErrorString(data), code),
+ map, addr, ranges)
+ caused_by = data.get(errors.ERROR_CAUSED_BY)
+ if caused_by is not None: e.caused_by = self.toError(caused_by, False)
+ return e
+
+
+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 == "contextAdded":
+ assert len(args) == 1
+ self.listener.contextAdded(_toContextArray(self.service, args[0]))
+ elif name == "contextChanged":
+ assert len(args) == 1
+ self.listener.contextChanged(_toContextArray(self.service, args[0]))
+ elif name == "contextRemoved":
+ assert len(args) == 1
+ self.listener.contextRemoved(args[0])
+ elif name == "memoryChanged":
+ assert len(args) == 2
+ self.listener.memoryChanged(args[0], _toAddrArray(args[1]), _toSizeArray(args[1]))
+ else:
+ raise IOError("Memory service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)
+
+
+def _toContextArray(svc, o):
+ if o is None: return None
+ ctx = []
+ for m in o: ctx.append(MemContext(svc, m))
+ return ctx
+
+def _toSizeArray(o):
+ if o is None: return None
+ return map(lambda m: m.get("size", 0), o)
+
+def _toAddrArray(o):
+ if o is None: return None
+ return map(lambda m: m.get("addr"), o)
diff --git a/python/src/tcf/services/remote/PathMapProxy.py b/python/src/tcf/services/remote/PathMapProxy.py
index 93e8c07b8..770e972f9 100644
--- a/python/src/tcf/services/remote/PathMapProxy.py
+++ b/python/src/tcf/services/remote/PathMapProxy.py
@@ -1,56 +1,56 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 pathmap
-from tcf.channel.Command import Command
-
-class PathMapProxy(pathmap.PathMapService):
- def __init__(self, channel):
- self.channel = channel
-
- def get(self, done):
- done = self._makeCallback(done)
- service = self
- class GetCommand(Command):
- def __init__(self):
- super(GetCommand, self).__init__(service.channel, service, "get", None)
- def done(self, error, args):
- map = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: map = _toPathMap(args[1])
- done.doneGet(self.token, error, map)
- return GetCommand().token
-
- def set(self, map, done):
- if isinstance(map, pathmap.PathMapRule) or isinstance(map, dict):
- map = (map,)
- done = self._makeCallback(done)
- service = self
- class SetCommand(Command):
- def __init__(self):
- super(SetCommand, self).__init__(service.channel, service, "set", (map,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneSet(self.token, error)
- return SetCommand().token
-
-
-def _toPathMap(o):
- if o is None: return None
- return map(_toPathMapRule, o)
-
-def _toPathMapRule(o):
- if o is None: return None
- return pathmap.PathMapRule(o)
+# *******************************************************************************
+# * Copyright (c) 2011 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 pathmap
+from tcf.channel.Command import Command
+
+class PathMapProxy(pathmap.PathMapService):
+ def __init__(self, channel):
+ self.channel = channel
+
+ def get(self, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetCommand(Command):
+ def __init__(self):
+ super(GetCommand, self).__init__(service.channel, service, "get", None)
+ def done(self, error, args):
+ map = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: map = _toPathMap(args[1])
+ done.doneGet(self.token, error, map)
+ return GetCommand().token
+
+ def set(self, map, done):
+ if isinstance(map, pathmap.PathMapRule) or isinstance(map, dict):
+ map = (map,)
+ done = self._makeCallback(done)
+ service = self
+ class SetCommand(Command):
+ def __init__(self):
+ super(SetCommand, self).__init__(service.channel, service, "set", (map,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneSet(self.token, error)
+ return SetCommand().token
+
+
+def _toPathMap(o):
+ if o is None: return None
+ return map(_toPathMapRule, o)
+
+def _toPathMapRule(o):
+ if o is None: return None
+ return pathmap.PathMapRule(o)
diff --git a/python/src/tcf/services/remote/ProcessesProxy.py b/python/src/tcf/services/remote/ProcessesProxy.py
index 4e1dff2c6..9cfdcbd56 100644
--- a/python/src/tcf/services/remote/ProcessesProxy.py
+++ b/python/src/tcf/services/remote/ProcessesProxy.py
@@ -1,215 +1,215 @@
-# *******************************************************************************
-# * Copyright (c) 2011, 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 import channel
-from tcf.services import processes
-from tcf.channel.Command import Command
-
-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
- 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 getChildren(self, parent_context_id, attached_only, done):
- done = self._makeCallback(done)
- service = self
- class GetChildrenCommand(Command):
- def __init__(self):
- super(GetChildrenCommand, self).__init__(service.channel, service,
- "getChildren", (parent_context_id, attached_only))
- def done(self, error, args):
- contexts = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- contexts = args[1]
- done.doneGetChildren(self.token, error, contexts)
- return GetChildrenCommand().token
-
- def getContext(self, context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetContextCommand(Command):
- def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (context_id,))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = ProcessContext(service, args[1])
- done.doneGetContext(self.token, error, ctx)
- return GetContextCommand().token
-
- def getEnvironment(self, done):
- done = self._makeCallback(done)
- service = self
- class GetEnvCommand(Command):
- def __init__(self):
- super(GetEnvCommand, self).__init__(service.channel, service, "getEnvironment", None)
- def done(self, error, args):
- env = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- env = _toEnvMap(args[1])
- done.doneGetEnvironment(self.token, error, env)
- 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):
- def __init__(self):
- super(StartCommand, self).__init__(service.channel, service,
- "start", (directory, file, command_line, env, attach))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = ProcessContext(service, args[1])
- done.doneStart(self.token, error, ctx)
- return StartCommand().token
-
- def getSignalList(self, context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetSignalsCommand(Command):
- def __init__(self):
- super(GetSignalsCommand, self).__init__(service.channel, service,
- "getSignalList", (context_id,))
- def done(self, error, args):
- list = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- list = args[1]
- done.doneGetSignalList(self.token, error, list)
- return GetSignalsCommand().token
-
- def getSignalMask(self, context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetSignalMaskCommand(Command):
- def __init__(self):
- super(GetSignalMaskCommand, self).__init__(service.channel, service,
- "getSignalMask", (context_id,))
- def done(self, error, args):
- dont_stop = 0
- dont_pass = 0
- pending = 0
- if not error:
- assert len(args) == 4
- error = self.toError(args[0])
- dont_stop, dont_pass, pending = args[1:4]
- done.doneGetSignalMask(self.token, error, dont_stop, dont_pass, pending)
- 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):
- super(SetSignalMaskCommand, self).__init__(service.channel, service,
- "setSignalMask", (context_id, dont_stop, dont_pass))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneCommand(self.token, error)
- return SetSignalMaskCommand().token
-
- def signal(self, context_id, signal, done):
- done = self._makeCallback(done)
- service = self
- class SignalCommand(Command):
- def __init__(self):
- super(SignalCommand, self).__init__(service.channel, service,
- "signal", (context_id, signal))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- 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 Exception as x:
- self.service.channel.terminate(x)
-
-def _toEnvStringArray(map):
- arr = []
- if not map: return arr
- for name, value in map.items():
- arr.append("%s=%s" % (name, value))
- return arr
-
-def _toEnvMap(arr):
- map = {}
- if not arr: return map
- for str in arr:
- i = str.find('=')
- if i >= 0: map[str[:i]] = str[i + 1:]
- else: map[str] = ""
- return map
+# *******************************************************************************
+# * Copyright (c) 2011, 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 import channel
+from tcf.services import processes
+from tcf.channel.Command import Command
+
+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
+ 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 getChildren(self, parent_context_id, attached_only, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetChildrenCommand(Command):
+ def __init__(self):
+ super(GetChildrenCommand, self).__init__(service.channel, service,
+ "getChildren", (parent_context_id, attached_only))
+ def done(self, error, args):
+ contexts = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ contexts = args[1]
+ done.doneGetChildren(self.token, error, contexts)
+ return GetChildrenCommand().token
+
+ def getContext(self, context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (context_id,))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = ProcessContext(service, args[1])
+ done.doneGetContext(self.token, error, ctx)
+ return GetContextCommand().token
+
+ def getEnvironment(self, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetEnvCommand(Command):
+ def __init__(self):
+ super(GetEnvCommand, self).__init__(service.channel, service, "getEnvironment", None)
+ def done(self, error, args):
+ env = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ env = _toEnvMap(args[1])
+ done.doneGetEnvironment(self.token, error, env)
+ 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):
+ def __init__(self):
+ super(StartCommand, self).__init__(service.channel, service,
+ "start", (directory, file, command_line, env, attach))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = ProcessContext(service, args[1])
+ done.doneStart(self.token, error, ctx)
+ return StartCommand().token
+
+ def getSignalList(self, context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetSignalsCommand(Command):
+ def __init__(self):
+ super(GetSignalsCommand, self).__init__(service.channel, service,
+ "getSignalList", (context_id,))
+ def done(self, error, args):
+ list = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ list = args[1]
+ done.doneGetSignalList(self.token, error, list)
+ return GetSignalsCommand().token
+
+ def getSignalMask(self, context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetSignalMaskCommand(Command):
+ def __init__(self):
+ super(GetSignalMaskCommand, self).__init__(service.channel, service,
+ "getSignalMask", (context_id,))
+ def done(self, error, args):
+ dont_stop = 0
+ dont_pass = 0
+ pending = 0
+ if not error:
+ assert len(args) == 4
+ error = self.toError(args[0])
+ dont_stop, dont_pass, pending = args[1:4]
+ done.doneGetSignalMask(self.token, error, dont_stop, dont_pass, pending)
+ 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):
+ super(SetSignalMaskCommand, self).__init__(service.channel, service,
+ "setSignalMask", (context_id, dont_stop, dont_pass))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneCommand(self.token, error)
+ return SetSignalMaskCommand().token
+
+ def signal(self, context_id, signal, done):
+ done = self._makeCallback(done)
+ service = self
+ class SignalCommand(Command):
+ def __init__(self):
+ super(SignalCommand, self).__init__(service.channel, service,
+ "signal", (context_id, signal))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ 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 Exception as x:
+ self.service.channel.terminate(x)
+
+def _toEnvStringArray(map):
+ arr = []
+ if not map: return arr
+ for name, value in map.items():
+ arr.append("%s=%s" % (name, value))
+ return arr
+
+def _toEnvMap(arr):
+ map = {}
+ if not arr: return map
+ for str in arr:
+ i = str.find('=')
+ if i >= 0: map[str[:i]] = str[i + 1:]
+ else: map[str] = ""
+ return map
diff --git a/python/src/tcf/services/remote/ProcessesV1Proxy.py b/python/src/tcf/services/remote/ProcessesV1Proxy.py
index 5ebf28a3e..c16d15624 100644
--- a/python/src/tcf/services/remote/ProcessesV1Proxy.py
+++ b/python/src/tcf/services/remote/ProcessesV1Proxy.py
@@ -1,32 +1,32 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 . import ProcessesProxy
-from tcf.services import processes_v1
-from tcf.channel.Command import Command
-
-class ProcessesV1Proxy(ProcessesProxy.ProcessesProxy, processes_v1.ProcessesV1Service):
- def start(self, directory, file, command_line, environment, params, done):
- done = self._makeCallback(done)
- service = self
- env = ProcessesProxy._toEnvStringArray(environment)
- class StartCommand(Command):
- def __init__(self):
- super(StartCommand, self).__init__(service.channel, service,
- "start", (directory, file, command_line, env, params))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = ProcessesProxy.ProcessContext(service, args[1])
- done.doneStart(self.token, error, ctx)
- return StartCommand().token
+# *******************************************************************************
+# * Copyright (c) 2011 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 . import ProcessesProxy
+from tcf.services import processes_v1
+from tcf.channel.Command import Command
+
+class ProcessesV1Proxy(ProcessesProxy.ProcessesProxy, processes_v1.ProcessesV1Service):
+ def start(self, directory, file, command_line, environment, params, done):
+ done = self._makeCallback(done)
+ service = self
+ env = ProcessesProxy._toEnvStringArray(environment)
+ class StartCommand(Command):
+ def __init__(self):
+ super(StartCommand, self).__init__(service.channel, service,
+ "start", (directory, file, command_line, env, params))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = ProcessesProxy.ProcessContext(service, args[1])
+ done.doneStart(self.token, error, ctx)
+ return StartCommand().token
diff --git a/python/src/tcf/services/remote/RegistersProxy.py b/python/src/tcf/services/remote/RegistersProxy.py
index f33eea147..fdf3d9ae8 100644
--- a/python/src/tcf/services/remote/RegistersProxy.py
+++ b/python/src/tcf/services/remote/RegistersProxy.py
@@ -1,176 +1,176 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 import channel
-from tcf.services import registers
-from tcf.channel import toByteArray
-from tcf.channel.Command import Command
-
-class Context(registers.RegistersContext):
- def __init__(self, service, props):
- super(Context, self).__init__(props)
- self.service = service
-
- def getNamedValues(self):
- return _toValuesArray(self._props.get(registers.PROP_VALUES))
-
- def get(self, done):
- service = self.service
- done = service._makeCallback(done)
- id = self.getID()
- class GetCommand(Command):
- def __init__(self):
- super(GetCommand, self).__init__(service.channel, service, "get", (id,))
- def done(self, error, args):
- val = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- val = toByteArray(args[1])
- done.doneGet(self.token, error, val)
- return GetCommand().token
-
- def set(self, value, done):
- service = self.service
- done = service._makeCallback(done)
- id = self.getID()
- binary = bytearray(value)
- class SetCommand(Command):
- def __init__(self):
- super(SetCommand, self).__init__(service.channel, service, "set", (id, binary))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneSet(self.token, error)
- return SetCommand().token
-
- def search(self, filter, done):
- service = self.service
- done = service._makeCallback(done)
- id = self.getID()
- class SearchCommand(Command):
- def __init__(self):
- super(SearchCommand, self).__init__(service.channel, service, "search", (id, filter))
- def done(self, error, args):
- paths = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- paths = args[1]
- done.doneSearch(self.token, error, paths)
- return SearchCommand().token
-
-class RegistersProxy(registers.RegistersService):
- def __init__(self, channel):
- self.channel = channel
- self.listeners = {}
-
- def getChildren(self, parent_context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetChildrenCommand(Command):
- def __init__(self):
- super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
- def done(self, error, args):
- contexts = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- contexts = args[1]
- done.doneGetChildren(self.token, error, contexts)
- return GetChildrenCommand().token
-
- def getContext(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetContextCommand(Command):
- def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = Context(service, args[1])
- done.doneGetContext(self.token, error, ctx)
- return GetContextCommand().token
-
- def getm(self, locs, done):
- done = self._makeCallback(done)
- service = self
- class GetMCommand(Command):
- def __init__(self):
- super(GetMCommand, self).__init__(service.channel, service, "getm", (locs,))
- def done(self, error, args):
- val = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- val = toByteArray(args[1])
- done.doneGet(self.token, error, val)
- return GetMCommand().token
-
- def setm(self, locs, value, done):
- done = self._makeCallback(done)
- service = self
- binary = bytearray(value)
- class SetMCommand(Command):
- def __init__(self):
- super(SetMCommand, self).__init__(service.channel, service, "setm", (locs, binary))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneSet(self.token, error)
- return SetMCommand().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 NamedValueInfo(registers.NamedValue):
- def __init__(self, m):
- desc = m.get("Description")
- name = m.get("Name")
- value = toByteArray(m.get("Value"))
- super(NamedValueInfo, self).__init__(value, name, desc)
-
-def _toValuesArray(o):
- if o is None: return None
- arr = []
- for m in o:
- arr.append(NamedValueInfo(m))
- return arr
-
-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 == "contextChanged":
- self.listener.contextChanged()
- elif name == "registerChanged":
- assert len(args) == 1
- self.listener.registerChanged(args[0])
- else:
- raise IOError("Registers service: unknown event: " + name);
- except Exception as x:
- self.service.channel.terminate(x)
+# *******************************************************************************
+# * Copyright (c) 2011 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 import channel
+from tcf.services import registers
+from tcf.channel import toByteArray
+from tcf.channel.Command import Command
+
+class Context(registers.RegistersContext):
+ def __init__(self, service, props):
+ super(Context, self).__init__(props)
+ self.service = service
+
+ def getNamedValues(self):
+ return _toValuesArray(self._props.get(registers.PROP_VALUES))
+
+ def get(self, done):
+ service = self.service
+ done = service._makeCallback(done)
+ id = self.getID()
+ class GetCommand(Command):
+ def __init__(self):
+ super(GetCommand, self).__init__(service.channel, service, "get", (id,))
+ def done(self, error, args):
+ val = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ val = toByteArray(args[1])
+ done.doneGet(self.token, error, val)
+ return GetCommand().token
+
+ def set(self, value, done):
+ service = self.service
+ done = service._makeCallback(done)
+ id = self.getID()
+ binary = bytearray(value)
+ class SetCommand(Command):
+ def __init__(self):
+ super(SetCommand, self).__init__(service.channel, service, "set", (id, binary))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneSet(self.token, error)
+ return SetCommand().token
+
+ def search(self, filter, done):
+ service = self.service
+ done = service._makeCallback(done)
+ id = self.getID()
+ class SearchCommand(Command):
+ def __init__(self):
+ super(SearchCommand, self).__init__(service.channel, service, "search", (id, filter))
+ def done(self, error, args):
+ paths = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ paths = args[1]
+ done.doneSearch(self.token, error, paths)
+ return SearchCommand().token
+
+class RegistersProxy(registers.RegistersService):
+ def __init__(self, channel):
+ self.channel = channel
+ self.listeners = {}
+
+ def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetChildrenCommand(Command):
+ def __init__(self):
+ super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
+ def done(self, error, args):
+ contexts = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ contexts = args[1]
+ done.doneGetChildren(self.token, error, contexts)
+ return GetChildrenCommand().token
+
+ def getContext(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = Context(service, args[1])
+ done.doneGetContext(self.token, error, ctx)
+ return GetContextCommand().token
+
+ def getm(self, locs, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetMCommand(Command):
+ def __init__(self):
+ super(GetMCommand, self).__init__(service.channel, service, "getm", (locs,))
+ def done(self, error, args):
+ val = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ val = toByteArray(args[1])
+ done.doneGet(self.token, error, val)
+ return GetMCommand().token
+
+ def setm(self, locs, value, done):
+ done = self._makeCallback(done)
+ service = self
+ binary = bytearray(value)
+ class SetMCommand(Command):
+ def __init__(self):
+ super(SetMCommand, self).__init__(service.channel, service, "setm", (locs, binary))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneSet(self.token, error)
+ return SetMCommand().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 NamedValueInfo(registers.NamedValue):
+ def __init__(self, m):
+ desc = m.get("Description")
+ name = m.get("Name")
+ value = toByteArray(m.get("Value"))
+ super(NamedValueInfo, self).__init__(value, name, desc)
+
+def _toValuesArray(o):
+ if o is None: return None
+ arr = []
+ for m in o:
+ arr.append(NamedValueInfo(m))
+ return arr
+
+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 == "contextChanged":
+ self.listener.contextChanged()
+ elif name == "registerChanged":
+ assert len(args) == 1
+ self.listener.registerChanged(args[0])
+ else:
+ raise IOError("Registers service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/RunControlProxy.py b/python/src/tcf/services/remote/RunControlProxy.py
index 8c2832cf4..60d20fea8 100644
--- a/python/src/tcf/services/remote/RunControlProxy.py
+++ b/python/src/tcf/services/remote/RunControlProxy.py
@@ -1,158 +1,158 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 import channel
-from tcf.services import runcontrol
-from tcf.channel.Command import Command
-
-class RunContext(runcontrol.RunControlContext):
- def __init__(self, service, props):
- super(RunContext, self).__init__(props)
- self.service = service
-
- def getState(self, done):
- service = self.service
- done = service._makeCallback(done)
- id = self.getID()
- class GetStateCommand(Command):
- def __init__(self):
- super(GetStateCommand, self).__init__(service.channel, service, "getState", (id,))
- def done(self, error, args):
- susp = False
- pc = None
- reason = None
- map = None
- if not error:
- assert len(args) == 5
- error = self.toError(args[0])
- susp = args[1]
- if args[2]: pc = str(args[2])
- reason = args[3]
- map = args[4]
- done.doneGetState(self.token, error, susp, pc, reason, map)
- return GetStateCommand().token
-
-# def resume(self, mode, count, done):
-# return self._command("resume", [self.getID(), mode, count], done)
-
- def resume(self, mode, count, params, done):
- if not params:
- return self._command("resume", (self.getID(), mode, count), done)
- else:
- return self._command("resume", (self.getID(), mode, count, params), done)
-
- def suspend(self, done):
- return self._command("suspend", (self.getID(),), done)
-
- def terminate(self, done):
- return self._command("terminate", (self.getID(),), done)
-
- 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)
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneCommand(self.token, error)
- return RCCommand(cmd, args).token
-
-
-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 == "contextSuspended":
- assert len(args) == 4
- self.listener.contextSuspended(args[0], args[1], args[2], args[3])
- elif name == "contextResumed":
- assert len(args) == 1
- self.listener.contextResumed(args[0])
- elif name == "contextAdded":
- assert len(args) == 1
- self.listener.contextAdded(_toContextArray(self.service,args[0]))
- elif name == "contextChanged":
- assert len(args) == 1
- self.listener.contextChanged(_toContextArray(self.service,args[0]))
- elif name == "contextRemoved":
- assert len(args) == 1
- self.listener.contextRemoved(args[0])
- elif name == "contextException":
- assert len(args) == 2
- self.listener.contextException(args[0], args[1])
- elif name == "containerSuspended":
- assert len(args) == 5
- self.listener.containerSuspended(args[0], args[1], args[2], args[3], args[4])
- elif name == "containerResumed":
- assert len(args) == 1
- self.listener.containerResumed(args[0])
- else:
- raise IOError("RunControl service: unknown event: " + name);
- except Exception as x:
- self.service.channel.terminate(x)
-
-class RunControlProxy(runcontrol.RunControlService):
- 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 getContext(self, context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetContextCommand(Command):
- def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (context_id,))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = RunContext(service, args[1])
- done.doneGetContext(self.token, error, ctx)
- return GetContextCommand().token
-
- def getChildren(self, parent_context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetChildrenCommand(Command):
- def __init__(self):
- super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
- def done(self, error, args):
- contexts = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- contexts = args[1]
- done.doneGetChildren(self.token, error, contexts)
- return GetChildrenCommand().token
-
-def _toContextArray(svc,o):
- if o is None: return None
- ctx = []
- for m in o: ctx.append(RunContext(svc,m))
- return ctx
+# *******************************************************************************
+# * Copyright (c) 2011 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 import channel
+from tcf.services import runcontrol
+from tcf.channel.Command import Command
+
+class RunContext(runcontrol.RunControlContext):
+ def __init__(self, service, props):
+ super(RunContext, self).__init__(props)
+ self.service = service
+
+ def getState(self, done):
+ service = self.service
+ done = service._makeCallback(done)
+ id = self.getID()
+ class GetStateCommand(Command):
+ def __init__(self):
+ super(GetStateCommand, self).__init__(service.channel, service, "getState", (id,))
+ def done(self, error, args):
+ susp = False
+ pc = None
+ reason = None
+ map = None
+ if not error:
+ assert len(args) == 5
+ error = self.toError(args[0])
+ susp = args[1]
+ if args[2]: pc = str(args[2])
+ reason = args[3]
+ map = args[4]
+ done.doneGetState(self.token, error, susp, pc, reason, map)
+ return GetStateCommand().token
+
+# def resume(self, mode, count, done):
+# return self._command("resume", [self.getID(), mode, count], done)
+
+ def resume(self, mode, count, params, done):
+ if not params:
+ return self._command("resume", (self.getID(), mode, count), done)
+ else:
+ return self._command("resume", (self.getID(), mode, count, params), done)
+
+ def suspend(self, done):
+ return self._command("suspend", (self.getID(),), done)
+
+ def terminate(self, done):
+ return self._command("terminate", (self.getID(),), done)
+
+ 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)
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneCommand(self.token, error)
+ return RCCommand(cmd, args).token
+
+
+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 == "contextSuspended":
+ assert len(args) == 4
+ self.listener.contextSuspended(args[0], args[1], args[2], args[3])
+ elif name == "contextResumed":
+ assert len(args) == 1
+ self.listener.contextResumed(args[0])
+ elif name == "contextAdded":
+ assert len(args) == 1
+ self.listener.contextAdded(_toContextArray(self.service,args[0]))
+ elif name == "contextChanged":
+ assert len(args) == 1
+ self.listener.contextChanged(_toContextArray(self.service,args[0]))
+ elif name == "contextRemoved":
+ assert len(args) == 1
+ self.listener.contextRemoved(args[0])
+ elif name == "contextException":
+ assert len(args) == 2
+ self.listener.contextException(args[0], args[1])
+ elif name == "containerSuspended":
+ assert len(args) == 5
+ self.listener.containerSuspended(args[0], args[1], args[2], args[3], args[4])
+ elif name == "containerResumed":
+ assert len(args) == 1
+ self.listener.containerResumed(args[0])
+ else:
+ raise IOError("RunControl service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)
+
+class RunControlProxy(runcontrol.RunControlService):
+ 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 getContext(self, context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (context_id,))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = RunContext(service, args[1])
+ done.doneGetContext(self.token, error, ctx)
+ return GetContextCommand().token
+
+ def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetChildrenCommand(Command):
+ def __init__(self):
+ super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
+ def done(self, error, args):
+ contexts = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ contexts = args[1]
+ done.doneGetChildren(self.token, error, contexts)
+ return GetChildrenCommand().token
+
+def _toContextArray(svc,o):
+ if o is None: return None
+ ctx = []
+ for m in o: ctx.append(RunContext(svc,m))
+ return ctx
diff --git a/python/src/tcf/services/remote/StackTraceProxy.py b/python/src/tcf/services/remote/StackTraceProxy.py
index b551af36f..5a2d6288f 100644
--- a/python/src/tcf/services/remote/StackTraceProxy.py
+++ b/python/src/tcf/services/remote/StackTraceProxy.py
@@ -1,54 +1,54 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 stacktrace
-from tcf.channel.Command import Command
-
-class StackTraceProxy(stacktrace.StackTraceService):
- def __init__(self, channel):
- self.channel = channel
-
- def getChildren(self, parent_context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetChildrenCommand(Command):
- def __init__(self):
- super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
- def done(self, error, args):
- contexts = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- contexts = args[1]
- done.doneGetChildren(self.token, error, contexts)
- return GetChildrenCommand().token
-
- def getContext(self, ids, done):
- done = self._makeCallback(done)
- service = self
- class GetContextCommand(Command):
- def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (ids,))
- def done(self, error, args):
- ctxs = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[1])
- ctxs = service.toContextArray(args[0])
- done.doneGetContext(self.token, error, ctxs)
- return GetContextCommand().token
-
- def toContextArray(self, ctxProps):
- if ctxProps is None: return None
- ctxs = []
- for props in ctxProps:
- ctxs.append(stacktrace.StackTraceContext(props))
- return ctxs
+# *******************************************************************************
+# * Copyright (c) 2011 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 stacktrace
+from tcf.channel.Command import Command
+
+class StackTraceProxy(stacktrace.StackTraceService):
+ def __init__(self, channel):
+ self.channel = channel
+
+ def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetChildrenCommand(Command):
+ def __init__(self):
+ super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
+ def done(self, error, args):
+ contexts = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ contexts = args[1]
+ done.doneGetChildren(self.token, error, contexts)
+ return GetChildrenCommand().token
+
+ def getContext(self, ids, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (ids,))
+ def done(self, error, args):
+ ctxs = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[1])
+ ctxs = service.toContextArray(args[0])
+ done.doneGetContext(self.token, error, ctxs)
+ return GetContextCommand().token
+
+ def toContextArray(self, ctxProps):
+ if ctxProps is None: return None
+ ctxs = []
+ for props in ctxProps:
+ ctxs.append(stacktrace.StackTraceContext(props))
+ return ctxs
diff --git a/python/src/tcf/services/remote/StreamsProxy.py b/python/src/tcf/services/remote/StreamsProxy.py
index d4149099d..67297e7d1 100644
--- a/python/src/tcf/services/remote/StreamsProxy.py
+++ b/python/src/tcf/services/remote/StreamsProxy.py
@@ -1,146 +1,146 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 streams
-from tcf import channel
-from tcf.channel.Command import Command
-
-class StreamsProxy(streams.StreamsService):
- def __init__(self, channel):
- self.channel = channel
- self.listeners = {}
-
- def connect(self, stream_id, done):
- done = self._makeCallback(done)
- service = self
- class ConnectCommand(Command):
- def __init__(self):
- super(ConnectCommand, self).__init__(service.channel, service, "connect", (stream_id,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneConnect(self.token, error)
- return ConnectCommand().token
-
- def disconnect(self, stream_id, done):
- done = self._makeCallback(done)
- service = self
- class DisconnectCommand(Command):
- def __init__(self):
- super(DisconnectCommand, self).__init__(service.channel, service, "disconnect", (stream_id,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneDisconnect(self.token, error)
- return DisconnectCommand().token
-
- def eos(self, stream_id, done):
- done = self._makeCallback(done)
- service = self
- class EOSCommand(Command):
- def __init__(self):
- super(EOSCommand, self).__init__(service.channel, service, "eos", (stream_id,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneEOS(self.token, error)
- return EOSCommand().token
-
- def read(self, stream_id, size, done):
- done = self._makeCallback(done)
- service = self
- class ReadCommand(Command):
- def __init__(self):
- super(ReadCommand, self).__init__(service.channel, service, "read", (stream_id, size))
- def done(self, error, args):
- lost_size = 0
- data = None
- eos = False
- if not error:
- assert len(args) == 4
- data = channel.toByteArray(args[0])
- error = self.toError(args[1])
- lost_size = args[2]
- eos = args[3]
- done.doneRead(self.token, error, lost_size, data, eos)
- return ReadCommand().token
-
- def subscribe(self, stream_type, listener, done):
- done = self._makeCallback(done)
- service = self
- class SubscribeCommand(Command):
- def __init__(self):
- super(SubscribeCommand, self).__init__(service.channel, service, "subscribe", (stream_type,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- if not error:
- l = ChannelEventListener(service, listener)
- service.listeners[listener] = l
- service.channel.addEventListener(service, l)
- done.doneSubscribe(self.token, error)
- return SubscribeCommand().token
-
- def unsubscribe(self, stream_type, listener, done):
- done = self._makeCallback(done)
- service = self
- class UnsubscribeCommand(Command):
- def __init__(self):
- super(UnsubscribeCommand, self).__init__(service.channel, service, "unsubscribe", (stream_type,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- if not error:
- l = service.listeners.pop(listener, None)
- if l: service.channel.removeEventListener(service, l)
- done.doneUnsubscribe(self.token, error)
- return UnsubscribeCommand().token
-
- def write(self, stream_id, buf, offset, size, done):
- done = self._makeCallback(done)
- service = self
- binary = buf[offset:offset+size]
- class WriteCommand(Command):
- def __init__(self):
- super(WriteCommand, self).__init__(service.channel, service, "write", (stream_id, binary))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneWrite(self.token, error)
- return WriteCommand().token
-
-
-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 == "created":
- if len(args) == 3:
- self.listener.created(args[0], args[1], args[2])
- else:
- assert len(args) == 2
- self.listener.created(args[0], args[1], None)
- elif name == "disposed":
- assert len(args) == 2
- self.listener.disposed(args[0], args[1])
- else:
- raise IOError("Streams service: unknown event: " + name);
- except Exception as x:
- self.service.channel.terminate(x)
+# *******************************************************************************
+# * Copyright (c) 2011 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 streams
+from tcf import channel
+from tcf.channel.Command import Command
+
+class StreamsProxy(streams.StreamsService):
+ def __init__(self, channel):
+ self.channel = channel
+ self.listeners = {}
+
+ def connect(self, stream_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class ConnectCommand(Command):
+ def __init__(self):
+ super(ConnectCommand, self).__init__(service.channel, service, "connect", (stream_id,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneConnect(self.token, error)
+ return ConnectCommand().token
+
+ def disconnect(self, stream_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class DisconnectCommand(Command):
+ def __init__(self):
+ super(DisconnectCommand, self).__init__(service.channel, service, "disconnect", (stream_id,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneDisconnect(self.token, error)
+ return DisconnectCommand().token
+
+ def eos(self, stream_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class EOSCommand(Command):
+ def __init__(self):
+ super(EOSCommand, self).__init__(service.channel, service, "eos", (stream_id,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneEOS(self.token, error)
+ return EOSCommand().token
+
+ def read(self, stream_id, size, done):
+ done = self._makeCallback(done)
+ service = self
+ class ReadCommand(Command):
+ def __init__(self):
+ super(ReadCommand, self).__init__(service.channel, service, "read", (stream_id, size))
+ def done(self, error, args):
+ lost_size = 0
+ data = None
+ eos = False
+ if not error:
+ assert len(args) == 4
+ data = channel.toByteArray(args[0])
+ error = self.toError(args[1])
+ lost_size = args[2]
+ eos = args[3]
+ done.doneRead(self.token, error, lost_size, data, eos)
+ return ReadCommand().token
+
+ def subscribe(self, stream_type, listener, done):
+ done = self._makeCallback(done)
+ service = self
+ class SubscribeCommand(Command):
+ def __init__(self):
+ super(SubscribeCommand, self).__init__(service.channel, service, "subscribe", (stream_type,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ if not error:
+ l = ChannelEventListener(service, listener)
+ service.listeners[listener] = l
+ service.channel.addEventListener(service, l)
+ done.doneSubscribe(self.token, error)
+ return SubscribeCommand().token
+
+ def unsubscribe(self, stream_type, listener, done):
+ done = self._makeCallback(done)
+ service = self
+ class UnsubscribeCommand(Command):
+ def __init__(self):
+ super(UnsubscribeCommand, self).__init__(service.channel, service, "unsubscribe", (stream_type,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ if not error:
+ l = service.listeners.pop(listener, None)
+ if l: service.channel.removeEventListener(service, l)
+ done.doneUnsubscribe(self.token, error)
+ return UnsubscribeCommand().token
+
+ def write(self, stream_id, buf, offset, size, done):
+ done = self._makeCallback(done)
+ service = self
+ binary = buf[offset:offset+size]
+ class WriteCommand(Command):
+ def __init__(self):
+ super(WriteCommand, self).__init__(service.channel, service, "write", (stream_id, binary))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneWrite(self.token, error)
+ return WriteCommand().token
+
+
+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 == "created":
+ if len(args) == 3:
+ self.listener.created(args[0], args[1], args[2])
+ else:
+ assert len(args) == 2
+ self.listener.created(args[0], args[1], None)
+ elif name == "disposed":
+ assert len(args) == 2
+ self.listener.disposed(args[0], args[1])
+ else:
+ raise IOError("Streams service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/SymbolsProxy.py b/python/src/tcf/services/remote/SymbolsProxy.py
index 7d911f6c9..72c3b10fb 100644
--- a/python/src/tcf/services/remote/SymbolsProxy.py
+++ b/python/src/tcf/services/remote/SymbolsProxy.py
@@ -1,121 +1,121 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 import channel
-from tcf.services import symbols
-from tcf.channel.Command import Command
-
-
-class Context(symbols.Symbol):
- def __init__(self, props):
- super(Context, self).__init__(props)
- self.value = channel.toByteArray(props.get(symbols.PROP_VALUE))
-
- def getValue(self):
- return self.value
-
-
-class SymbolsProxy(symbols.SymbolsService):
- def __init__(self, channel):
- self.channel = channel
-
- def getContext(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetContextCommand(Command):
- def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = Context(args[1])
- done.doneGetContext(self.token, error, ctx)
- return GetContextCommand().token
-
- def getChildren(self, parent_context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetChildrenCommand(Command):
- def __init__(self):
- super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
- def done(self, error, args):
- contexts = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- contexts = args[1]
- done.doneGetChildren(self.token, error, contexts)
- return GetChildrenCommand().token
-
- def find(self, context_id, ip, name, done):
- done = self._makeCallback(done)
- service = self
- class FindCommand(Command):
- def __init__(self):
- super(FindCommand, self).__init__(service.channel, service, "find", (context_id, ip, name))
- def done(self, error, args):
- id = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- id = args[1]
- done.doneFind(self.token, error, id)
- return FindCommand().token
-
- def findByAddr(self, context_id, addr, done):
- done = self._makeCallback(done)
- service = self
- class FindByAddrCommand(Command):
- def __init__(self):
- super(FindByAddrCommand, self).__init__(service.channel, service, "findByAddr", (context_id, addr))
- def done(self, error, args):
- id = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- id = args[1]
- done.doneFind(self.token, error, id)
- return FindByAddrCommand().token
-
- def list(self, context_id, done):
- done = self._makeCallback(done)
- service = self
- class ListCommand(Command):
- def __init__(self):
- super(ListCommand, self).__init__(service.channel, service, "list", (context_id,))
- def done(self, error, args):
- lst = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- lst = args[1]
- done.doneList(self.token, error, lst)
- return ListCommand().token
-
- def findFrameInfo(self, context_id, address, done):
- done = self._makeCallback(done)
- service = self
- class FindFrameInfoCommand(Command):
- def __init__(self):
- super(FindFrameInfoCommand, self).__init__(service.channel, service, "findFrameInfo", (context_id, address))
- def done(self, error, args):
- address = None
- size = None
- fp_cmds = None
- reg_cmds = None
- if not error:
- assert len(args) == 5
- error = self.toError(args[0])
- address, size, fp_cmds, reg_cmds = args[1:5]
- done.doneFindFrameInfo(self.token, error, address, size, fp_cmds, reg_cmds)
- return FindFrameInfoCommand().token
+# *******************************************************************************
+# * Copyright (c) 2011 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 import channel
+from tcf.services import symbols
+from tcf.channel.Command import Command
+
+
+class Context(symbols.Symbol):
+ def __init__(self, props):
+ super(Context, self).__init__(props)
+ self.value = channel.toByteArray(props.get(symbols.PROP_VALUE))
+
+ def getValue(self):
+ return self.value
+
+
+class SymbolsProxy(symbols.SymbolsService):
+ def __init__(self, channel):
+ self.channel = channel
+
+ def getContext(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = Context(args[1])
+ done.doneGetContext(self.token, error, ctx)
+ return GetContextCommand().token
+
+ def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetChildrenCommand(Command):
+ def __init__(self):
+ super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
+ def done(self, error, args):
+ contexts = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ contexts = args[1]
+ done.doneGetChildren(self.token, error, contexts)
+ return GetChildrenCommand().token
+
+ def find(self, context_id, ip, name, done):
+ done = self._makeCallback(done)
+ service = self
+ class FindCommand(Command):
+ def __init__(self):
+ super(FindCommand, self).__init__(service.channel, service, "find", (context_id, ip, name))
+ def done(self, error, args):
+ id = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ id = args[1]
+ done.doneFind(self.token, error, id)
+ return FindCommand().token
+
+ def findByAddr(self, context_id, addr, done):
+ done = self._makeCallback(done)
+ service = self
+ class FindByAddrCommand(Command):
+ def __init__(self):
+ super(FindByAddrCommand, self).__init__(service.channel, service, "findByAddr", (context_id, addr))
+ def done(self, error, args):
+ id = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ id = args[1]
+ done.doneFind(self.token, error, id)
+ return FindByAddrCommand().token
+
+ def list(self, context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class ListCommand(Command):
+ def __init__(self):
+ super(ListCommand, self).__init__(service.channel, service, "list", (context_id,))
+ def done(self, error, args):
+ lst = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ lst = args[1]
+ done.doneList(self.token, error, lst)
+ return ListCommand().token
+
+ def findFrameInfo(self, context_id, address, done):
+ done = self._makeCallback(done)
+ service = self
+ class FindFrameInfoCommand(Command):
+ def __init__(self):
+ super(FindFrameInfoCommand, self).__init__(service.channel, service, "findFrameInfo", (context_id, address))
+ def done(self, error, args):
+ address = None
+ size = None
+ fp_cmds = None
+ reg_cmds = None
+ if not error:
+ assert len(args) == 5
+ error = self.toError(args[0])
+ address, size, fp_cmds, reg_cmds = args[1:5]
+ done.doneFindFrameInfo(self.token, error, address, size, fp_cmds, reg_cmds)
+ return FindFrameInfoCommand().token
diff --git a/python/src/tcf/services/remote/SysMonitorProxy.py b/python/src/tcf/services/remote/SysMonitorProxy.py
index 04aad1969..bf1f16bd7 100644
--- a/python/src/tcf/services/remote/SysMonitorProxy.py
+++ b/python/src/tcf/services/remote/SysMonitorProxy.py
@@ -1,77 +1,77 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
-# * All rights reserved. self program and the accompanying materials
-# * are made available under the terms of the Eclipse Public License v1.0
-# * which accompanies self 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 sysmonitor
-from tcf.channel.Command import Command
-
-class SysMonitorProxy(sysmonitor.SysMonitorService):
- def __init__(self, channel):
- self.channel = channel
-
- def getChildren(self, parent_context_id, done):
- done = self._makeCallback(done)
- service = self
- class GetChildrenCommand(Command):
- def __init__(self):
- super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
- def done(self, error, args):
- contexts = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- contexts = args[1]
- done.doneGetChildren(self.token, error, contexts)
- return GetChildrenCommand().token
-
- def getContext(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetContextCommand(Command):
- def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = sysmonitor.SysMonitorContext(args[1])
- done.doneGetContext(self.token, error, ctx)
- return GetContextCommand().token
-
- def getCommandLine(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetCommandLineCommand(Command):
- def __init__(self):
- super(GetCommandLineCommand, self).__init__(service.channel, service, "getCommandLine", (id,))
- def done(self, error, args):
- arr = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- arr = args[1]
- done.doneGetCommandLine(self.token, error, arr)
- return GetCommandLineCommand().token
-
- def getEnvironment(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetEnvironmentCommand(Command):
- def __init__(self):
- super(GetEnvironmentCommand, self).__init__(service.channel, service, "getEnvironment", (id,))
- def done(self, error, args):
- arr = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- arr = args[1]
- done.doneGetCommandLine(self.token, error, arr)
- return GetEnvironmentCommand().token
+# *******************************************************************************
+# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# * All rights reserved. self program and the accompanying materials
+# * are made available under the terms of the Eclipse Public License v1.0
+# * which accompanies self 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 sysmonitor
+from tcf.channel.Command import Command
+
+class SysMonitorProxy(sysmonitor.SysMonitorService):
+ def __init__(self, channel):
+ self.channel = channel
+
+ def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetChildrenCommand(Command):
+ def __init__(self):
+ super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
+ def done(self, error, args):
+ contexts = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ contexts = args[1]
+ done.doneGetChildren(self.token, error, contexts)
+ return GetChildrenCommand().token
+
+ def getContext(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = sysmonitor.SysMonitorContext(args[1])
+ done.doneGetContext(self.token, error, ctx)
+ return GetContextCommand().token
+
+ def getCommandLine(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetCommandLineCommand(Command):
+ def __init__(self):
+ super(GetCommandLineCommand, self).__init__(service.channel, service, "getCommandLine", (id,))
+ def done(self, error, args):
+ arr = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ arr = args[1]
+ done.doneGetCommandLine(self.token, error, arr)
+ return GetCommandLineCommand().token
+
+ def getEnvironment(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetEnvironmentCommand(Command):
+ def __init__(self):
+ super(GetEnvironmentCommand, self).__init__(service.channel, service, "getEnvironment", (id,))
+ def done(self, error, args):
+ arr = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ arr = args[1]
+ done.doneGetCommandLine(self.token, error, arr)
+ return GetEnvironmentCommand().token
diff --git a/python/src/tcf/services/remote/TerminalsProxy.py b/python/src/tcf/services/remote/TerminalsProxy.py
index 5e68c3406..22217e27b 100644
--- a/python/src/tcf/services/remote/TerminalsProxy.py
+++ b/python/src/tcf/services/remote/TerminalsProxy.py
@@ -1,123 +1,123 @@
-# *******************************************************************************
-# * Copyright (c) 2011 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 terminals
-from tcf import channel
-from tcf.channel.Command import Command
-
-class TerminalContext(terminals.TerminalContext):
- def __init__(self, service, props):
- super(TerminalContext, self).__init__(props)
- self.service = service
-
- def exit(self, done):
- service = self.service
- done = service._makeCallback(done)
- id = self.getID()
- class ExitCommand(Command):
- def __init__(self, cmd, args):
- super(ExitCommand, self).__init__(service.channel, service, "exit", id)
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneCommand(self.token, error)
- return ExitCommand().token
-
-
-class TerminalsProxy(terminals.TerminalsService):
- def __init__(self, channel):
- self.channel = channel
- self.listeners = {}
-
- def getContext(self, id, done):
- done = self._makeCallback(done)
- service = self
- class GetContextCommand(Command):
- def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = TerminalContext(service, args[1])
- done.doneGetContext(self.token, error, ctx)
- return GetContextCommand().token
-
- def launch(self, type, encoding, environment, done):
- done = self._makeCallback(done)
- service = self
- class LaunchCommand(Command):
- def __init__(self):
- super(LaunchCommand, self).__init__(service.channel, service, "launch", (type, encoding, environment))
- def done(self, error, args):
- ctx = None
- if not error:
- assert len(args) == 2
- error = self.toError(args[0])
- if args[1]: ctx = TerminalContext(service, args[1])
- done.doneLaunch(self.token, error, ctx)
- return LaunchCommand().token
-
- def setWinSize(self, context_id, newWidth, newHeight, done):
- done = self._makeCallback(done)
- service = self
- class SetWinSizeCommand(Command):
- def __init__(self):
- super(SetWinSizeCommand, self).__init__(service.channel, service, "setWinSize", (context_id, newWidth, newHeight))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneCommand(self.token, error)
- return SetWinSizeCommand().token
-
- def exit(self, context_id, done):
- done = self._makeCallback(done)
- service = self
- class ExitCommand(Command):
- def __init__(self):
- super(ExitCommand, self).__init__(service.channel, service, "exit", (context_id,))
- def done(self, error, args):
- if not error:
- assert len(args) == 1
- error = self.toError(args[0])
- done.doneCommand(self.token, error)
- return ExitCommand().token
-
- def addListener(self, listener):
- l = ChannelEventListener()
- self.channel.addEventListener(self, l)
- self.listeners[listener] = l
-
- def removeListener(self, listener):
- l = self.listeners.pop(listener, None)
- if l: 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])
- elif name == "winSizeChanged":
- assert len(args) == 3
- self.listener.winSizeChanged(args[0], args[1], args[2])
- else:
- raise IOError("Terminals service: unknown event: " + name);
- except Exception as x:
- self.service.channel.terminate(x)
+# *******************************************************************************
+# * Copyright (c) 2011 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 terminals
+from tcf import channel
+from tcf.channel.Command import Command
+
+class TerminalContext(terminals.TerminalContext):
+ def __init__(self, service, props):
+ super(TerminalContext, self).__init__(props)
+ self.service = service
+
+ def exit(self, done):
+ service = self.service
+ done = service._makeCallback(done)
+ id = self.getID()
+ class ExitCommand(Command):
+ def __init__(self, cmd, args):
+ super(ExitCommand, self).__init__(service.channel, service, "exit", id)
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneCommand(self.token, error)
+ return ExitCommand().token
+
+
+class TerminalsProxy(terminals.TerminalsService):
+ def __init__(self, channel):
+ self.channel = channel
+ self.listeners = {}
+
+ def getContext(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = TerminalContext(service, args[1])
+ done.doneGetContext(self.token, error, ctx)
+ return GetContextCommand().token
+
+ def launch(self, type, encoding, environment, done):
+ done = self._makeCallback(done)
+ service = self
+ class LaunchCommand(Command):
+ def __init__(self):
+ super(LaunchCommand, self).__init__(service.channel, service, "launch", (type, encoding, environment))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = TerminalContext(service, args[1])
+ done.doneLaunch(self.token, error, ctx)
+ return LaunchCommand().token
+
+ def setWinSize(self, context_id, newWidth, newHeight, done):
+ done = self._makeCallback(done)
+ service = self
+ class SetWinSizeCommand(Command):
+ def __init__(self):
+ super(SetWinSizeCommand, self).__init__(service.channel, service, "setWinSize", (context_id, newWidth, newHeight))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneCommand(self.token, error)
+ return SetWinSizeCommand().token
+
+ def exit(self, context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class ExitCommand(Command):
+ def __init__(self):
+ super(ExitCommand, self).__init__(service.channel, service, "exit", (context_id,))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneCommand(self.token, error)
+ return ExitCommand().token
+
+ def addListener(self, listener):
+ l = ChannelEventListener()
+ self.channel.addEventListener(self, l)
+ self.listeners[listener] = l
+
+ def removeListener(self, listener):
+ l = self.listeners.pop(listener, None)
+ if l: 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])
+ elif name == "winSizeChanged":
+ assert len(args) == 3
+ self.listener.winSizeChanged(args[0], args[1], args[2])
+ else:
+ raise IOError("Terminals service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)

Back to the top