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 7860fa5221
commit a2acb593ec
2 changed files with 9 additions and 3 deletions

View File

@ -35,7 +35,7 @@ import os
if sys.version_info[0] < 3: if sys.version_info[0] < 3:
from StringIO import StringIO from StringIO import StringIO
else: 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) callback(_("Unable to open '%s'") % path)
return return
try: try:
buffer = StringIO(fp.read()) content = fp.read()
if sys.version_info[0] < 3:
buffer = StringIO(content)
else:
buffer = BytesIO(content)
except: except:
if callback: if callback:
callback(_("Error in reading '%s'") % path) callback(_("Error in reading '%s'") % path)

View File

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