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

Back to the top