From: biao716.wang Date: Wed, 21 Jun 2023 08:38:38 +0000 (+0900) Subject: fix run error in mic-bootstrap X-Git-Tag: accepted/tools/devbase/tools/20250527.103804~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c67d6f630a5039024fa6e5e7d8110bcbd4fa8d5;p=tools%2Fmic.git fix run error in mic-bootstrap Change-Id: Iadabbd7a5eedf2b1189e1b851801b18c6e59b9fe Signed-off-by: biao716.wang --- diff --git a/mic/utils/errors.py b/mic/utils/errors.py index 9e7f133..d0c8e40 100644 --- a/mic/utils/errors.py +++ b/mic/utils/errors.py @@ -26,7 +26,7 @@ class CreatorError(Exception): def __str__(self): if isinstance(self.msg, str): - self.msg = self.msg.encode('utf-8', 'ignore') + pass else: self.msg = str(self.msg) return self.msg diff --git a/mic/utils/misc.py b/mic/utils/misc.py index 2898f1d..e50f8f3 100755 --- a/mic/utils/misc.py +++ b/mic/utils/misc.py @@ -290,7 +290,7 @@ def normalize_ksfile(ksconf, release, arch): ksc = ksc.replace("@BUILD_ID@", release) fd, ksconf = tempfile.mkstemp(prefix=os.path.basename(ksconf)) - os.write(fd, ksc) + os.write(fd, ksc.encode()) os.close(fd) msger.debug('normalized ks file:%s' % ksconf) diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py index 51d9786..3370fef 100644 --- a/plugins/backend/yumpkgmgr.py +++ b/plugins/backend/yumpkgmgr.py @@ -240,7 +240,7 @@ class Yum(BackendPlugin, yum.YumBase): else: msger.warning("No such package %s to remove" %(pkg,)) - def selectGroup(self, grp, include = ksparser.GROUP_DEFAULT): + def selectGroup(self, grp, include = ksparser.constants.GROUP_DEFAULT): try: yum.YumBase.selectGroup(self, grp) if include == ksparser.GROUP_REQUIRED: diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index 7822904..b95f9bd 100644 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -20,6 +20,7 @@ import shutil import urllib.parse import rpm import glob +import functools import zypp #pylint: disable=import-error if not hasattr(zypp, 'PoolQuery') or \ @@ -226,7 +227,7 @@ class Zypp(BackendPlugin): for pitem in sorted( q.queryResults(self.Z.pool()), - cmp=lambda x,y: cmpEVR(zypp.asKindPackage(x), zypp.asKindPackage(y)), + key=functools.cmp_to_key(lambda x,y: cmpEVR(zypp.asKindPackage(x), zypp.asKindPackage(y))), reverse=True): item = zypp.asKindPackage(pitem) if item.name() in list(self.excpkgs.keys()) and \ @@ -254,7 +255,7 @@ class Zypp(BackendPlugin): for pitem in sorted( q.queryResults(self.Z.pool()), - cmp=lambda x,y: cmpEVR(zypp.asKindPackage(x), zypp.asKindPackage(y)), + key=functools.cmp_to_key(lambda x,y: cmpEVR(zypp.asKindPackage(x), zypp.asKindPackage(y))), reverse=True): item = zypp.asKindPackage(pitem) if item.name() in list(self.excpkgs.keys()) and \ @@ -303,7 +304,7 @@ class Zypp(BackendPlugin): """collect packages should not be installed""" self.to_deselect.append(pkg) - def selectGroup(self, grp, include = ksparser.GROUP_DEFAULT): + def selectGroup(self, grp, include = ksparser.constants.GROUP_DEFAULT): def compareGroup(pitem): item = zypp.asKindPattern(pitem) return item.repoInfo().priority() @@ -734,8 +735,8 @@ class Zypp(BackendPlugin): for problem in probs: msger.warning("repo problem: %s, %s" \ - % (problem.description().decode("utf-8"), - problem.details().decode("utf-8"))) + % (problem.description(), + problem.details())) raise RepoError("found %d resolver problem, abort!" \ % len(probs)) diff --git a/tools/mic b/tools/mic index abb5bab..6cfcd49 100755 --- a/tools/mic +++ b/tools/mic @@ -147,7 +147,7 @@ def create_parser(parser): parser.set_defaults(alias="cr") - subparsers = parser.add_subparsers(title='Subcommands' ) + subparsers = parser.add_subparsers(title='Subcommands', dest='subcommand') subparsers.required = True auto_parser = subparsers.add_parser('auto', parents=[parent_parser], help='auto detect image type from magic header')