Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/tcf/services/remote/RunControlProxy.py')
-rw-r--r--python/src/tcf/services/remote/RunControlProxy.py78
1 files changed, 53 insertions, 25 deletions
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

Back to the top