Skip to content

Commit

Permalink
Fixed minor bugs to verify unit tests
Browse files Browse the repository at this point in the history
Distro A; OPSEC #4584

Signed-off-by: Roger Strain <[email protected]>
  • Loading branch information
Roger Strain committed Nov 19, 2020
1 parent 8b9f068 commit 7672671
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 672 deletions.
42 changes: 18 additions & 24 deletions launch/launch/actions/execute_local.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
# Copyright 2018 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Module for the ExecuteLocal action."""

import asyncio
import io
import os
import platform
import shlex
import signal
import threading
import traceback
from typing import Any # noqa: F401
from typing import Callable
from typing import cast
from typing import Dict
from typing import Iterable
from typing import List
from typing import Optional
from typing import Text
Expand Down Expand Up @@ -47,9 +59,6 @@
from ..events.process import ProcessStdout
from ..events.process import ShutdownProcess
from ..events.process import SignalProcess
from ..frontend import Entity
from ..frontend import expose_action
from ..frontend import Parser
from ..launch_context import LaunchContext
from ..launch_description import LaunchDescription
from ..launch_description_entity import LaunchDescriptionEntity
Expand All @@ -58,7 +67,6 @@
from ..substitution import Substitution # noqa: F401
from ..substitutions import LaunchConfiguration
from ..substitutions import PythonExpression
from ..substitutions import TextSubstitution
from ..utilities import create_future
from ..utilities import is_a_subclass
from ..utilities import normalize_to_list_of_substitutions
Expand All @@ -69,7 +77,7 @@


class ExecuteLocal(Action):
"""Action that begins executing a process on the local system and sets up event handlers for the process."""
"""Action that begins executing a process on the local system and sets up event handlers."""

def __init__(
self,
Expand All @@ -81,7 +89,6 @@ def __init__(
sigkill_timeout: SomeSubstitutionsType = LaunchConfiguration(
'sigkill_timeout', default=5),
emulate_tty: bool = False,
prefix: Optional[SomeSubstitutionsType] = None,
output: Text = 'log',
output_format: Text = '[{this.name}] {line}',
log_cmd: bool = False,
Expand Down Expand Up @@ -157,9 +164,6 @@ def __init__(
:py:func:`evaluate_condition_expression`.
Throws :py:exception:`InvalidConditionExpressionError` if the
'emulate_tty' configuration does not represent a boolean.
:param: prefix a set of commands/arguments to preceed the cmd, used for
things like gdb/valgrind and defaults to the LaunchConfiguration
called 'launch-prefix'
:param: output configuration for process output logging. Defaults to 'log'
i.e. log both stdout and stderr to launch main log file and stderr to
the screen.
Expand All @@ -183,9 +187,6 @@ def __init__(
self.__sigterm_timeout = normalize_to_list_of_substitutions(sigterm_timeout)
self.__sigkill_timeout = normalize_to_list_of_substitutions(sigkill_timeout)
self.__emulate_tty = emulate_tty
self.__prefix = normalize_to_list_of_substitutions(
LaunchConfiguration('launch-prefix', default='') if prefix is None else prefix
)
self.__output = os.environ.get('OVERRIDE_LAUNCH_PROCESS_OUTPUT', output)
self.__output_format = output_format

Expand Down Expand Up @@ -216,11 +217,6 @@ def shell(self):
"""Getter for shell."""
return self.__shell

@property
def prefix(self):
"""Getter for prefix."""
return self.__prefix

@property
def output(self):
"""Getter for output."""
Expand Down Expand Up @@ -591,10 +587,9 @@ async def __execute_process(self, context: LaunchContext) -> None:
self.__cleanup()

def prepare(self, context: LaunchContext):
"""
Prepares the action for execution.
"""
"""Prepare the action for execution."""
self.__process_description.apply_context(context)
self.__expand_substitutions(context)

def execute(self, context: LaunchContext) -> Optional[List[LaunchDescriptionEntity]]:
"""
Expand All @@ -607,7 +602,7 @@ def execute(self, context: LaunchContext) -> Optional[List[LaunchDescriptionEnti
- configures logging for the IO process event
- create a task for the coroutine that monitors the process
"""
self.prepare(context)
self.prepare(context)
name = self.__process_description.final_name

if self.__executed:
Expand Down Expand Up @@ -653,7 +648,6 @@ def execute(self, context: LaunchContext) -> Optional[List[LaunchDescriptionEnti
try:
self.__completed_future = create_future(context.asyncio_loop)
self.__shutdown_future = create_future(context.asyncio_loop)
self.__expand_substitutions(context)
self.__logger = launch.logging.get_logger(name)
self.__stdout_logger, self.__stderr_logger = \
launch.logging.get_output_loggers(name, self.__output)
Expand Down
Loading

0 comments on commit 7672671

Please sign in to comment.