tonyseek / openvpn-status

Parse OpenVPN status logs in Python
https://openvpn-status.readthedocs.io
MIT License
83 stars 31 forks source link

Expected 'OpenVPN CLIENT LIST' #15

Open nazububu opened 4 years ago

nazububu commented 4 years ago

Hello!

Package version: 0.2.1 Python version: 3.7.5 OS: Ubuntu 19.04

The fact is that if the OpenVPN status file is empty (for some reason, OpenVPN was able to create it, but an error occurred and there is no content inside) - an exception appears:

openvpn_status.parser.ParsingError: expected 'OpenVPN CLIENT LIST' but got end of input

Traceback:

Traceback (most recent call last):
  File "/srv/openvpn-status/venv/lib/python3.7/site-packages/openvpn_status/parser.py", line 49, in expect_line
    line = next(self)
  File "/srv/openvpn-status/venv/lib/python3.7/site-packages/openvpn_status/parser.py", line 30, in __next__
    line = next(self.lines).strip()
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "parser.py", line 10, in <module>
    parser = openvpn_status.parse_status(file.read())
  File "/srv/openvpn-status/venv/lib/python3.7/site-packages/openvpn_status/shortcuts.py", line 18, in parse_status
    return parser.parse()
  File "/srv/openvpn-status/venv/lib/python3.7/site-packages/openvpn_status/parser.py", line 84, in parse
    return self._parse()
  File "/srv/openvpn-status/venv/lib/python3.7/site-packages/openvpn_status/parser.py", line 93, in _parse
    self.expect_line(Status.client_list.label)
  File "/srv/openvpn-status/venv/lib/python3.7/site-packages/openvpn_status/parser.py", line 51, in expect_line
    raise ParsingError('expected %r but got end of input' % content)
openvpn_status.parser.ParsingError: expected 'OpenVPN CLIENT LIST' but got end of input

If you need any information about this, I will be glad to share :)