Skip to content

Commit

Permalink
optics
Browse files Browse the repository at this point in the history
  • Loading branch information
emphasize committed Dec 28, 2023
1 parent 713e29a commit c42faed
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions ovos_utils/log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,21 @@ def parse_file(self, source) -> Generator[Union[LogLine, Traceback], None, None]


def get_last_load_time(directories: Optional[List[str]] = None) -> Optional[datetime]:
# if nothing's found return the beginning of unix time
last_timestamp = datetime.fromtimestamp(0)
if directories is None:
directory = get_log_path("skills")
else:
directory = get_log_path("skills", directories)

# if nothing's found return the beginning of unix time
if directory is None:
return datetime.fromtimestamp(0)

with open(os.path.join(directory,"skills.log"), "r") as f:
for line in f.readlines()[::-1]:
logline = OVOSLogParser.parse(line)
if logline.timestamp:
last_timestamp = logline.timestamp
if logline.message == "Loading message bus configs":
return last_timestamp
if directory:
with open(os.path.join(directory,"skills.log"), "r") as f:
for line in f.readlines()[::-1]:
logline = OVOSLogParser.parse(line)
if logline.timestamp:
last_timestamp = logline.timestamp
if logline.message == "Loading message bus configs":
break
return last_timestamp


Expand Down

0 comments on commit c42faed

Please sign in to comment.