def _execute(self, command, options, parameters):
"""
Launches the given command after SCA-specific processing has taken
place in 'execute'. Override or extend this method in subclasses to
have more control over the launching of components.
Returns the pid of the new process.
"""
args = [command]
# SR:446, SR:447
for param in parameters:
if param.value.value() != None:
args.append(str(param.id))
# SR:453 indicates that an InvalidParameters exception should be
# raised if the input parameter is not of a string type; however,
# version 2.2.2 of the SCA spec is less strict in its wording. For
# our part, as long as the value can be stringized, it is accepted,
# to allow component developers to use more specific types.
try:
args.append(str(param.value.value()))
except:
raise CF.ExecutableDevice.InvalidParameters([param])
self._log.debug("Popen %s %s", command, args)
# SR:445
try:
sp = ossie.utils.Popen(args, executable=command, cwd=os.getcwd(), close_fds=True, stdin=self._devnull, preexec_fn=os.setpgrp)
except OSError, e:
# SR:455
# CF error codes do not map directly to errno codes, so at present
# we omit the enumerated value.
self._log.error("subprocess.Popen: %s", e.strerror)
raise CF.ExecutableDevice.ExecuteFail(CF.CF_NOTSET, e.strerror)
pid = sp.pid
self._applications[pid] = sp
# SR:449
self._log.debug("execute() --> %s", pid)
self._log.debug("APPLICATIONS %s", self._applications)
return pid
评论列表
文章目录