question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getting appdata TypeError: string indices must be integers

See original GitHub issue

I was trying to pull back data for my apps and I kept getting:

Traceback (most recent call last):
  File "./samsung-test.py", line 17, in <module>
    for app in remote.applications:
  File "/usr/lib/python2.7/site-packages/samsungctl-0.8.0b-py2.7.egg/samsungctl/remote_websocket.py", line 227, in applications
    if app_1['appId'] == app_2['appId']:
TypeError: string indices must be integers

So I updated the code to resolve that issue:

for app_1 in app_data[1]['data']:
            for app_2 in app_data[0]:
                if str(app_1['appId']) == str(app_2['appId']):
                    app_1.update(app_2)

        res = []
        for app in app_data[1]:
            res += [application.Application(self, **app)]

but now I am getting this error:

Traceback (most recent call last):
  File "./samsung-test.py", line 17, in <module>
    for app in remote.applications:
  File "/usr/lib/python2.7/site-packages/samsungctl-0.8.0b-py2.7.egg/samsungctl/remote_websocket.py", line 232, in applications
    res += [application.Application(self, **app)]
TypeError: type object argument after ** must be a mapping, not unicode

NOTE: The line number is wrong in my error message because I added so many print statements to troubleshoot this.

I will admit that I am a bit of a hack when it comes to code, so I am not sure what the last error means or how to correct it. Any advice?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:22 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
xxKeoxxcommented, Jan 10, 2019

I do not think what you gave for a PR is going to fix the issue.

reason why is I set up the containers that hold the application data as a list. and it is a list that get sent back from the TV. by placing the [‘data’] where you did is trying to access a list as a dictionary. I need to see the exact data that gets returned by the TV so we know what thee structure looks like exactly.

When I ran the script it pulled back and reported the information I expected to see. Here is the data before the change. In order for the loop to work I had to start the loop with data under the “data” key so it new where to get the “data”.

Here is what it returns:

    "data": [
        {
            "appId": "3201512006963", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201512006963/250x250.png", 
            "name": "Plex"
        }, 
        {
            "appId": "111012010001", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/111012010001/250x250.png", 
            "name": "VUDU"
        }, 
        {
            "appId": "111299001912", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/111299001912/250x250.png", 
            "name": "YouTube"
        }, 
        {
            "appId": "111199000417", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/111199000417/250x250.png", 
            "name": "HBO GO"
        }, 
        {
            "appId": "3201608010239", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201608010239/250x250.png", 
            "name": "TV Plus"
        }, 
        {
            "appId": "11101200001", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/11101200001/250x250.png", 
            "name": "Netflix"
        }, 
        {
            "appId": "3201606009872", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201606009872/250x250.png", 
            "name": "Emby"
        }, 
        {
            "appId": "3201601007625", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201601007625/250x250.png", 
            "name": "Hulu"
        }, 
        {
            "appId": "111399000031", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/111399000031/250x250.png", 
            "name": "FandangoNOW"
        }, 
        {
            "appId": "20162100005", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/20162100005/250x250.png", 
            "name": "e-Manual"
        }, 
        {
            "appId": "org.tizen.browser", 
            "app_type": 4, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/webbrowser/250x250.png", 
            "name": "Web Browser"
        }, 
        {
            "appId": "3201601007250", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201601007250/250x250.png", 
            "name": "Google Play Movies \uff06 TV"
        }, 
        {
            "appId": "11091000000", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/11091000000/250x250.png", 
            "name": "Facebook Watch"
        }, 
        {
            "appId": "3201512006785", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201512006785/250x250.png", 
            "name": "Amazon Video"
        }, 
        {
            "appId": "11101000410", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/11101000410/250x250.png", 
            "name": "Vimeo"
        }, 
        {
            "appId": "3201504002064", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201504002064/250x250.png", 
            "name": "GameFly Streaming"
        }, 
        {
            "appId": "3201606009840", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201606009840/250x250.png", 
            "name": "NBC"
        }, 
        {
            "appId": "3201611010963", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201611010963/250x250.png", 
            "name": "SHOWTIME"
        }, 
        {
            "appId": "3201608010450", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201608010450/250x250.png", 
            "name": "HGTV"
        }, 
        {
            "appId": "3201704012161", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201704012161/250x250.png", 
            "name": "CNNgo"
        }, 
        {
            "appId": "3201707014448", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201707014448/250x250.png", 
            "name": "Sling TV"
        }, 
        {
            "appId": "3201502001363", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201502001363/250x250.png", 
            "name": "iHeartRadio"
        }, 
        {
            "appId": "3201707014489", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201707014489/250x250.png", 
            "name": "YouTube TV"
        }, 
        {
            "appId": "3201708014637", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201708014637/250x250.png", 
            "name": "Freeform"
        }, 
        {
            "appId": "3201710014981", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201710014981/250x250.png", 
            "name": "CBS All Access"
        }, 
        {
            "appId": "3201711015155", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201711015155/250x250.png", 
            "name": "CBS News: Live Breaking News"
        }, 
        {
            "appId": "3201710014874", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201710014874/250x250.png", 
            "name": "Amazon Music"
        }, 
        {
            "appId": "3201608010313", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201608010313/250x250.png", 
            "name": "Food Network"
        }, 
        {
            "appId": "3201608010451", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201608010451/250x250.png", 
            "name": "Travel Channel"
        }, 
        {
            "appId": "3201506003227", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201506003227/250x250.png", 
            "name": "STARZ"
        }, 
        {
            "appId": "111199000333", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/111199000333/250x250.png", 
            "name": "UFC.TV"
        }, 
        {
            "appId": "3201608010191", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201608010191/250x250.png", 
            "name": "Deezer"
        }, 
        {
            "appId": "3201709014781", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201709014781/250x250.png", 
            "name": "Pantaya"
        }, 
        {
            "appId": "11091300004", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/11091300004/250x250.png", 
            "name": "Pandora"
        }, 
        {
            "appId": "3201702011851", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201702011851/250x250.png", 
            "name": "Steam Link"
        }, 
        {
            "appId": "121299000101", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/121299000101/250x250.png", 
            "name": "TuneIn"
        }, 
        {
            "appId": "3201801015541", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201801015541/250x250.png", 
            "name": "Discovery GO"
        }, 
        {
            "appId": "3201605009473", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201605009473/250x250.png", 
            "name": "NBC Sports"
        }, 
        {
            "appId": "3201608010240", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201608010240/250x250.png", 
            "name": "NFL SUNDAY TICKET"
        }, 
        {
            "appId": "3201806016508", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201806016508/250x250.png", 
            "name": "ABC"
        }, 
        {
            "appId": "3201806016390", 
            "app_type": 2, 
            "icon": "/opt/down/webappservice/apps_icon/FirstScreen/3201806016390/250x250.png", 
            "name": "DAZN"
        }
    ]
}
0reactions
kdschlossercommented, Jan 28, 2019

Oh man… Your killing me… I’m playin.

It cool I will leave it open. Tho I think a lot of the information in this issue are going to be irreverent. I had someone else test pulling of application data along with the running of an application and it checked out OK. I finally broke down and set up unittests to mimic the communications between TV and library… and i worked out most of the kinks that way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python typeerror: string indices must be integers Solution
String indices must be integers. This means that when you're accessing an iterable object like a string, you must do it using a...
Read more >
why am I getting a "TypeError: String indices Must be integer ...
I'm following along with a Udemy course for Python & Finance, unfortunately hit a wall whilst trying to call stock data from yahoo...
Read more >
Typeerror: string indices must be integers – How to Fix in Python
We get the "TypeError: string indices must be integers" error when we try to access a character using its string value rather the...
Read more >
Strange "TypeError: string indices must be integers" when ...
When you pass your procString variable, you are giving the parameters argument as a string which is incorrect. My guess is that when...
Read more >
TypeError: string indices must be integers · Issue #73 - GitHub
I only recently started working with this package, and am excited about the prospects for it. However all of a sudden I can't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found