Merge release-0.28.17 from 'tools/mic'
[platform/upstream/mic.git] / plugins / backend / yumpkgmgr.py
index 8f3112d..d63c592 100644 (file)
@@ -77,7 +77,7 @@ class MyYumRepository(yum.yumRepo.YumRepository):
                 import M2Crypto
                 m2c_connection = M2Crypto.SSL.Connection.clientPostConnectionCheck
                 M2Crypto.SSL.Connection.clientPostConnectionCheck = None
-            except ImportError, err:
+            except ImportError as err:
                 raise CreatorError("%s, please try to install python-m2crypto" % str(err))
 
         proxy = None
@@ -165,7 +165,7 @@ class Yum(BackendPlugin, yum.YumBase):
         f.write(conf)
         f.close()
 
-        os.chmod(confpath, 0644)
+        os.chmod(confpath, 0o644)
 
     def _cleanupRpmdbLocks(self, installroot):
         # cleans up temporary files left by bdb so that differing
@@ -205,9 +205,9 @@ class Yum(BackendPlugin, yum.YumBase):
             return None
         except yum.Errors.InstallError:
             return "No package(s) available to install"
-        except yum.Errors.RepoError, e:
+        except yum.Errors.RepoError as e:
             raise CreatorError("Unable to download from repo : %s" % (e,))
-        except yum.Errors.YumBaseError, e:
+        except yum.Errors.YumBaseError as e:
             raise CreatorError("Unable to install: %s" % (e,))
 
     def deselectPackage(self, pkg):
@@ -252,11 +252,11 @@ class Yum(BackendPlugin, yum.YumBase):
                     self.selectPackage(p)
 
             return None
-        except (yum.Errors.InstallError, yum.Errors.GroupsError), e:
+        except (yum.Errors.InstallError, yum.Errors.GroupsError) as e:
             return e
-        except yum.Errors.RepoError, e:
+        except yum.Errors.RepoError as e:
             raise CreatorError("Unable to download from repo : %s" % (e,))
-        except yum.Errors.YumBaseError, e:
+        except yum.Errors.YumBaseError as e:
             raise CreatorError("Unable to install: %s" % (e,))
 
     def addRepository(self, name, url = None, mirrorlist = None, proxy = None,
@@ -308,9 +308,9 @@ class Yum(BackendPlugin, yum.YumBase):
         ts = rpmUtils.transaction.initReadOnlyTransaction()
         try:
             hdr = rpmUtils.miscutils.hdrFromPackage(ts, pkg)
-        except rpmUtils.RpmUtilsError, e:
-            raise yum.Errors.MiscError, \
-                  'Could not open local rpm file: %s: %s' % (pkg, e)
+        except rpmUtils.RpmUtilsError as e:
+            raise yum.Errors.MiscError \
+                  ('Could not open local rpm file: %s: %s' % (pkg, e))
 
         self.deselectPackage(hdr['name'])
         yum.YumBase.installLocal(self, pkg, po, updateonly)
@@ -335,7 +335,7 @@ class Yum(BackendPlugin, yum.YumBase):
         os.environ["LD_PRELOAD"] = ""
         try:
             (res, resmsg) = self.buildTransaction()
-        except yum.Errors.RepoError, e:
+        except yum.Errors.RepoError as e:
             raise CreatorError("Unable to download from repo : %s" %(e,))
 
         if res != 2:
@@ -393,7 +393,7 @@ class Yum(BackendPlugin, yum.YumBase):
             raise CreatorError("No enough space used for downloading.")
 
         # record the total size of installed pkgs
-        pkgs_total_size = 0L
+        pkgs_total_size = 0
         for x in dlpkgs:
             if hasattr(x, 'installedsize'):
                 pkgs_total_size += int(x.installedsize)
@@ -444,11 +444,11 @@ class Yum(BackendPlugin, yum.YumBase):
                 raise CreatorError("mic failes to install some packages")
             self._cleanupRpmdbLocks(self.conf.installroot)
 
-        except rpmUtils.RpmUtilsError, e:
+        except rpmUtils.RpmUtilsError as e:
             raise CreatorError("mic does NOT support delta rpm: %s" % e)
-        except yum.Errors.RepoError, e:
+        except yum.Errors.RepoError as e:
             raise CreatorError("Unable to download from repo : %s" % e)
-        except yum.Errors.YumBaseError, e:
+        except yum.Errors.YumBaseError as e:
             raise CreatorError("Unable to install: %s" % e)
         finally:
             msger.disable_logstderr()
@@ -468,7 +468,7 @@ class Yum(BackendPlugin, yum.YumBase):
                     }
             try:
                 self.__pkgs_vcsinfo[lname] = hdr['VCS']
-            except ValueError, KeyError:
+            except ValueError as KeyError:
                 self.__pkgs_vcsinfo[lname] = None
 
         return self.__pkgs_vcsinfo