From: biao716.wang Date: Mon, 14 Nov 2022 07:34:15 +0000 (+0900) Subject: fix preview test error with python3.x X-Git-Tag: accepted/tools/devbase/tools/20250527.103741~18^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23d3598c2032cb4808d378bc8e5a7e083908289d;p=tools%2Fgbs.git fix preview test error with python3.x Change-Id: Id0525f0029a06625ea738bff3f40c0ebcc1c5393 Signed-off-by: biao716.wang --- diff --git a/gitbuildsys/conf.py b/gitbuildsys/conf.py index 71d478b..333c595 100644 --- a/gitbuildsys/conf.py +++ b/gitbuildsys/conf.py @@ -377,23 +377,32 @@ url = http://download.tizen.org/releases/daily/trunk/ivi/latest/ def _get(self, opt, section='general'): 'get value from multi-levels of config file' + sect_found = True + global gerr for cfgparser in self._cfgparsers: try: return cfgparser.get(section, opt) except Error as err: - raise errors.ConfigError(err) + sect_found = False + gerr = err + pass + + if not sect_found: + raise errors.ConfigError(gerr) def options(self, section='general'): 'merge and return options of certain section from multi-levels' sect_found = False - global gerr options = set() for cfgparser in self._cfgparsers: try: options.update(cfgparser.options(section)) sect_found = True except Error as err: - raise errors.ConfigError(err) + pass + + if not sect_found: + raise errors.ConfigError(err) return options diff --git a/gitbuildsys/utils.py b/gitbuildsys/utils.py index becd0fd..1039c22 100644 --- a/gitbuildsys/utils.py +++ b/gitbuildsys/utils.py @@ -280,7 +280,7 @@ class URLGrabber(object): log.debug("fetching %s => %s" % (url, filename)) - with open(filename, 'w') as outfile: + with open(filename, 'wb') as outfile: self.change_url(url, outfile, user, passwd, no_cache) self.perform() @@ -440,7 +440,7 @@ class RepoParser(object): fh_gz = open(fname, 'r') buildconf_file = os.path.join(os.path.dirname(fname), 'build.conf') - buildconf_fh = open(buildconf_file, 'w') + buildconf_fh = open(buildconf_file, 'wb') buildconf_fh.write(fh_gz.read()) fh_gz.close() buildconf_fh.close() diff --git a/tests/test_changelog.py b/tests/test_changelog.py index 1078863..a93c09f 100644 --- a/tests/test_changelog.py +++ b/tests/test_changelog.py @@ -32,7 +32,7 @@ from gbp.git.repository import GitRepository from gitbuildsys.errors import GbsError -GBS = SourceFileLoader("gbs", "../tools/gbs").load_module().main +GBS = SourceFileLoader("gbs", "./tools/gbs").load_module().main ENV = {} TEST_SPEC_CONTENT = """ diff --git a/tests/test_export.py b/tests/test_export.py index a1bfe16..007f5e2 100644 --- a/tests/test_export.py +++ b/tests/test_export.py @@ -8,7 +8,7 @@ import shutil import tempfile from nose.tools import eq_ -GBS = SourceFileLoader("gbs", "../tools/gbs").load_module().main +GBS = SourceFileLoader("gbs", "./tools/gbs").load_module().main class TestExport(unittest.TestCase): """Test export output of gbs commands""" diff --git a/tests/test_help.py b/tests/test_help.py index ccb77f9..643fee5 100644 --- a/tests/test_help.py +++ b/tests/test_help.py @@ -23,7 +23,7 @@ from importlib.machinery import SourceFileLoader from nose.tools import eq_ -GBS = SourceFileLoader("gbs", "../tools/gbs").load_module().main +GBS = SourceFileLoader("gbs", "./tools/gbs").load_module().main class TestHelp(unittest.TestCase): """Test help output of gbs commands""" diff --git a/tests/test_import.py b/tests/test_import.py index 512dd71..494a717 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -32,7 +32,7 @@ from gitbuildsys.errors import GbsError from gbp.git.repository import GitRepository -GBS = SourceFileLoader("gbs", "../tools/gbs").load_module().main +GBS = SourceFileLoader("gbs", "./tools/gbs").load_module().main def with_data(fname): """