parse openvpn status log

def parse_status_file(status_file,nas_addr):
    ''' parse openvpn status log
    '''
    session_users = {}
    flag1 = False
    flag2 = False
    with open(status_file) as stlines:
        for line in stlines:

            if line.startswith("Common Name"):
                flag1 = True
                continue

            if line.startswith("ROUTING TABLE"):
                flag1 = False
                continue

            if line.startswith("Virtual Address"):
                flag2 = True
                continue

            if line.startswith("GLOBAL STATS"):
                flag2 = False
                continue

            if flag1:
                try:
                    username,realaddr,inbytes,outbytes,_ = line.split(',')
                    realip,realport = realaddr.split(':')
                    session_id = md5(nas_addr + realip + realport).hexdigest()
                    session_users.setdefault(session_id, {}).update(dict(
                        session_id=session_id,
                        username=username,
                        realip=realip,
                        realport=realport,
                        inbytes=inbytes,
                        outbytes=outbytes
                    ))
                except:
                    traceback.print_exc()

            if flag2:
                try:
                    userip,username,realaddr,_ = line.split(',')
                    realip,realport = realaddr.split(':')
                    session_id = md5(nas_addr + realip + realport).hexdigest()
                    session_users.setdefault(session_id, {}).update(dict(
                        session_id=session_id,
                        username=username,
                        realip=realip,
                        realport=realport,
                        userip=userip,
                    ))
                except:
                    traceback.print_exc()

    return session_users