Skip to content

ovos-logs TypeError in log_parser.py ~372 #261

Description

@mcnamamj

Installed a fresh install last night using ovos-installer on a Raspberry Pi 4 (Mark II).

Using ovos-logs slice, I would get this error:

  File "/home/matt/.venvs/ovos/lib/python3.11/site-packages/ovos_utils/log_parser.py", line 372, in slice
    if start <= log.timestamp < end:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<=' not supported between instances of 'datetime.datetime' and 'str'

if start <= log.timestamp < end:

So it seemed like log.timestamp wasn't a datetime.datetime.

I added debug info to identify problematic line(s):

        for log in OVOSLogParser.parse_file(logfile):
            if log.timestamp == "":
                console.print(f"\n\nOut:{log}\n\n")
                continue
            if start <= log.timestamp < end:

When I ran ovos-logs slice next, before the logs showed I did find the debug line ran for 1 log entry:

Out:2024-07-17 21:59:57.530 - common_query.openvoiceos - INFO - First run of common_query.openvoiceos

NOTE: The prefix OUT: comes from my console.print.

So it just seems there's something wrong about this one line that ovos-logs couldn't handle.

That patch fixed it for me, but I'm:

  1. Not sure what's wrong with this line
  2. Unfamiliar with best practices on how to address this

I'm happy to make a PR if I get some feedback on how to address it.

Thanks y'all!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions