flask experiment
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 

41 lines
861 B

class openvpnstatus(object):
"""read the openvpn-status.log file"""
def __init__(self):
self.update()
def update(self):
"""read file"""
import os
self.connections = []
self.routes = []
f = open("openvpn-status.log", "r")
state = 0
for line in f:
if "Updated" in line:
state = 1
continue
elif "ROUTING" in line:
state = 2
continue
elif "GLOBAL" in line:
state = 0
break
if state == 1:
fields = line.split(",")
self.connections.append(fields)
elif state == 2:
fields = line.split(",")
self.routes.append(fields)
f.close()
#end of file