Fix sugar-install-bundle - Python 2

On Python 2 is seen
ConfigParser instance has no attribute 'read_string'

Regression introduced by 2018c930ad

Fixes https://github.com/sugarlabs/sugar-toolkit-gtk3/issues/438

Signed-off-by: James Cameron <quozl@laptop.org>
This commit is contained in:
Bas Hulsken 2020-01-06 11:21:39 +11:00 committed by James Cameron
parent 5b9f36db06
commit 39b12bbf7f

View File

@ -21,6 +21,7 @@ UNSTABLE.
""" """
from six.moves.configparser import ConfigParser, ParsingError from six.moves.configparser import ConfigParser, ParsingError
import six
from locale import normalize from locale import normalize
import os import os
import shutil import shutil
@ -129,6 +130,9 @@ class ActivityBundle(Bundle):
def _parse_info(self, info_file): def _parse_info(self, info_file):
cp = ConfigParser() cp = ConfigParser()
if six.PY2:
cp.readfp(info_file)
else:
cp.read_string(info_file.read().decode()) cp.read_string(info_file.read().decode())
section = 'Activity' section = 'Activity'
@ -251,6 +255,9 @@ class ActivityBundle(Bundle):
def _parse_linfo(self, linfo_file): def _parse_linfo(self, linfo_file):
cp = ConfigParser() cp = ConfigParser()
try: try:
if six.PY2:
cp.readfp(linfo_file)
else:
cp.read_string(linfo_file.read().decode()) cp.read_string(linfo_file.read().decode())
except ParsingError as e: except ParsingError as e:
logging.exception('Exception reading linfo file: %s', e) logging.exception('Exception reading linfo file: %s', e)