From 0faa2a4451d64571f81874bc9cd27a256a436564 Mon Sep 17 00:00:00 2001 From: Chris Veilleux Date: Thu, 29 Aug 2019 19:24:01 -0500 Subject: [PATCH] Applied a code review change to make the datetime representation on the output file to suite different locales --- scripts/log_merger.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/log_merger.py b/scripts/log_merger.py index 8287a734dd..828cd5bc0a 100644 --- a/scripts/log_merger.py +++ b/scripts/log_merger.py @@ -1,11 +1,14 @@ from argparse import ArgumentParser from datetime import date, datetime, time +from locale import localeconv from pathlib import Path BOOT_START_MESSAGE = 'Starting message bus service...' BOOT_END_MESSAGE = 'Skills all loaded!' NOT_FOUND = -1 +TIME_FORMAT = '%Y-%m-%d %H:%M:%S{}%f'.format(localeconv()['decimal_point']) + class LogFileReader: log_dir = Path('/var/log/mycroft') @@ -64,10 +67,7 @@ class LogFileReader: def _parse_log_msg_ts(self, log_msg_ts): try: - self.log_msg_ts = datetime.strptime( - log_msg_ts, - '%Y-%m-%d %H:%M:%S,%f' - ) + self.log_msg_ts = datetime.strptime(log_msg_ts, TIME_FORMAT) except ValueError: print( 'Found log message with bad time section: ' + self.log_file_rec