Suddenly 'string indices must be integers' and app is broken?! #4

Closed
opened 2021-07-01 12:01:27 +02:00 by homer77 · 2 comments
Owner

What seemed to be running yesterday now stops working, and I actually don't get it ...

Traceback (most recent call last):
fritzab2matrix |   File "./fritzab2matrix.py", line 131, in <module>
fritzab2matrix |     fritzab2matrix()
fritzab2matrix |   File "./fritzab2matrix.py", line 77, in fritzab2matrix
fritzab2matrix |     msg_info = a['Date'] + " - " + a['Number']
fritzab2matrix | TypeError: string indices must be integers

Here's the code:

    l = get_message_list(message_list_url)
    print(l)                                                                    
    if l['Root'] == None or l['Root']['Message'] == None:
        return False
    else:
        message = l['Root']['Message']
        print(message)

    for a in message:

        # format the information regarding the message
        msg_info = a['Date'] + " - " + a['Number']
        ```
What seemed to be running yesterday now stops working, and I actually don't get it ... ``` Traceback (most recent call last): fritzab2matrix | File "./fritzab2matrix.py", line 131, in <module> fritzab2matrix | fritzab2matrix() fritzab2matrix | File "./fritzab2matrix.py", line 77, in fritzab2matrix fritzab2matrix | msg_info = a['Date'] + " - " + a['Number'] fritzab2matrix | TypeError: string indices must be integers ``` Here's the code: ``` l = get_message_list(message_list_url) print(l) if l['Root'] == None or l['Root']['Message'] == None: return False else: message = l['Root']['Message'] print(message) for a in message: # format the information regarding the message msg_info = a['Date'] + " - " + a['Number'] ```
homer77 added the
bug
label 2021-07-01 12:01:27 +02:00
homer77 self-assigned this 2021-07-01 12:01:27 +02:00
Author
Owner

On the other - identically - machine with the same docker setup fritzab2matrix is running.
From the dict that broke on the first machine

OrderedDict([('Index', '20'), ('Tam', '0'), ('Called', '****002'), ('Date', '01.07.21 19:03'), ('Duration', '0:01'), ('Inbook', '0'), ('Name', 'Some Caller'), ('New', '0'), ('Number', '*******714'), ('Path', '/download.lua?path=/data/tam/rec/rec.0.020')]), OrderedDict([('Index', '19'), ('Tam', '0'), ('Called', '****002'), ('Date', '01.07.21 18:59'), ('Duration', '0:01'), ('Inbook', '0'), ('Name', 'Some Caller'), ('New', '0'), ('Number', '******714'), ('Path', '/download.lua?path=/data/tam/rec/rec.0.019')])

The structure of the messages dict doesn't seem to differ 🤔

Here is the dict of the broken setup

OrderedDict([('Index', '0'), ('Tam', '0'), ('Called', '*******850'), ('Date', '01.07.21 08:55'), ('Duration', '0:01'), ('Inbook', '1'), ('Name', 'Me mobil'), ('New', '1'), ('Number', '*******714'), ('Path', '/download.lua?path=/var/media/ftp/Storage-01/FRITZ/voicebox/rec/rec.0.000')])

Is it a problem after I deleted all messages on the first machine? So it's not a list of dicts?

On the other - identically - machine with the same docker setup fritzab2matrix is running. From the dict that broke on the first machine ``` OrderedDict([('Index', '20'), ('Tam', '0'), ('Called', '****002'), ('Date', '01.07.21 19:03'), ('Duration', '0:01'), ('Inbook', '0'), ('Name', 'Some Caller'), ('New', '0'), ('Number', '*******714'), ('Path', '/download.lua?path=/data/tam/rec/rec.0.020')]), OrderedDict([('Index', '19'), ('Tam', '0'), ('Called', '****002'), ('Date', '01.07.21 18:59'), ('Duration', '0:01'), ('Inbook', '0'), ('Name', 'Some Caller'), ('New', '0'), ('Number', '******714'), ('Path', '/download.lua?path=/data/tam/rec/rec.0.019')]) ``` The structure of the messages dict doesn't seem to differ 🤔 Here is the dict of the broken setup ``` OrderedDict([('Index', '0'), ('Tam', '0'), ('Called', '*******850'), ('Date', '01.07.21 08:55'), ('Duration', '0:01'), ('Inbook', '1'), ('Name', 'Me mobil'), ('New', '1'), ('Number', '*******714'), ('Path', '/download.lua?path=/var/media/ftp/Storage-01/FRITZ/voicebox/rec/rec.0.000')]) ``` Is it a problem after I deleted all messages on the first machine? So it's not a list of dicts?
Author
Owner

Is it a problem after I deleted all messages on the first machine? So it's not a list of dicts?

Yes it is, after producing a second message the docker image worked also fine. (Except that the files couldn't be uploaded - whyever ...) So it's an issue with the xml2dict method i.e.

  • if there's only 1 message it throws a single ordered dictionary
  • if there are multiple messages it throws a list of ordered dictionaries

I have to fix this by adding the only message to a list.

> Is it a problem after I deleted all messages on the first machine? So it's not a list of dicts? Yes it is, after producing a second message the docker image worked also fine. (Except that the files couldn't be uploaded - whyever ...) So it's an issue with the xml2dict method i.e. * if there's only 1 message it throws a single ordered dictionary * if there are multiple messages it throws a list of ordered dictionaries I have to fix this by adding the only message to a list.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: homer77/FritzAB2Matrix#4
No description provided.