Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions python/fusion_engine_client/analysis/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from .data_loader import DataLoader, TimeRange
from ..utils import trace as logging
from ..utils.argument_parser import ArgumentParser, ExtendedBooleanAction, TriStateBooleanAction, CSVAction
from ..utils.log import locate_log, DEFAULT_LOG_BASE_DIR
from ..utils.log import define_cli_arguments as define_log_search_arguments, locate_log
from ..utils.numpy_utils import find_first
from ..utils.trace import HighlightFormatter

Expand Down Expand Up @@ -2929,21 +2929,7 @@ def main(args=None):
"unless an 'abs' type is specified or --absolute-time is set.")

log_group = parser.add_argument_group('Input File/Log Control')
log_group.add_argument(
'--ignore-index', action=ExtendedBooleanAction,
help="If set, do not load the .p1i index file corresponding with the .p1log data file. If specified and a "
".p1i file does not exist, do not generate one. Otherwise, a .p1i file will be created automatically to "
"improve data read speed in the future.")
log_group.add_argument(
'--log-base-dir', metavar='DIR', default=DEFAULT_LOG_BASE_DIR,
help="The base directory containing FusionEngine logs to be searched if a log pattern is specified.")
log_group.add_argument(
'log',
help="The log to be read. May be one of:\n"
"- The path to a .p1log file or a file containing FusionEngine messages and other content\n"
"- The path to a FusionEngine log directory\n"
"- A pattern matching a FusionEngine log directory under the specified base directory "
"(see find_fusion_engine_log() and --log-base-dir)")
define_log_search_arguments(log_group)

output_group = parser.add_argument_group('Output Control')
output_group.add_argument(
Expand Down Expand Up @@ -2982,8 +2968,8 @@ def main(args=None):
time_range = None

# Locate the input file and set the output directory.
input_path, output_dir, log_id = locate_log(input_path=options.log, log_base_dir=options.log_base_dir,
return_output_dir=True, return_log_id=True)
input_path, log_dir, log_id = locate_log(input_path=options.log, log_base_dir=options.log_base_dir,
return_output_dir=True, return_log_id=True)
if input_path is None:
# locate_log() will log an error.
sys.exit(1)
Expand All @@ -2994,8 +2980,7 @@ def main(args=None):
_logger.info('Loading %s (log ID: %s).' % (input_path, log_id))

if options.output is None:
if log_id is not None:
output_dir = os.path.join(output_dir, 'plot_fusion_engine')
output_dir = os.path.join(log_dir, 'plot_fusion_engine')
else:
output_dir = options.output

Expand Down
20 changes: 3 additions & 17 deletions python/fusion_engine_client/applications/p1_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ..parsers import MixedLogReader
from ..utils import trace as logging
from ..utils.argument_parser import ArgumentParser, ExtendedBooleanAction, CSVAction
from ..utils.log import locate_log, DEFAULT_LOG_BASE_DIR
from ..utils.log import define_cli_arguments as define_log_search_arguments, locate_log
from ..utils.print_utils import DeviceSummary, add_print_format_argument, print_message, print_summary_table
from ..utils.time_range import TimeRange
from ..utils.trace import HighlightFormatter, BrokenPipeStreamHandler
Expand Down Expand Up @@ -65,25 +65,11 @@ def main():
parser.add_argument('-v', '--verbose', action='count', default=0,
help="Print verbose/trace debugging messages.")

log_parser = parser.add_argument_group('Log Control')
log_parser.add_argument(
'--ignore-index', action='store_true',
help="If set, do not load the .p1i index file corresponding with the .p1log data file. If specified and a .p1i "
"file does not exist, do not generate one. Otherwise, a .p1i file will be created automatically to "
"improve data read speed in the future.")
log_parser.add_argument(
'--log-base-dir', metavar='DIR', default=DEFAULT_LOG_BASE_DIR,
help="The base directory containing FusionEngine logs to be searched if a log pattern is specified.")
log_parser = parser.add_argument_group('Input File/Log Control')
define_log_search_arguments(log_parser)
log_parser.add_argument(
'--progress', action='store_true',
help="Print file read progress to the console periodically.")
log_parser.add_argument(
'log',
help="The log to be read. May be one of:\n"
"- The path to a .p1log file or a file containing FusionEngine messages and other content\n"
"- The path to a FusionEngine log directory\n"
"- A pattern matching a FusionEngine log directory under the specified base directory "
"(see find_fusion_engine_log() and --log-base-dir)")

options = parser.parse_args()

Expand Down
19 changes: 19 additions & 0 deletions python/fusion_engine_client/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ..messages import MessageType
from ..parsers.file_index import FileIndexBuilder, FileIndex
from ..parsers.mixed_log_reader import MixedLogReader
from ..utils.argument_parser import ExtendedBooleanAction

_logger = logging.getLogger('point_one.utils.log')

Expand Down Expand Up @@ -44,6 +45,24 @@
DEFAULT_LOG_BASE_DIR = os.path.expanduser("~/point_one/logs")


def define_cli_arguments(parser_group):
parser_group.add_argument(
'--ignore-index', action=ExtendedBooleanAction,
help="If set, do not load the .p1i index file corresponding with the .p1log data file. If specified and a "
".p1i file does not exist, do not generate one. Otherwise, a .p1i file will be created automatically to "
"improve data read speed in the future.")
parser_group.add_argument(
'--log-base-dir', metavar='DIR', default=DEFAULT_LOG_BASE_DIR,
help="The base directory containing FusionEngine logs to be searched if a log pattern is specified.")
parser_group.add_argument(
'log',
help="The log to be read. May be one of:\n"
"- The path to a .p1log file or a file containing FusionEngine messages and other content\n"
"- The path to a FusionEngine log directory\n"
"- A pattern matching a FusionEngine log directory under the specified base directory "
"(see find_fusion_engine_log() and --log-base-dir)")


def find_log_by_pattern(pattern, log_base_dir=DEFAULT_LOG_BASE_DIR, allow_multiple=False, skip_empty_files=True,
log_test_filenames=(MANIFEST_FILE_NAME,), return_test_file=False):
"""!
Expand Down
Loading