这是indexloc提供的服务,不要输入任何密码
Skip to content

AttributeError: 'NoneType' object has no attribute 'upper' when parsing using tag_block #239

@andyvan-trabus

Description

@andyvan-trabus

Parsing using the tag_block queue can result in an exception:

python test_239.py
Traceback (most recent call last):
File "test_239.py", line 9, in
queue.put(line, line_no)
File "/home/avanpelt/git/TMP/FORK/libais-fork/ais/tag_block.py", line 112, in put
match = Parse(line)
File "/home/avanpelt/git/TMP/FORK/libais-fork/ais/tag_block.py", line 86, in Parse
expected = result['tag_checksum'].upper()
AttributeError: 'NoneType' object has no attribute 'upper'

import ais
from ais import tag_block

MESSAGES = ['\\g:1-2-94\\g:2-2-9470,n:11222*1D\\$SAVSI,D13MN-PS-MTEBS1,5,141030.377988,1139,-49,66*58']

queue = tag_block.TagQueue()

for line_no, line in enumerate(MESSAGES):
    queue.put(line, line_no)

while not queue.empty():
    tag_msg = queue.get()
    if "decoded" not in tag_msg:
        print("Message NOT decoded using tag_block queue")
        payload = tag_msg["lines"][0]
        print("payload = '{}'".format(payload))

        body = payload.split(',')[-2]
        pad = int(payload.split('*')[-2][-1])
        print("Calling ais.decode('{}', {})".format(body, pad))
        msg = ais.decode(body, pad)
        print(msg)

    else:
        print("Message decoded using tag_block queue")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions