Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andyvan-trabus opened this issue Sep 28, 2021 · 0 comments

Comments

@andyvan-trabus
Copy link
Contributor

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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant