fix run error in mic-bootstrap 70/294570/8
authorbiao716.wang <biao716.wang@samsung.com>
Wed, 21 Jun 2023 08:38:38 +0000 (17:38 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Tue, 27 Jun 2023 03:26:47 +0000 (12:26 +0900)
Change-Id: Iadabbd7a5eedf2b1189e1b851801b18c6e59b9fe
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
mic/utils/errors.py
mic/utils/misc.py
plugins/backend/yumpkgmgr.py
plugins/backend/zypppkgmgr.py
tools/mic

index 9e7f13319a211f997fe054eb45b3016db60a16f1..d0c8e4000d28c414f1650c79a15e46fc6f900af6 100644 (file)
@@ -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
index 2898f1d57adf9ddaafcdecac43b6873d56b62a13..e50f8f3428642369eed0e6fb1480949e0b44ae87 100755 (executable)
@@ -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)
index 51d978660fc66f52dffda7f541ed9f89ee12c4e8..3370feff807fef867b9014930c512fac537bd43d 100644 (file)
@@ -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:
index 7822904de0e2eda8368336fdee38faa0f1387e07..b95f9bddfef953f3f2f24073f26029f136f0f6f3 100644 (file)
@@ -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))
index abb5bab30d4002b795d95a5af0a7fd58849400ed..6cfcd497e4bf6712edd201dfeba5193696733791 100755 (executable)
--- 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')