Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update odl.py to handle empty log files #9

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

stephenkreusch
Copy link
Contributor

This PR checks the globbed log file paths and skips log file processing if the file size is 0 bytes, to avoid an error like:

Traceback (most recent call last):
  File "/mnt/c/temp/odl.py", line 500, in <module>
    main()
  File "/mnt/c/temp/odl.py", line 484, in main
    odl_rows = process_odl(path, map, args.all_data)
  File "/mnt/c/temp/odl.py", line 304, in process_odl
    odl_header = Odl_header.parse(file_header)
  File "/home/stephen/miniconda3/lib/python3.10/site-packages/construct/core.py", line 404, in parse
    return self.parse_stream(io.BytesIO(data), **contextkw)
  File "/home/stephen/miniconda3/lib/python3.10/site-packages/construct/core.py", line 416, in parse_stream
    return self._parsereport(stream, context, "(parsing)")
  File "/home/stephen/miniconda3/lib/python3.10/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
  File "/home/stephen/miniconda3/lib/python3.10/site-packages/construct/core.py", line 2236, in _parse
    subobj = sc._parsereport(stream, context, path)
  File "/home/stephen/miniconda3/lib/python3.10/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
  File "/home/stephen/miniconda3/lib/python3.10/site-packages/construct/core.py", line 2770, in _parse
    return self.subcon._parsereport(stream, context, path)
  File "/home/stephen/miniconda3/lib/python3.10/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
  File "/home/stephen/miniconda3/lib/python3.10/site-packages/construct/core.py", line 964, in _parse
    return stream_read(stream, length, path)
  File "/home/stephen/miniconda3/lib/python3.10/site-packages/construct/core.py", line 178, in stream_read
    raise StreamError("stream read less than specified amount, expected %d, found %d" % (length, len(data)), path=path)
construct.core.StreamError: Error in path (parsing) -> signature
stream read less than specified amount, expected 8, found 0

Handle empty log files to prevent error.
@ydkhatri
Copy link
Owner

ydkhatri commented Jan 7, 2024 via email

@ydkhatri ydkhatri merged commit 0074fe9 into ydkhatri:main Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants