6330: Can't download ans install addons

svn: r21131
This commit is contained in:
Benny Malengier 2013-01-15 10:59:13 +00:00
parent 01dbd41081
commit 7672f64221
2 changed files with 9 additions and 3 deletions

View File

@ -35,7 +35,7 @@ import os
if sys.version_info[0] < 3:
from StringIO import StringIO
else:
from io import StringIO
from io import StringIO, BytesIO
#-------------------------------------------------------------------------
#
@ -219,7 +219,11 @@ def load_addon_file(path, callback=None):
callback(_("Unable to open '%s'") % path)
return
try:
buffer = StringIO(fp.read())
content = fp.read()
if sys.version_info[0] < 3:
buffer = StringIO(content)
else:
buffer = BytesIO(content)
except:
if callback:
callback(_("Error in reading '%s'") % path)

View File

@ -397,13 +397,15 @@ class ViewManager(CLIManager):
lines = list(fp.readlines())
count = 0
for line in lines:
if sys.version_info[0] >= 3:
line = line.decode('utf-8').replace(": u'", ": '")
try:
plugin_dict = safe_eval(line)
if type(plugin_dict) != type({}):
raise TypeError("Line with addon metadata is not "
"a dictionary")
except:
LOG.debug("Skipped a line in the addon listing: " +
LOG.warning("Skipped a line in the addon listing: " +
str(line))
continue
id = plugin_dict["i"]