-
Notifications
You must be signed in to change notification settings - Fork 36
Description
In my version of openvpn (xxx), the status log format changes in the timestamp field.
Wed Jul 20 16:43:45 2022 -> 2022-07-20 16:43:45
This raises exceptions :
openvpn_status.parser.ParsingError: expected valid format: time data '2022-07-20 16:43:45' does not match format '%a %b %d %H:%M:%S %Y'
To cope with this change, make the following changes in the file util.py
rename DATETIME_FORMAT_OPENVPN to DATETIME_FORMAT_OPENVPN_F1 (= u'%a %b %d %H:%M:%S %Y')
Add DATETIME_FORMAT_OPENVPN_F2 = u'%Y-%m-%d %H:%M:%S'
Change parse_time function :
def parse_time(time):
"""Parses date and time from input string in OpenVPN logging format."""
if isinstance(time, datetime.datetime):
return time
try:
res=datetime.datetime.strptime(time, DATETIME_FORMAT_OPENVPN_F1)
return res
except Exception as e:
pass
return datetime.datetime.strptime(time, DATETIME_FORMAT_OPENVPN_F2)
May be more simple solutions, but this one works 👍
Regards