nmcontrol icon indicating copy to clipboard operation
nmcontrol copied to clipboard

import.mode=all "TypeError: string indices must be integers, not str"

Open JeremyRand opened this issue 11 years ago • 4 comments

Sometimes when I run nmcontrol with "import.mode=all" in plugin-data.conf, I get the following output while it's parsing the name data (might take a couple minutes to show up):

Cmdline args: ['start'] Cmdline options: {'http.host': None, 'dns.host': None, 'data.update.mode': None, 'data.import.file': None, 'data.export.freq': None, 'data.import.from': None, 'data.update.freq': None, 'data.update.from': None, 'rpc.port': None, 'data.export.mode': None, 'dns.resolver': None, 'data.import.namecoin': None, 'data.export.to': None, 'dns.disable_standard_lookups': None, 'data.import.mode': None, 'dns.port': None, 'daemon': '0', 'data.update.file': None, 'http.port': None, 'dns.disable_ns_lookups': None, 'rpc.host': None, 'data.update.namecoin': None, 'debug': '1', 'data.export.file': None} Plugin domain parent starting Plugin data parent starting Plugin guiHttp parent starting Plugin Data : loading... BackendDataNamecoin: [Plugin guiHttp parent start' name_filter'Plugin guiHttpConfig parent starting , ''] Plugins started : domain, guiHttp, guiHttpConfig, dns Plugin dns parent starting Plugin main parent starting Plugin rpc parent starting Plugin dns parent start Plugin http parent starting Plugin guiHttpConfig parent start Plugin dns parent starting Plugin domain parent start

Service dns started Exception in thread data: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/home/jeremy/Downloads/NMControl/FreshGit/nmcontrol/lib/plugin.py", line 43, in run self.start2() File "/home/jeremy/Downloads/NMControl/FreshGit/nmcontrol/lib/plugin.py", line 56, in start2 return self.pStart() File "/home/jeremy/Downloads/NMControl/FreshGit/nmcontrol/plugin/pluginData.py", line 74, in pStart error, data = backend.getAllNames() File "/home/jeremy/Downloads/NMControl/FreshGit/nmcontrol/lib/backendDataNamecoin.py", line 37, in getAllNames datas[name['name']] = name TypeError: string indices must be integers, not str

It doesn't happen consistently, but it happens often enough that it's a major problem. When this occurs, all subsequent name lookups appear to fail.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

JeremyRand avatar Jan 31 '14 21:01 JeremyRand

Forgot to say, this is on Linux.

JeremyRand avatar Jan 31 '14 21:01 JeremyRand

On my machine, this error occurred 2 out of 10 times that I ran nmcontrol. If the data loading was successful (meaning the error didn't occur), you will instead get the message "102509 names loaded"; it can take a while for either the error or the success message to occur.

JeremyRand avatar Jan 31 '14 21:01 JeremyRand

Thank for the report. I also noticed this bug several times and changed config to this to skip the bug :

import.mode = none update.mode = ondemand

If it is due to some sort of timeout, I'll need to load names by chunks (name_filter allows that).

khalahan avatar Feb 01 '14 15:02 khalahan

I experienced this issue as well and looked into it on my machine, it seems like the problem is that the first (?) chunk returned by s.recv returns a smaller size than the actual specified buffer, for some reason - although subsequent chunks are at full length.

I've worked around it by changing the line to if len(tmp) == 0: break instead, but a proper fix would probably be to parse the Content-Length header and/or use an external networking/rpc library to take care of this.

Ps. Why are you using newlines everywhere instead of \r\n like HTTP specifies? Also, is checking the length even valid after .decode('iso-8859-1')?

haasn avatar Apr 16 '14 07:04 haasn