samsungctl: getting appdata TypeError: string indices must be integers
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?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 22 (15 by maintainers)
Commits related to this issue
- Fix for issue #25 Fixes TypeError: string indices must be integers on line 212 error — committed to xxKeoxx/samsungctl by xxKeoxx 5 years ago
- Merge pull request #27 from xxKeoxx/patch-1 Fix for issue #25 — committed to kdschlosser/samsungctl by kdschlosser 5 years ago
- Revert "Fix for issue #25" — committed to kdschlosser/samsungctl by kdschlosser 5 years ago
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: