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.py67
-rw-r--r--python/src/tcf/services/remote/ContextQueryProxy.py4
-rw-r--r--python/src/tcf/services/remote/DiagnosticsProxy.py83
-rw-r--r--python/src/tcf/services/remote/DisassemblyProxy.py6
-rw-r--r--python/src/tcf/services/remote/ExpressionsProxy.py64
-rw-r--r--python/src/tcf/services/remote/FileSystemProxy.py8
-rw-r--r--python/src/tcf/services/remote/LineNumbersProxy.py37
-rw-r--r--python/src/tcf/services/remote/LocatorProxy.py87
-rw-r--r--python/src/tcf/services/remote/MemoryMapProxy.py53
-rw-r--r--python/src/tcf/services/remote/MemoryProxy.py123
-rw-r--r--python/src/tcf/services/remote/PathMapProxy.py8
-rw-r--r--python/src/tcf/services/remote/ProcessesProxy.py123
-rw-r--r--python/src/tcf/services/remote/ProcessesV1Proxy.py27
-rw-r--r--python/src/tcf/services/remote/RegistersProxy.py77
-rw-r--r--python/src/tcf/services/remote/RunControlProxy.py78
-rw-r--r--python/src/tcf/services/remote/StackTraceProxy.py27
-rw-r--r--python/src/tcf/services/remote/StreamsProxy.py61
-rw-r--r--python/src/tcf/services/remote/SymbolsProxy.py8
-rw-r--r--python/src/tcf/services/remote/SysMonitorProxy.py47
-rw-r--r--python/src/tcf/services/remote/TerminalsProxy.py48
20 files changed, 714 insertions, 322 deletions
diff --git a/python/src/tcf/services/remote/BreakpointsProxy.py b/python/src/tcf/services/remote/BreakpointsProxy.py
index b7674a3b7..c10ea3c9e 100644
--- a/python/src/tcf/services/remote/BreakpointsProxy.py
+++ b/python/src/tcf/services/remote/BreakpointsProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,16 +7,18 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import breakpoints
+from ... import channel
+from ...channel.Command import Command
-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
@@ -28,6 +30,7 @@ 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)
@@ -44,10 +47,11 @@ class ChannelEventListener(channel.EventListener):
assert len(args) == 1
self.listener.contextRemoved(args[0])
else:
- raise IOError("Breakpoints service: unknown event: " + name);
+ 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
@@ -80,9 +84,12 @@ class BreakpointsProxy(breakpoints.BreakpointsService):
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)
+ super(GetIDsCommand, self).__init__(service.channel, service,
+ "getIDs", None)
+
def done(self, error, args):
ids = None
if not error:
@@ -92,49 +99,63 @@ class BreakpointsProxy(breakpoints.BreakpointsService):
done.doneGetIDs(self.token, error, ids)
return GetIDsCommand().token
- def getProperties(self, id, done):
+ def getProperties(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetPropertiesCommand(Command):
def __init__(self):
- super(GetPropertiesCommand, self).__init__(service.channel, service, "getProperties", (id,))
+ super(GetPropertiesCommand, self).__init__(service.channel,
+ service,
+ "getProperties",
+ (contextID,))
+
def done(self, error, args):
- map = None
+ props = None
if not error:
assert len(args) == 2
error = self.toError(args[0])
- map = args[1]
- done.doneGetProperties(self.token, error, map)
+ props = args[1]
+ done.doneGetProperties(self.token, error, props)
return GetPropertiesCommand().token
- def getStatus(self, id, done):
+ def getStatus(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetStatusCommand(Command):
def __init__(self):
- super(GetStatusCommand, self).__init__(service.channel, service, "getStatus", (id,))
+ super(GetStatusCommand, self).__init__(service.channel,
+ service, "getStatus",
+ (contextID,))
+
def done(self, error, args):
- map = None
+ states = None
if not error:
assert len(args) == 2
error = self.toError(args[0])
- map = args[1]
- done.doneGetStatus(self.token, error, map)
+ states = args[1]
+ done.doneGetStatus(self.token, error, states)
return GetStatusCommand().token
- def getCapabilities(self, id, done):
+ def getCapabilities(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetCapabilitiesCommand(Command):
def __init__(self):
- super(GetCapabilitiesCommand, self).__init__(service.channel, service, "getCapabilities", (id,))
+ super(GetCapabilitiesCommand, self).__init__(service.channel,
+ service,
+ "getCapabilities",
+ (contextID,))
+
def done(self, error, args):
- map = None
+ capabilities = None
if not error:
assert len(args) == 2
error = self.toError(args[0])
- map = args[1]
- done.doneGetCapabilities(self.token, error, map)
+ capabilities = args[1]
+ done.doneGetCapabilities(self.token, error, capabilities)
return GetCapabilitiesCommand().token
def addListener(self, listener):
diff --git a/python/src/tcf/services/remote/ContextQueryProxy.py b/python/src/tcf/services/remote/ContextQueryProxy.py
index 2d3a420e6..002d2a414 100644
--- a/python/src/tcf/services/remote/ContextQueryProxy.py
+++ b/python/src/tcf/services/remote/ContextQueryProxy.py
@@ -9,8 +9,8 @@
# * Wind River Systems - initial API and implementation
# *****************************************************************************
-from tcf.services import contextquery
-from tcf.channel.Command import Command
+from .. import contextquery
+from ...channel.Command import Command
class ContextQueryProxy(contextquery.ContextQueryService):
diff --git a/python/src/tcf/services/remote/DiagnosticsProxy.py b/python/src/tcf/services/remote/DiagnosticsProxy.py
index 9c1c63b70..82e135364 100644
--- a/python/src/tcf/services/remote/DiagnosticsProxy.py
+++ b/python/src/tcf/services/remote/DiagnosticsProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,12 +7,13 @@
# *
# * 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
+from .. import diagnostics
+from ... import errors
+from ...channel.Command import Command
+
class DiagnosticsProxy(diagnostics.DiagnosticsService):
def __init__(self, channel):
@@ -21,9 +22,12 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
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,))
+ super(EchoCommand, self).__init__(service.channel, service,
+ "echo", (s,))
+
def done(self, error, args):
result = None
if not error:
@@ -35,9 +39,12 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
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,))
+ super(EchoFPCommand, self).__init__(service.channel, service,
+ "echoFP", (n,))
+
def done(self, error, args):
n = None
if not error:
@@ -47,20 +54,23 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
return EchoFPCommand().token
def echoERR(self, err, done):
- map = None
+ errMap = None
if isinstance(err, errors.ErrorReport):
- map = err.getAttributes()
+ errMap = err.getAttributes()
else:
- map = {
+ errMap = {
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,))
+ super(EchoERRCommand, self).__init__(service.channel, service,
+ "echoERR", (errMap,))
+
def done(self, error, args):
err = None
result = None
@@ -74,9 +84,13 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
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)
+ super(GetTestListCommand, self).__init__(service.channel,
+ service,
+ "getTestList", None)
+
def done(self, error, args):
arr = None
if not error:
@@ -89,9 +103,12 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
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,))
+ super(RunTestCommand, self).__init__(service.channel, service,
+ "runTest", (s,))
+
def done(self, error, args):
result = None
if not error:
@@ -104,9 +121,13 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
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,))
+ super(CancelTestCommand, self).__init__(service.channel,
+ service, "cancelTest",
+ (s,))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -117,9 +138,14 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
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))
+ super(GetSymbolCommand, self).__init__(service.channel,
+ service, "getSymbol",
+ (context_id,
+ symbol_name))
+
def done(self, error, args):
sym = None
if not error:
@@ -132,9 +158,14 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
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))
+ 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
@@ -146,12 +177,16 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
done.doneCreateTestStreams(self.token, error, inp_id, out_id)
return CreateTestStreamsCommand().token
- def disposeTestStream(self, id, done):
+ def disposeTestStream(self, streamID, done):
done = self._makeCallback(done)
service = self
+
class DisposeTestStreamCommand(Command):
def __init__(self):
- super(DisposeTestStreamCommand, self).__init__(service.channel, service, "disposeTestStream", (id,))
+ super(DisposeTestStreamCommand,
+ self).__init__(service.channel, service,
+ "disposeTestStream", (streamID,))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -162,13 +197,19 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
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)
+ 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
+ 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 867c19b95..3c07edc21 100644
--- a/python/src/tcf/services/remote/DisassemblyProxy.py
+++ b/python/src/tcf/services/remote/DisassemblyProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013 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
@@ -9,8 +9,8 @@
# * Wind River Systems - initial API and implementation
# *****************************************************************************
-from tcf.services import disassembly
-from tcf.channel.Command import Command
+from .. import disassembly
+from ...channel.Command import Command
class DisassemblyProxy(disassembly.DisassemblyService):
diff --git a/python/src/tcf/services/remote/ExpressionsProxy.py b/python/src/tcf/services/remote/ExpressionsProxy.py
index 72529014b..19dde711b 100644
--- a/python/src/tcf/services/remote/ExpressionsProxy.py
+++ b/python/src/tcf/services/remote/ExpressionsProxy.py
@@ -1,4 +1,4 @@
-# *******************************************************************************
+# *****************************************************************************
# * Copyright (c) 2011, 2013 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
@@ -7,24 +7,29 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import expressions
+from ... import channel
+from ...channel.Command import Command
-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):
+ def assign(self, contextID, 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))
+ super(AssignCommand, self).__init__(service.channel, service,
+ "assign",
+ (contextID, value))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -35,9 +40,14 @@ class ExpressionsProxy(expressions.ExpressionsService):
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))
+ super(CreateCommand, self).__init__(service.channel, service,
+ "create",
+ (parent_id, language,
+ expression))
+
def done(self, error, args):
ctx = None
if not error:
@@ -47,12 +57,15 @@ class ExpressionsProxy(expressions.ExpressionsService):
done.doneCreate(self.token, error, ctx)
return CreateCommand().token
- def dispose(self, id, done):
+ def dispose(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class DisposeCommand(Command):
def __init__(self):
- super(DisposeCommand, self).__init__(service.channel, service, "dispose", (id,))
+ super(DisposeCommand, self).__init__(service.channel, service,
+ "dispose", (contextID,))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -60,12 +73,15 @@ class ExpressionsProxy(expressions.ExpressionsService):
done.doneDispose(self.token, error)
return DisposeCommand().token
- def evaluate(self, id, done):
+ def evaluate(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class EvalCommand(Command):
def __init__(self):
- super(EvalCommand, self).__init__(service.channel, service, "evaluate", (id,))
+ super(EvalCommand, self).__init__(service.channel, service,
+ "evaluate", (contextID,))
+
def done(self, error, args):
value = None
if not error:
@@ -73,15 +89,21 @@ class ExpressionsProxy(expressions.ExpressionsService):
value = channel.toByteArray(args[0])
error = self.toError(args[1])
props = args[2]
- done.doneEvaluate(self.token, error, expressions.Value(value, props))
+ 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,))
+ super(GetChildrenCommand, self).__init__(service.channel,
+ service,
+ "getChildren",
+ (parent_context_id,))
+
def done(self, error, args):
contexts = None
if not error:
@@ -91,18 +113,23 @@ class ExpressionsProxy(expressions.ExpressionsService):
done.doneGetChildren(self.token, error, contexts)
return GetChildrenCommand().token
- def getContext(self, id, done):
+ def getContext(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetContextCommand(Command):
def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
+ super(GetContextCommand, self).__init__(service.channel,
+ service, "getContext",
+ (contextID,))
+
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(args[1])
+ if args[1]:
+ ctx = expressions.Expression(args[1])
done.doneGetContext(self.token, error, ctx)
return GetContextCommand().token
@@ -122,6 +149,7 @@ 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)
@@ -129,6 +157,6 @@ class ChannelEventListener(channel.EventListener):
assert len(args) == 1
self.listener.valueChanged(args[0])
else:
- raise IOError("Expressions service: unknown event: " + name);
+ 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 11fdb6a08..69b4d8eb6 100644
--- a/python/src/tcf/services/remote/FileSystemProxy.py
+++ b/python/src/tcf/services/remote/FileSystemProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013 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
@@ -9,9 +9,9 @@
# * Wind River Systems - initial API and implementation
# *****************************************************************************
-from tcf import errors, channel
-from tcf.services import filesystem
-from tcf.channel.Command import Command
+from .. import filesystem
+from ... import errors, channel
+from ...channel.Command import Command
class Status(filesystem.FileSystemException):
diff --git a/python/src/tcf/services/remote/LineNumbersProxy.py b/python/src/tcf/services/remote/LineNumbersProxy.py
index 7452cc761..5436bd695 100644
--- a/python/src/tcf/services/remote/LineNumbersProxy.py
+++ b/python/src/tcf/services/remote/LineNumbersProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,23 +7,28 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import linenumbers
+from ...channel.Command import Command
-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):
+ 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))
+ "mapToSource",
+ (context_id, start_address,
+ end_address))
+
def done(self, error, args):
arr = None
if not error:
@@ -33,13 +38,17 @@ class LineNumbersProxy(linenumbers.LineNumbersService):
done.doneMapToSource(self.token, error, arr)
return MapCommand().token
- def mapToMemory(self, context_id, file, line, column, done):
+ def mapToMemory(self, context_id, filePath, 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))
+ "mapToMemory",
+ (context_id, filePath, line,
+ column))
+
def done(self, error, args):
arr = None
if not error:
@@ -49,15 +58,17 @@ class LineNumbersProxy(linenumbers.LineNumbersService):
done.doneMapToMemory(self.token, error, arr)
return MapCommand().token
+
def _toCodeAreaArray(o):
- if not o: return None
+ if not o:
+ return None
arr = []
directory = None
- file = None
+ filePath = None
for area in o:
directory = area.get("Dir", directory)
- file = area.get("File", file)
- arr.append(linenumbers.CodeArea(directory, file,
+ filePath = area.get("File", filePath)
+ arr.append(linenumbers.CodeArea(directory, filePath,
area.get("SLine", 0), area.get("SCol", 0),
area.get("ELine", 0), area.get("ECol", 0),
area.get("SAddr"), area.get("EAddr"),
diff --git a/python/src/tcf/services/remote/LocatorProxy.py b/python/src/tcf/services/remote/LocatorProxy.py
index d9963686e..730c095bb 100644
--- a/python/src/tcf/services/remote/LocatorProxy.py
+++ b/python/src/tcf/services/remote/LocatorProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,26 +7,30 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import locator
+from ... import protocol, peer, channel
+from ...channel.Command import Command
-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)
@@ -41,48 +45,58 @@ class ChannelEventListener(channel.EventListener):
try:
l.peerAdded(_peer)
except Exception as x:
- protocol.log("Unhandled exception in Locator listener", 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")
+ 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
+ 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)
+ 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]
+ peerID = args[0]
+ _peer = self.proxy.peers.get(peerID)
+ if not _peer:
+ return
+ del self.proxy.peers[peerID]
for l in self.proxy.listeners:
try:
- l.peerRemoved(id)
+ l.peerRemoved(peerID)
except Exception as x:
- protocol.log("Unhandled exception in Locator listener", 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
+ peerID = args[0]
+ _peer = self.proxy.peers.get(peerID)
+ if not _peer:
+ return
for l in self.proxy.listeners:
try:
- l.peerHeartBeat(id)
+ l.peerHeartBeat(peerID)
except Exception as x:
- protocol.log("Unhandled exception in Locator listener", 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.channel = channel
self.peers = {}
self.listeners = []
self.get_peers_done = False
@@ -95,9 +109,12 @@ class LocatorProxy(locator.LocatorService):
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])
+ super(RedirectCommand, self).__init__(service.channel, service,
+ "redirect", [_peer])
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -108,11 +125,15 @@ class LocatorProxy(locator.LocatorService):
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)
+ super(SyncCommand, self).__init__(service.channel, service,
+ "sync", None)
+
def done(self, error, args):
- if error: service.channel.terminate(error)
+ if error:
+ service.channel.terminate(error)
done.doneSync(self.token)
return SyncCommand().token
@@ -120,9 +141,13 @@ class LocatorProxy(locator.LocatorService):
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)
+ super(GetPeersCommand, self).__init__(service.channel,
+ service, "getPeers",
+ None)
+
def done(self, error, args):
if not error:
assert len(args) == 2
@@ -133,15 +158,17 @@ class LocatorProxy(locator.LocatorService):
c = args[1]
if c:
for m in c:
- id = m.get(peer.ATTR_ID)
- if service.peers.get(id): continue;
+ peerID = m.get(peer.ATTR_ID)
+ if service.peers.get(peerID):
+ continue
_peer = Peer(service.channel.getRemotePeer(), m)
- service.peers[id] = _peer
+ service.peers[peerID] = _peer
for l in service.listeners:
try:
l.peerAdded(_peer)
except Exception as x:
- protocol.log("Unhandled exception in Locator listener", x)
+ protocol.log("Unhandled exception in " +
+ "Locator listener", x)
GetPeersCommand()
self.get_peers_done = True
diff --git a/python/src/tcf/services/remote/MemoryMapProxy.py b/python/src/tcf/services/remote/MemoryMapProxy.py
index 34aab1d5f..f21eaf0a4 100644
--- a/python/src/tcf/services/remote/MemoryMapProxy.py
+++ b/python/src/tcf/services/remote/MemoryMapProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,40 +7,49 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import memorymap
+from ... import channel
+from ...channel.Command import Command
-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):
+ def get(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetCommand(Command):
def __init__(self):
- super(GetCommand, self).__init__(service.channel, service, "get", (id,))
+ super(GetCommand, self).__init__(service.channel, service,
+ "get", (contextID,))
+
def done(self, error, args):
- map = None
+ memMap = 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)
+ if args[1]:
+ memMap = _toMemoryMap(args[1])
+ done.doneGet(self.token, error, memMap)
return GetCommand().token
- def set(self, id, map, done):
- if isinstance(map, memorymap.MemoryRegion) or isinstance(map, dict):
- map = (map,)
+ def set(self, contextID, memMap, done):
+ if isinstance(memMap, memorymap.MemoryRegion) or \
+ isinstance(memMap, dict):
+ memMap = (memMap,)
done = self._makeCallback(done)
service = self
+
class SetCommand(Command):
def __init__(self):
- super(SetCommand, self).__init__(service.channel, service, "set", (id, map))
+ super(SetCommand, self).__init__(service.channel, service,
+ "set", (contextID, memMap))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -55,12 +64,15 @@ class MemoryMapProxy(memorymap.MemoryMapService):
def removeListener(self, listener):
l = self.listeners.pop(listener, None)
- if l: self.channel.removeEventListener(self, l)
+ 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)
@@ -68,15 +80,18 @@ class ChannelEventListener(channel.EventListener):
assert len(args) == 1
self.listener.changed(args[0])
else:
- raise IOError("MemoryMap service: unknown event: " + name);
+ 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
+ if o is None:
+ return None
return map(_toMemoryRegion, o)
+
def _toMemoryRegion(o):
- if o is None: return None
+ 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 8cf9f302e..8d84d3746 100644
--- a/python/src/tcf/services/remote/MemoryProxy.py
+++ b/python/src/tcf/services/remote/MemoryProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013 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
@@ -9,21 +9,27 @@
# * Wind River Systems - initial API and implementation
# *****************************************************************************
-from tcf import errors, channel
-from tcf.services import memory
-from tcf.channel.Command import Command
+from .. import memory
+from ... import errors, channel
+from ...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
+ if self.offs < o.offs:
+ return -1
+ if self.offs > o.offs:
+ return +1
return 0
-class MemoryErrorReport(errors.ErrorReport, memory.MemoryError, memory.ErrorOffset):
+
+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:
@@ -40,14 +46,16 @@ class MemoryErrorReport(errors.ErrorReport, memory.MemoryError, memory.ErrorOffs
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))
+ key = memory.ErrorOffset.RANGE_KEY_MSG
+ r.msg = errors.toErrorString(m.get(key))
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
+ if self.ranges is None:
+ return None
l = 0
h = len(self.ranges) - 1
while l <= h:
@@ -62,7 +70,8 @@ class MemoryErrorReport(errors.ErrorReport, memory.MemoryError, memory.ErrorOffs
return None
def getStatus(self, offset):
- if self.ranges is None: return memory.ErrorOffset.BYTE_UNKNOWN
+ if self.ranges is None:
+ return memory.ErrorOffset.BYTE_UNKNOWN
l = 0
h = len(self.ranges) - 1
while l <= h:
@@ -84,12 +93,15 @@ class MemContext(memory.MemoryContext):
def fill(self, addr, word_size, value, size, mode, done):
service = self.service
- id = self.getID()
+ contextID = 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))
+ super(FillCommand, self).__init__(service, "fill",
+ (contextID, addr, word_size,
+ size, mode, value))
+
def done(self, error, args):
e = None
if error:
@@ -102,12 +114,15 @@ class MemContext(memory.MemoryContext):
def get(self, addr, word_size, buf, offs, size, mode, done):
service = self.service
- id = self.getID()
+ contextID = self.getID()
done = service._makeCallback(done)
+
class GetCommand(MemoryCommand):
def __init__(self):
- super(GetCommand, self).__init__(service,
- "get", (id, addr, word_size, size, mode))
+ super(GetCommand, self).__init__(service, "get",
+ (contextID, addr, word_size,
+ size, mode))
+
def done(self, error, args):
e = None
if error:
@@ -116,19 +131,24 @@ class MemContext(memory.MemoryContext):
assert len(args) == 3
byts = channel.toByteArray(args[0])
assert len(byts) <= size
- buf[offs:offs+len(byts)] = byts
+ buf[offs:offs + len(byts)] = byts
e = self.toMemoryError(addr, 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()
+ contextID = 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])))
+ super(SetCommand, self).__init__(service, "set",
+ (contextID, addr, word_size,
+ size, mode,
+ bytearray(buf[offs:offs +
+ size])))
+
def done(self, error, args):
e = None
if error:
@@ -139,6 +159,7 @@ class MemContext(memory.MemoryContext):
done.doneMemory(self.token, e)
return SetCommand().token
+
class MemoryProxy(memory.MemoryService):
def __init__(self, channel):
self.channel = channel
@@ -147,24 +168,34 @@ class MemoryProxy(memory.MemoryService):
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,))
+ 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])
+ 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,))
+ super(GetChildrenCommand, self).__init__(service.channel,
+ service,
+ "getChildren",
+ (parent_context_id,))
+
def done(self, error, args):
contexts = None
if not error:
@@ -185,20 +216,26 @@ class MemoryProxy(memory.MemoryService):
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)
+ super(MemoryCommand, self).__init__(service.channel, service, cmd,
+ args)
+
def toMemoryError(self, addr, data, ranges):
- if data is None: return None
+ 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: %d" % (
- cmd, errors.toErrorString(data), code),
+ if len(cmd) > 72:
+ cmd = cmd[0:72] + "..."
+ e = MemoryErrorReport("TCF command exception:\nCommand: %s\n" +
+ "Exception: %s\nError code: %d" %
+ (cmd, errors.toErrorString(data), code),
data, addr, ranges)
caused_by = data.get(errors.ERROR_CAUSED_BY)
- if caused_by is not None: e.caused_by = self.toError(caused_by, False)
+ if caused_by is not None:
+ e.caused_by = self.toError(caused_by, False)
return e
@@ -206,37 +243,47 @@ 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]))
+ self.listener.contextAdded(_toContextArray(self.service,
+ args[0]))
elif name == "contextChanged":
assert len(args) == 1
- self.listener.contextChanged(_toContextArray(self.service, args[0]))
+ 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]))
+ self.listener.memoryChanged(args[0], _toAddrArray(args[1]),
+ _toSizeArray(args[1]))
else:
- raise IOError("Memory service: unknown event: " + name);
+ 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
+ if o is None:
+ return None
ctx = []
- for m in o: ctx.append(MemContext(svc, m))
+ for m in o:
+ ctx.append(MemContext(svc, m))
return ctx
+
def _toSizeArray(o):
- if o is None: return None
+ if o is None:
+ return None
return map(lambda m: m.get("size", 0), o)
+
def _toAddrArray(o):
- if o is None: return None
+ 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 28f64881f..b4755521b 100644
--- a/python/src/tcf/services/remote/PathMapProxy.py
+++ b/python/src/tcf/services/remote/PathMapProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013 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
@@ -9,9 +9,9 @@
# * Wind River Systems - initial API and implementation
# *****************************************************************************
-from tcf import channel
-from tcf.services import pathmap
-from tcf.channel.Command import Command
+from .. import pathmap
+from ... import channel
+from ...channel.Command import Command
class ChannelEventListener(channel.EventListener):
diff --git a/python/src/tcf/services/remote/ProcessesProxy.py b/python/src/tcf/services/remote/ProcessesProxy.py
index eeba4dcd6..bb9b5f9a6 100644
--- a/python/src/tcf/services/remote/ProcessesProxy.py
+++ b/python/src/tcf/services/remote/ProcessesProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,11 +7,12 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import processes
+from ... import channel
+from ...channel.Command import Command
-from tcf import channel
-from tcf.services import processes
-from tcf.channel.Command import Command
class ProcessContext(processes.ProcessContext):
def __init__(self, service, props):
@@ -30,11 +31,13 @@ class ProcessContext(processes.ProcessContext):
def _command(self, command, done):
service = self.service
done = service._makeCallback(done)
- id = self.getID()
+ contextID = self.getID()
+
class _Command(Command):
def __init__(self):
super(_Command, self).__init__(service.channel, service,
- command, (id,))
+ command, (contextID,))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -42,6 +45,7 @@ class ProcessContext(processes.ProcessContext):
done.doneCommand(self.token, error)
return _Command().token
+
class ProcessesProxy(processes.ProcessesService):
def __init__(self, channel):
self.channel = channel
@@ -50,10 +54,15 @@ class ProcessesProxy(processes.ProcessesService):
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))
+ super(GetChildrenCommand, self).__init__(service.channel,
+ service,
+ "getChildren",
+ (parent_context_id,
+ attached_only))
+
def done(self, error, args):
contexts = None
if not error:
@@ -66,24 +75,32 @@ class ProcessesProxy(processes.ProcessesService):
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,))
+ 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])
+ 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)
+ super(GetEnvCommand, self).__init__(service.channel, service,
+ "getEnvironment", None)
+
def done(self, error, args):
env = None
if not error:
@@ -93,46 +110,60 @@ class ProcessesProxy(processes.ProcessesService):
done.doneGetEnvironment(self.token, error, env)
return GetEnvCommand().token
- def start(self, directory, file, command_line, environment, attach, done):
+ def start(self, directory, filePath, 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))
+ "start",
+ (directory, filePath,
+ 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])
+ 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,))
+ super(GetSignalsCommand, self).__init__(service.channel,
+ service,
+ "getSignalList",
+ (context_id,))
+
def done(self, error, args):
- list = None
+ lst = None
if not error:
assert len(args) == 2
error = self.toError(args[0])
- list = args[1]
- done.doneGetSignalList(self.token, error, list)
+ lst = args[1]
+ done.doneGetSignalList(self.token, error, lst)
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,))
+ super(GetSignalMaskCommand, self).__init__(service.channel,
+ service,
+ "getSignalMask",
+ (context_id,))
+
def done(self, error, args):
dont_stop = 0
dont_pass = 0
@@ -141,16 +172,23 @@ class ProcessesProxy(processes.ProcessesService):
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)
+ 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))
+ 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
@@ -161,10 +199,13 @@ class ProcessesProxy(processes.ProcessesService):
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))
+ super(SignalCommand, self).__init__(service.channel,
+ service, "signal",
+ (context_id, signal))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -183,10 +224,12 @@ class ProcessesProxy(processes.ProcessesService):
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)
@@ -194,22 +237,28 @@ class ChannelEventListener(channel.EventListener):
assert len(args) == 2
self.listener.exited(args[0], args[1])
else:
- raise IOError("Processes service: unknown event: " + name);
+ raise IOError("Processes service: unknown event: " + name)
except Exception as x:
self.service.channel.terminate(x)
-def _toEnvStringArray(map):
+
+def _toEnvStringArray(envVars):
arr = []
- if not map: return arr
- for name, value in map.items():
+ if not envVars:
+ return arr
+ for name, value in envVars.items():
arr.append("%s=%s" % (name, value))
return arr
+
def _toEnvMap(arr):
- map = {}
- if not arr: return map
+ envVars = {}
+ if not arr:
+ return envVars
for env in arr:
i = env.find('=')
- if i >= 0: map[env[:i]] = env[i + 1:]
- else: map[env] = ""
- return map
+ if i >= 0:
+ envVars[env[:i]] = env[i + 1:]
+ else:
+ envVars[env] = ""
+ return envVars
diff --git a/python/src/tcf/services/remote/ProcessesV1Proxy.py b/python/src/tcf/services/remote/ProcessesV1Proxy.py
index c16d15624..883b9d457 100644
--- a/python/src/tcf/services/remote/ProcessesV1Proxy.py
+++ b/python/src/tcf/services/remote/ProcessesV1Proxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,26 +7,35 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
from . import ProcessesProxy
-from tcf.services import processes_v1
-from tcf.channel.Command import Command
+from .. import processes_v1
+from ...channel.Command import Command
-class ProcessesV1Proxy(ProcessesProxy.ProcessesProxy, processes_v1.ProcessesV1Service):
- def start(self, directory, file, command_line, environment, params, done):
+
+class ProcessesV1Proxy(ProcessesProxy.ProcessesProxy,
+ processes_v1.ProcessesV1Service):
+
+ def start(self, directory, filePath, 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))
+ "start",
+ (directory, filePath,
+ 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])
+ 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 fdf3d9ae8..aa52f34b4 100644
--- a/python/src/tcf/services/remote/RegistersProxy.py
+++ b/python/src/tcf/services/remote/RegistersProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,12 +7,13 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import registers
+from ... import channel
+from ...channel import toByteArray
+from ...channel.Command import Command
-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):
@@ -25,10 +26,13 @@ class Context(registers.RegistersContext):
def get(self, done):
service = self.service
done = service._makeCallback(done)
- id = self.getID()
+ contextID = self.getID()
+
class GetCommand(Command):
def __init__(self):
- super(GetCommand, self).__init__(service.channel, service, "get", (id,))
+ super(GetCommand, self).__init__(service.channel, service,
+ "get", (contextID,))
+
def done(self, error, args):
val = None
if not error:
@@ -41,11 +45,14 @@ class Context(registers.RegistersContext):
def set(self, value, done):
service = self.service
done = service._makeCallback(done)
- id = self.getID()
+ contextID = self.getID()
binary = bytearray(value)
+
class SetCommand(Command):
def __init__(self):
- super(SetCommand, self).__init__(service.channel, service, "set", (id, binary))
+ super(SetCommand, self).__init__(service.channel, service,
+ "set", (contextID, binary))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -53,13 +60,17 @@ class Context(registers.RegistersContext):
done.doneSet(self.token, error)
return SetCommand().token
- def search(self, filter, done):
+ def search(self, filterOn, done):
service = self.service
done = service._makeCallback(done)
- id = self.getID()
+ contextID = self.getID()
+
class SearchCommand(Command):
def __init__(self):
- super(SearchCommand, self).__init__(service.channel, service, "search", (id, filter))
+ super(SearchCommand, self).__init__(service.channel, service,
+ "search",
+ (contextID, filterOn))
+
def done(self, error, args):
paths = None
if not error:
@@ -69,6 +80,7 @@ class Context(registers.RegistersContext):
done.doneSearch(self.token, error, paths)
return SearchCommand().token
+
class RegistersProxy(registers.RegistersService):
def __init__(self, channel):
self.channel = channel
@@ -77,9 +89,14 @@ class RegistersProxy(registers.RegistersService):
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,))
+ super(GetChildrenCommand, self).__init__(service.channel,
+ service,
+ "getChildren",
+ (parent_context_id,))
+
def done(self, error, args):
contexts = None
if not error:
@@ -89,27 +106,35 @@ class RegistersProxy(registers.RegistersService):
done.doneGetChildren(self.token, error, contexts)
return GetChildrenCommand().token
- def getContext(self, id, done):
+ def getContext(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetContextCommand(Command):
def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
+ super(GetContextCommand, self).__init__(service.channel,
+ service, "getContext",
+ (contextID,))
+
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])
+ 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,))
+ super(GetMCommand, self).__init__(service.channel, service,
+ "getm", (locs,))
+
def done(self, error, args):
val = None
if not error:
@@ -123,9 +148,12 @@ class RegistersProxy(registers.RegistersService):
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))
+ super(SetMCommand, self).__init__(service.channel, service,
+ "setm", (locs, binary))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -144,6 +172,7 @@ class RegistersProxy(registers.RegistersService):
del self.listeners[listener]
self.channel.removeEventListener(self, l)
+
class NamedValueInfo(registers.NamedValue):
def __init__(self, m):
desc = m.get("Description")
@@ -151,17 +180,21 @@ class NamedValueInfo(registers.NamedValue):
value = toByteArray(m.get("Value"))
super(NamedValueInfo, self).__init__(value, name, desc)
+
def _toValuesArray(o):
- if o is None: return None
+ 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)
@@ -171,6 +204,6 @@ class ChannelEventListener(channel.EventListener):
assert len(args) == 1
self.listener.registerChanged(args[0])
else:
- raise IOError("Registers service: unknown event: " + name);
+ 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 60d20fea8..8aef1bcaa 100644
--- a/python/src/tcf/services/remote/RunControlProxy.py
+++ b/python/src/tcf/services/remote/RunControlProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,11 +7,12 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import runcontrol
+from ... import channel
+from ...channel.Command import Command
-from tcf import channel
-from tcf.services import runcontrol
-from tcf.channel.Command import Command
class RunContext(runcontrol.RunControlContext):
def __init__(self, service, props):
@@ -21,23 +22,27 @@ class RunContext(runcontrol.RunControlContext):
def getState(self, done):
service = self.service
done = service._makeCallback(done)
- id = self.getID()
+ contextID = self.getID()
+
class GetStateCommand(Command):
def __init__(self):
- super(GetStateCommand, self).__init__(service.channel, service, "getState", (id,))
+ super(GetStateCommand, self).__init__(service.channel, service,
+ "getState", (contextID,))
+
def done(self, error, args):
susp = False
pc = None
reason = None
- map = None
+ states = None
if not error:
assert len(args) == 5
error = self.toError(args[0])
susp = args[1]
- if args[2]: pc = str(args[2])
+ if args[2]:
+ pc = str(args[2])
reason = args[3]
- map = args[4]
- done.doneGetState(self.token, error, susp, pc, reason, map)
+ states = args[4]
+ done.doneGetState(self.token, error, susp, pc, reason, states)
return GetStateCommand().token
# def resume(self, mode, count, done):
@@ -47,7 +52,8 @@ class RunContext(runcontrol.RunControlContext):
if not params:
return self._command("resume", (self.getID(), mode, count), done)
else:
- return self._command("resume", (self.getID(), mode, count, params), done)
+ return self._command("resume", (self.getID(), mode, count, params),
+ done)
def suspend(self, done):
return self._command("suspend", (self.getID(),), done)
@@ -58,9 +64,12 @@ class RunContext(runcontrol.RunControlContext):
def _command(self, cmd, args, done):
service = self.service
done = service._makeCallback(done)
+
class RCCommand(Command):
def __init__(self, cmd, args):
- super(RCCommand, self).__init__(service.channel, service, cmd, args)
+ super(RCCommand, self).__init__(service.channel, service, cmd,
+ args)
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -73,21 +82,25 @@ 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])
+ 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]))
+ self.listener.contextAdded(_toContextArray(self.service,
+ args[0]))
elif name == "contextChanged":
assert len(args) == 1
- self.listener.contextChanged(_toContextArray(self.service,args[0]))
+ self.listener.contextChanged(_toContextArray(self.service,
+ args[0]))
elif name == "contextRemoved":
assert len(args) == 1
self.listener.contextRemoved(args[0])
@@ -96,15 +109,17 @@ class ChannelEventListener(channel.EventListener):
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])
+ 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);
+ 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
@@ -124,24 +139,34 @@ class RunControlProxy(runcontrol.RunControlService):
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,))
+ 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])
+ 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,))
+ super(GetChildrenCommand, self).__init__(service.channel,
+ service,
+ "getChildren",
+ (parent_context_id,))
+
def done(self, error, args):
contexts = None
if not error:
@@ -151,8 +176,11 @@ class RunControlProxy(runcontrol.RunControlService):
done.doneGetChildren(self.token, error, contexts)
return GetChildrenCommand().token
-def _toContextArray(svc,o):
- if o is None: return None
+
+def _toContextArray(svc, o):
+ if o is None:
+ return None
ctx = []
- for m in o: ctx.append(RunContext(svc,m))
+ 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 5a2d6288f..843cf1e8c 100644
--- a/python/src/tcf/services/remote/StackTraceProxy.py
+++ b/python/src/tcf/services/remote/StackTraceProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,10 +7,11 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import stacktrace
+from ...channel.Command import Command
-from tcf.services import stacktrace
-from tcf.channel.Command import Command
class StackTraceProxy(stacktrace.StackTraceService):
def __init__(self, channel):
@@ -19,9 +20,14 @@ class StackTraceProxy(stacktrace.StackTraceService):
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,))
+ super(GetChildrenCommand, self).__init__(service.channel,
+ service,
+ "getChildren",
+ (parent_context_id,))
+
def done(self, error, args):
contexts = None
if not error:
@@ -34,9 +40,13 @@ class StackTraceProxy(stacktrace.StackTraceService):
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,))
+ super(GetContextCommand, self).__init__(service.channel,
+ service, "getContext",
+ (ids,))
+
def done(self, error, args):
ctxs = None
if not error:
@@ -47,7 +57,8 @@ class StackTraceProxy(stacktrace.StackTraceService):
return GetContextCommand().token
def toContextArray(self, ctxProps):
- if ctxProps is None: return None
+ if ctxProps is None:
+ return None
ctxs = []
for props in ctxProps:
ctxs.append(stacktrace.StackTraceContext(props))
diff --git a/python/src/tcf/services/remote/StreamsProxy.py b/python/src/tcf/services/remote/StreamsProxy.py
index 67297e7d1..d249a5b93 100644
--- a/python/src/tcf/services/remote/StreamsProxy.py
+++ b/python/src/tcf/services/remote/StreamsProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,11 +7,12 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import streams
+from ... import channel
+from ...channel.Command import Command
-from tcf.services import streams
-from tcf import channel
-from tcf.channel.Command import Command
class StreamsProxy(streams.StreamsService):
def __init__(self, channel):
@@ -21,9 +22,12 @@ class StreamsProxy(streams.StreamsService):
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,))
+ super(ConnectCommand, self).__init__(service.channel, service,
+ "connect", (stream_id,))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -34,9 +38,13 @@ class StreamsProxy(streams.StreamsService):
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,))
+ super(DisconnectCommand, self).__init__(service.channel,
+ service, "disconnect",
+ (stream_id,))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -47,9 +55,12 @@ class StreamsProxy(streams.StreamsService):
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,))
+ super(EOSCommand, self).__init__(service.channel, service,
+ "eos", (stream_id,))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -60,9 +71,12 @@ class StreamsProxy(streams.StreamsService):
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))
+ super(ReadCommand, self).__init__(service.channel, service,
+ "read", (stream_id, size))
+
def done(self, error, args):
lost_size = 0
data = None
@@ -79,9 +93,13 @@ class StreamsProxy(streams.StreamsService):
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,))
+ super(SubscribeCommand, self).__init__(service.channel,
+ service, "subscribe",
+ (stream_type,))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -96,26 +114,36 @@ class StreamsProxy(streams.StreamsService):
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,))
+ 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)
+ 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]
+ binary = buf[offset:offset + size]
+
class WriteCommand(Command):
def __init__(self):
- super(WriteCommand, self).__init__(service.channel, service, "write", (stream_id, binary))
+ super(WriteCommand, self).__init__(service.channel, service,
+ "write",
+ (stream_id, binary))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -128,6 +156,7 @@ 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)
@@ -141,6 +170,6 @@ class ChannelEventListener(channel.EventListener):
assert len(args) == 2
self.listener.disposed(args[0], args[1])
else:
- raise IOError("Streams service: unknown event: " + name);
+ 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 a8556f1df..29966ecce 100644
--- a/python/src/tcf/services/remote/SymbolsProxy.py
+++ b/python/src/tcf/services/remote/SymbolsProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013 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
@@ -9,9 +9,9 @@
# * Wind River Systems - initial API and implementation
# *****************************************************************************
-from tcf import channel
-from tcf.services import symbols
-from tcf.channel.Command import Command
+from .. import symbols
+from ... import channel
+from ...channel.Command import Command
class Context(symbols.Symbol):
diff --git a/python/src/tcf/services/remote/SysMonitorProxy.py b/python/src/tcf/services/remote/SysMonitorProxy.py
index 7d9b2835c..9e2833fd5 100644
--- a/python/src/tcf/services/remote/SysMonitorProxy.py
+++ b/python/src/tcf/services/remote/SysMonitorProxy.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 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
@@ -7,10 +7,11 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
+
+from .. import sysmonitor
+from ...channel.Command import Command
-from tcf.services import sysmonitor
-from tcf.channel.Command import Command
class SysMonitorProxy(sysmonitor.SysMonitorService):
def __init__(self, channel):
@@ -19,9 +20,14 @@ class SysMonitorProxy(sysmonitor.SysMonitorService):
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,))
+ super(GetChildrenCommand, self).__init__(service.channel,
+ service,
+ "getChildren",
+ (parent_context_id,))
+
def done(self, error, args):
contexts = None
if not error:
@@ -31,27 +37,37 @@ class SysMonitorProxy(sysmonitor.SysMonitorService):
done.doneGetChildren(self.token, error, contexts)
return GetChildrenCommand().token
- def getContext(self, id, done):
+ def getContext(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetContextCommand(Command):
def __init__(self):
- super(GetContextCommand, self).__init__(service.channel, service, "getContext", (id,))
+ super(GetContextCommand, self).__init__(service.channel,
+ service, "getContext",
+ (contextID,))
+
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])
+ if args[1]:
+ ctx = sysmonitor.SysMonitorContext(args[1])
done.doneGetContext(self.token, error, ctx)
return GetContextCommand().token
- def getCommandLine(self, id, done):
+ def getCommandLine(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetCommandLineCommand(Command):
def __init__(self):
- super(GetCommandLineCommand, self).__init__(service.channel, service, "getCommandLine", (id,))
+ super(GetCommandLineCommand, self).__init__(service.channel,
+ service,
+ "getCommandLine",
+ (contextID,))
+
def done(self, error, args):
arr = None
if not error:
@@ -61,12 +77,17 @@ class SysMonitorProxy(sysmonitor.SysMonitorService):
done.doneGetCommandLine(self.token, error, arr)
return GetCommandLineCommand().token
- def getEnvironment(self, id, done):
+ def getEnvironment(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetEnvironmentCommand(Command):
def __init__(self):
- super(GetEnvironmentCommand, self).__init__(service.channel, service, "getEnvironment", (id,))
+ super(GetEnvironmentCommand, self).__init__(service.channel,
+ service,
+ "getEnvironment",
+ (contextID,))
+
def done(self, error, args):
arr = None
if not error:
diff --git a/python/src/tcf/services/remote/TerminalsProxy.py b/python/src/tcf/services/remote/TerminalsProxy.py
index 08d986eeb..f3e3d275a 100644
--- a/python/src/tcf/services/remote/TerminalsProxy.py
+++ b/python/src/tcf/services/remote/TerminalsProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013 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
@@ -9,9 +9,10 @@
# * Wind River Systems - initial API and implementation
# *****************************************************************************
-from tcf.services import terminals
-from tcf import channel
-from tcf.channel.Command import Command
+from .. import terminals
+from ... import channel
+from ...channel.Command import Command
+
class TerminalContext(terminals.TerminalContext):
def __init__(self, service, props):
@@ -22,10 +23,12 @@ class TerminalContext(terminals.TerminalContext):
service = self.service
done = service._makeCallback(done)
context_id = self.getID()
+
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
@@ -39,43 +42,57 @@ class TerminalsProxy(terminals.TerminalsService):
self.channel = channel
self.listeners = {}
- def getContext(self, id, done):
+ def getContext(self, contextID, done):
done = self._makeCallback(done)
service = self
+
class GetContextCommand(Command):
def __init__(self):
super(GetContextCommand, self).__init__(
- service.channel, service, "getContext", (id,))
+ service.channel, service, "getContext", (contextID,))
+
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])
+ if args[1]:
+ ctx = TerminalContext(service, args[1])
done.doneGetContext(self.token, error, ctx)
return GetContextCommand().token
def launch(self, terminal_type, encoding, environment, done):
done = self._makeCallback(done)
service = self
+
class LaunchCommand(Command):
def __init__(self):
- super(LaunchCommand, self).__init__(service.channel, service, "launch", (terminal_type, encoding, environment))
+ super(LaunchCommand, self).__init__(service.channel, service,
+ "launch",
+ (terminal_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])
+ 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))
+ super(SetWinSizeCommand, self).__init__(service.channel,
+ service, "setWinSize",
+ (context_id, newWidth,
+ newHeight))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -86,9 +103,12 @@ class TerminalsProxy(terminals.TerminalsService):
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,))
+ super(ExitCommand, self).__init__(service.channel, service,
+ "exit", (context_id,))
+
def done(self, error, args):
if not error:
assert len(args) == 1
@@ -103,13 +123,15 @@ class TerminalsProxy(terminals.TerminalsService):
def removeListener(self, listener):
l = self.listeners.pop(listener, None)
- if l: self.channel.removeEventListener(self, l)
+ 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)
@@ -120,6 +142,6 @@ class ChannelEventListener(channel.EventListener):
assert len(args) == 3
self.listener.winSizeChanged(args[0], args[1], args[2])
else:
- raise IOError("Terminals service: unknown event: " + name);
+ raise IOError("Terminals service: unknown event: " + name)
except Exception as x:
self.service.channel.terminate(x)

Back to the top