Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/src/tcf/services/processes_v1.py182
-rw-r--r--python/src/tcf/services/remote/ContextQueryProxy.py2
-rw-r--r--python/src/tcf/services/remote/ProcessesV1Proxy.py24
-rw-r--r--python/src/tcf/tests/ProcessStart.py42
4 files changed, 203 insertions, 47 deletions
diff --git a/python/src/tcf/services/processes_v1.py b/python/src/tcf/services/processes_v1.py
index 2218100cc..83bfae6ae 100644
--- a/python/src/tcf/services/processes_v1.py
+++ b/python/src/tcf/services/processes_v1.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011-2014 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,49 +9,183 @@
# * Wind River Systems - initial API and implementation
# *****************************************************************************
-"""
-Extension of Processes service.
-It provides new "start" command that supports additional parameters.
+"""Extension of Processes service.
+
+.. |start| replace:: :meth:`~tcf.services.processes.ProcessesService.start`
+.. |DoneStart| replace:: :class:`~tcf.services.processes.DoneStart`
+
+It provides new |start| command that supports additional parameters.
+
+Properties
+----------
+Process Context Properties
+^^^^^^^^^^^^^^^^^^^^^^^^^^
++-----------------+--------+--------------------------------------------------+
+| Name | Type | Description |
++=================+========+==================================================+
+| PROP_CAN_ATTACH | |bool| | **True** if process can be attached. |
++-----------------+--------+--------------------------------------------------+
+| PROP_IS_PROCESS | |bool| | **True** if context is a process (as opposed to |
+| | | thread or some specific processes). |
++-----------------+--------+--------------------------------------------------+
+
+Processes Service Capablities
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
++----------------------+--------+---------------------------------------------+
+| Name | Type | Description |
++======================+========+=============================================+
+| PROP_PROC_CREATION | |bool| | **True** if process creation is supported. |
++----------------------+--------+---------------------------------------------+
+| PROP_THREAD_CREATION | |bool| | **True** if thread creation is supported. |
++----------------------+--------+---------------------------------------------+
+| PROP_MAX_THREAD_ARGS | |int| | Maximum number of argument for thread |
+| | | creation. |
++----------------------+--------+---------------------------------------------+
+| PROP_START_PARAMS | |list| | The list of parameters supported by |start| |
+| | | command. |
++----------------------+--------+---------------------------------------------+
+
+Process Start Properties
+^^^^^^^^^^^^^^^^^^^^^^^^
++-----------------------+--------------+--------------------------------------+
+| Name | Type | Description |
++=======================+==============+======================================+
+| START_ATTACH | |bool| | Attach the debugger to the process. |
++-----------------------+--------------+--------------------------------------+
+| START_ATTACH_CHILDREN | |bool| | Auto-attach process children. |
++-----------------------+--------------+--------------------------------------+
+| START_STOP_AT_ENTRY | |bool| | Stop at process entry. |
++-----------------------+--------------+--------------------------------------+
+| START_STOP_AT_MAIN | |bool| | Stop at main(). |
++-----------------------+--------------+--------------------------------------+
+| START_USE_TERMINAL | |bool| | Use pseudo-terminal for the process |
+| | | standard I/O. |
++-----------------------+--------------+--------------------------------------+
+| START_MEM_SPACE_ID | |basestring| | Process memory space in which to |
+| | | start thead in. |
++-----------------------+--------------+--------------------------------------+
+| START_SYMBOL | |basestring| | Entry point symbol to start thread. |
++-----------------------+--------------+--------------------------------------+
+| START_ADDRESS | |long| | Entry point address to start thread. |
++-----------------------+--------------+--------------------------------------+
+| START_NAME | |basestring| | Name of the thread to start. |
++-----------------------+--------------+--------------------------------------+
+| START_PRIORITY | |int| | The thread priority. |
++-----------------------+--------------+--------------------------------------+
+| START_STACK_SIZE | |long| | The thread stack size. |
++-----------------------+--------------+--------------------------------------+
+| START_PROC_OPTIONS | |int| | The process options flag value. |
++-----------------------+--------------+--------------------------------------+
+| START_THREAD_OPTIONS | |int| | The thread options flag value. |
++-----------------------+--------------+--------------------------------------+
+
+Service Methods
+---------------
+.. autodata:: NAME
+.. autoclass:: ProcessesV1Service
+
+start
+^^^^^
+.. automethod:: ProcessesV1Service.start
+
+getCapabilities
+^^^^^^^^^^^^^^^
+.. automethod:: ProcessesV1Service.getCapabilities
"""
from . import processes
NAME = "ProcessesV1"
+"""Processes version 1 service name."""
# Process start parameters
-# Boolean, attach the debugger to the process
+
START_ATTACH = "Attach"
-# Boolean, auto-attach process children
START_ATTACH_CHILDREN = "AttachChildren"
-# Boolean, stop at process entry
START_STOP_AT_ENTRY = "StopAtEntry"
-# Boolean, stop at main()
START_STOP_AT_MAIN = "StopAtMain"
-# Boolean, Use pseudo-terminal for the process standard I/O
START_USE_TERMINAL = "UseTerminal"
+START_MEM_SPACE_ID = "MemSpaceID"
+START_SYMBOL = "StartSymbol"
+START_ADDRESS = "StartAddress"
+START_NAME = "Name"
+START_PRIORITY = "Priority"
+START_STACK_SIZE = "StackSize"
+START_PROC_OPTIONS = "ProcessOptions"
+START_THREAD_OPTIONS = "ThreadOptions"
+
+# Context properties.
+
+PROP_CAN_ATTACH = "CanAttach"
+PROP_IS_PROCESS = "IsProcess"
+
+# Capability properties.
+
+PROP_PROC_CREATION = "ProcessCreation"
+PROP_THREAD_CREATION = "ThreadCreation"
+PROP_MAX_THREAD_ARGS = "MaxThreadArgs"
+PROP_START_PARAMS = "StartParams"
+
+
+class DoneGetCapabilities (object):
+ """A class to implement TCF's ProcessesV1 |getCapabilities| end.
+
+ When TCF's ProcessesV1 service |getCapabilities| method is called, this
+ class can be specified as the *done* parameter.
+ """
+
+ def doneGetCapabilities(self, token, error, capabilityData):
+ """Implementation method for TCF's ProcessesV1 service
+ doneGetCapabilities().
+
+ :param token: TCF request token corresponding to the command.
+ :param error: Potential error returned by the TCF agent.
+ :param capabilityData: Capability data properties.
+ """
+ raise NotImplementedError("Abstract method")
class ProcessesV1Service(processes.ProcessesService):
+ """TCF processes Version 1 service interface."""
+
def getName(self):
+ """Get this service name.
+
+ :returns: This service name, which is the value of :const:`NAME`
+ """
return NAME
def start(self, directory, filePath, command_line, environment, params,
done):
+ """Start a new process on remote machine.
+
+ .. note:: The service does **NOT** add image file name as first
+ argument for the process. If a client wants first parameter
+ to be the file name, it should add it itself.
+
+ :param directory: Initial value of working directory for the process.
+ :type directory: |basestring|
+ :param filePath: Process image file.
+ :type filePath: |basestring|
+ :param command_line: Command line arguments for the process.
+ :type command_line: |list| of |basestring|
+ :param environment: A |dict| of environment variables for the process,
+ if **None** then default set of environment
+ variables will be used.
+ :type environment: |dict| or **None**
+ :param params: Additional process start parameters as |dict|, see
+ `Process Start Properties`_ for supported keys.
+ :type params: |dict|
+ :param done: Call back interface called when operation is completed.
+ :type done: |DoneStart|
"""
- Start a new process on remote machine.
- @param directory - initial value of working directory for the process.
- @param filePath - process image file.
- @param command_line - command line arguments for the process.
- Note: the service does NOT add image file name as
- first argument for the process. If a client wants
- first parameter to be the file name, it should
- add it itself.
- @param environment - map of environment variables for the process,
- if None then default set of environment variables
- will be used.
- @param params - additional process start parameters as map, see START_*
- for supported keys.
- @param done - call back interface called when operation is completed.
- @return pending command handle, can be used to cancel the command.
+ raise NotImplementedError("Abstract method")
+
+ def getCapabilities(self, done):
+ """Retrieve the capabilities for the service.
+
+ :param done: Callback interface called when operation is completed.
+
+ :returns: Pending command handle.
"""
raise NotImplementedError("Abstract method")
diff --git a/python/src/tcf/services/remote/ContextQueryProxy.py b/python/src/tcf/services/remote/ContextQueryProxy.py
index 6ea3e0cc0..a9a08dbaf 100644
--- a/python/src/tcf/services/remote/ContextQueryProxy.py
+++ b/python/src/tcf/services/remote/ContextQueryProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2012, 2013-2014 Wind River Systems, Inc. and others.
+# * Copyright (c) 2012-2014 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
diff --git a/python/src/tcf/services/remote/ProcessesV1Proxy.py b/python/src/tcf/services/remote/ProcessesV1Proxy.py
index 883b9d457..2eab77963 100644
--- a/python/src/tcf/services/remote/ProcessesV1Proxy.py
+++ b/python/src/tcf/services/remote/ProcessesV1Proxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011-2014 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
@@ -39,3 +39,25 @@ class ProcessesV1Proxy(ProcessesProxy.ProcessesProxy,
ctx = ProcessesProxy.ProcessContext(service, args[1])
done.doneStart(self.token, error, ctx)
return StartCommand().token
+
+ 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", (contextId,))
+
+ def done(self, error, args):
+ capabilityData = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ capabilityData = args[1]
+
+ done.doneGetCapabilities(self.token, error, capabilityData)
+
+ return GetCapabilitiesCommand().token
diff --git a/python/src/tcf/tests/ProcessStart.py b/python/src/tcf/tests/ProcessStart.py
index ca6d1b168..88f7d64a2 100644
--- a/python/src/tcf/tests/ProcessStart.py
+++ b/python/src/tcf/tests/ProcessStart.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2013-2014 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
@@ -24,14 +24,14 @@ import tcf.services.runcontrol as runcontrol # @UnresolvedImport
import tcf.services.streams as streams # @UnresolvedImport
-class TcfProtocolLogger (object) :
+class TcfProtocolLogger (object):
"""A class to override TCF protocol's default logger.
As we do not want TCF errors to be logged on the console, this logger
simply does nothing on TCF protocol log messages.
"""
- def log (self, msg, x) :
+ def log(self, msg, x):
"""Logs the given message.
:param msg: log entry text.
@@ -39,7 +39,7 @@ class TcfProtocolLogger (object) :
"""
pass
- def __del__ (self) :
+ def __del__(self):
"""Sometimes we get some protocol warnings. I would like to remove them
by flushing the log cache here.
"""
@@ -124,10 +124,10 @@ class StreamsListener(streams.StreamsListener):
if data:
print data,
if not eos:
- self._service.read (self._streamID, self._size, self)
+ self._service.read(self._streamID, self._size, self)
- self._service.read (streamID, 4096, DoneRead(self._service, streamID,
- 4096))
+ self._service.read(streamID, 4096, DoneRead(self._service, streamID,
+ 4096))
def disposed(self, streamType, streamID):
"""Called when a stream is disposed.
@@ -219,7 +219,7 @@ def getChildren(service, contextID=None):
protocol.log("Error from " + service.getName() + \
".getContext()", error)
else:
- val.setValue (ids)
+ val.setValue(ids)
with condition:
condition.notify()
@@ -241,7 +241,7 @@ def getChildren(service, contextID=None):
# Return the retrieved children IDs, or an empty tuple
- return (tuple (value.getValue() or []))
+ return (tuple(value.getValue() or []))
def getContext(service, contextID):
@@ -299,7 +299,7 @@ def getContext(service, contextID):
protocol.log("Error from " + service.getName() + \
".getContext()", error)
else:
- val.setValue (context)
+ val.setValue(context)
with condition:
condition.notify()
@@ -360,7 +360,7 @@ def resume(context):
# Resume context with RM_RESUME mode, 1 time. No resume properties.
- context.resume (runcontrol.RM_RESUME, 1, {}, DoneResume())
+ context.resume(runcontrol.RM_RESUME, 1, {}, DoneResume())
# create a condition to wait on
@@ -420,17 +420,17 @@ def start(connection, path, *args):
if error:
protocol.log("Error from Processes.start", error)
else:
- val.setValue (process)
+ val.setValue(process)
with condition:
condition.notify()
# depending on the service, the start method only does 'doAttach', or
# take a dictionnary of options
- if (proc.getName () == processes_v1.NAME) :
+ if (proc.getName() == processes_v1.NAME):
opts = {processes_v1.START_ATTACH: True,
processes_v1.START_USE_TERMINAL: True}
- else :
+ else:
opts = True
# start the process itself
@@ -505,7 +505,7 @@ def state(context):
if error:
protocol.log("Error from runcontrol.getState()", error)
else:
- val.setValue ((suspended, pc, reason, params))
+ val.setValue((suspended, pc, reason, params))
with condition:
condition.notify()
@@ -592,7 +592,7 @@ def subscribe(svc, streamType, listener):
# TCF initialisation
protocol.startEventQueue()
-protocol.setLogger (TcfProtocolLogger ())
+protocol.setLogger(TcfProtocolLogger())
atexit.register(protocol.getEventQueue().shutdown)
try:
@@ -605,7 +605,7 @@ except Exception as e:
streamsSvc = getService(c, streams.NAME)
if streamsSvc:
- subscribe (streamsSvc, 'ProcessesV1', StreamsListener(streamsSvc))
+ subscribe(streamsSvc, 'ProcessesV1', StreamsListener(streamsSvc))
p = start(c, '/bin/ls', '-l', '-a')
@@ -623,7 +623,7 @@ context = getContext(rcSvc, p.getID())
print 'Runcontrol context is a container:', context.isContainer()
while context and not context.hasState():
- children = getChildren (rcSvc, context.getID())
+ children = getChildren(rcSvc, context.getID())
for child in children:
context = getContext(rcSvc, child)
if context and context.hasState():
@@ -637,7 +637,7 @@ if context is None:
# (suspended, pc, reason, params)
ctxState = state(context)
-print 'Context state : ' + str (ctxState)
+print 'Context state : ' + str(ctxState)
while ctxState and ctxState[0]:
resume(context)
@@ -646,10 +646,10 @@ while ctxState and ctxState[0]:
try:
ctxState = state(context)
if ctxState:
- print 'Context state : ' + str (ctxState)
+ print 'Context state : ' + str(ctxState)
except:
pass
# Let the async calls the time to end ...
-time.sleep (2)
+time.sleep(2)

Back to the top