Merge branch 'add-trace-action-session-timestamp' into 'master'
Add append_timestamp option for trace action See merge request micro-ROS/ros_tracing/ros2_tracing!81
This commit is contained in:
commit
8092da4941
4 changed files with 21 additions and 4 deletions
|
@ -38,6 +38,7 @@ class Trace(Action):
|
|||
self,
|
||||
*,
|
||||
session_name: str,
|
||||
append_timestamp: bool = False,
|
||||
base_path: str = path.DEFAULT_BASE_PATH,
|
||||
events_ust: List[str] = names.DEFAULT_EVENTS_ROS,
|
||||
events_kernel: List[str] = names.DEFAULT_EVENTS_KERNEL,
|
||||
|
@ -47,11 +48,14 @@ class Trace(Action):
|
|||
Constructor.
|
||||
|
||||
:param session_name: the name of the tracing session
|
||||
:param append_timestamp: whether to append timestamp to the session name
|
||||
:param base_path: the path to the base directory in which to create the tracing session directory
|
||||
:param events_ust: the list of ROS UST events to enable
|
||||
:param events_kernel: the list of kernel events to enable
|
||||
"""
|
||||
super().__init__(**kwargs)
|
||||
if append_timestamp:
|
||||
session_name = path.append_timestamp(session_name)
|
||||
self.__session_name = session_name
|
||||
self.__base_path = base_path
|
||||
self.__events_ust = events_ust
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
from typing import List
|
||||
from typing import Tuple
|
||||
|
||||
|
@ -27,6 +26,7 @@ from launch_ros.actions import Node
|
|||
from tracetools_launch.action import Trace
|
||||
from tracetools_read import DictEvent
|
||||
from tracetools_read import get_event_name
|
||||
from tracetools_trace.tools.path import append_timestamp
|
||||
|
||||
|
||||
def run_and_trace(
|
||||
|
@ -48,13 +48,14 @@ def run_and_trace(
|
|||
:param node_names: the names of the nodes to execute
|
||||
:return: exit code, full generated path
|
||||
"""
|
||||
session_name = f'{session_name_prefix}-{time.strftime("%Y%m%d%H%M%S")}'
|
||||
session_name = append_timestamp(session_name_prefix)
|
||||
full_path = os.path.join(base_path, session_name)
|
||||
|
||||
launch_actions = []
|
||||
# Add trace action
|
||||
launch_actions.append(Trace(
|
||||
session_name=session_name,
|
||||
append_timestamp=False,
|
||||
base_path=base_path,
|
||||
events_ust=ros_events,
|
||||
events_kernel=kernel_events
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
"""Module containing parsing functions for tracing commands."""
|
||||
|
||||
import argparse
|
||||
import time
|
||||
|
||||
from . import names
|
||||
from . import path
|
||||
|
@ -42,7 +41,7 @@ def parse_args():
|
|||
def add_arguments(parser):
|
||||
parser.add_argument(
|
||||
'--session-name', '-s', dest='session_name',
|
||||
default=f'session-{time.strftime("%Y%m%d%H%M%S")}',
|
||||
default=path.append_timestamp('session'),
|
||||
help='the name of the tracing session (default: session-YYYYMMDDHHMMSS)')
|
||||
parser.add_argument(
|
||||
'--path', '-p', dest='path',
|
||||
|
|
|
@ -13,11 +13,24 @@
|
|||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
|
||||
DEFAULT_BASE_PATH = '~/.ros/tracing/'
|
||||
|
||||
|
||||
def append_timestamp(
|
||||
session_name_base: str,
|
||||
) -> str:
|
||||
"""
|
||||
Append timestamp to base session name.
|
||||
|
||||
:param session_name_base: the base name of the tracing session
|
||||
:return: the session name with timestamp
|
||||
"""
|
||||
return session_name_base + '-' + time.strftime('%Y%m%d%H%M%S')
|
||||
|
||||
|
||||
def get_full_session_path(
|
||||
session_name: str,
|
||||
base_path: str = DEFAULT_BASE_PATH
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue