Remove useless try and reraise blocks.
authorHuang Hao <hao.h.huang@intel.com>
Mon, 11 Mar 2013 10:42:25 +0000 (18:42 +0800)
committerGerrit Code Review <gerrit2@otctools.jf.intel.com>
Tue, 12 Mar 2013 07:38:50 +0000 (00:38 -0700)
These code catch all exceptions and simply reraise them, which is
equivalent to not writing the try block. So just remove them to
cleanup.

Change-Id: I965356746a5b349458205de9c5a1d6bf97bf8d93

mic/bootstrap.py
mic/kickstart/__init__.py
tools/mic

index ca42a19..66c291b 100644 (file)
@@ -105,18 +105,15 @@ class MiniBackend(object):
     def downloadPkgs(self):
         nonexist = []
         for pkg in self.dlpkgs:
-            try:
-                localpth = misc.get_package(pkg, self.repomd, self.arch)
-                if localpth:
-                    self.localpkgs[pkg] = localpth
-                elif pkg in self.optionals:
-                    # skip optional rpm
-                    continue
-                else:
-                    # mark nonexist rpm
-                    nonexist.append(pkg)
-            except:
-                raise
+            localpth = misc.get_package(pkg, self.repomd, self.arch)
+            if localpth:
+                self.localpkgs[pkg] = localpth
+            elif pkg in self.optionals:
+                # skip optional rpm
+                continue
+            else:
+                # mark nonexist rpm
+                nonexist.append(pkg)
 
         if nonexist:
             raise errors.BootstrapError("Can't get rpm binary: %s" %
@@ -215,13 +212,9 @@ class Bootstrap(object):
             pkgmgr.optionals = list(optlist)
             map(pkgmgr.selectPackage, pkglist + list(optlist))
             pkgmgr.runInstall()
-
         except (OSError, IOError, errors.CreatorError), err:
             raise errors.BootstrapError("%s" % err)
 
-        except:
-            raise
-
     def run(self, cmd, chdir, rootdir=None, bindmounts=None):
         def mychroot():
             os.chroot(rootdir)
index 6594436..eb8bee2 100644 (file)
@@ -315,10 +315,7 @@ class UserConfig(KickstartConfig):
     @apply_wrapper
     def apply(self, user):
         for userconfig in user.userList:
-            try:
-                self.addUser(userconfig)
-            except:
-                raise
+            self.addUser(userconfig)
 
 class ServicesConfig(KickstartConfig):
     """A class to apply a kickstart services configuration to a system."""
index 02a96df..b316dbf 100755 (executable)
--- a/tools/mic
+++ b/tools/mic
@@ -90,11 +90,8 @@ class MicCmd(cmdln.Cmdln):
 
     @cmdln.alias("cr")
     def do_create(self, argv):
-        try:
-            cr = creator.Creator()
-            cr.main(argv[1:])
-        except:
-            raise
+        cr = creator.Creator()
+        cr.main(argv[1:])
 
     def _root_confirm(self):
         if os.geteuid() != 0: