From f11008f4c3fe8adf14aa16d0106ed8e0baf087d7 Mon Sep 17 00:00:00 2001 From: Huang Hao Date: Mon, 11 Mar 2013 18:42:25 +0800 Subject: [PATCH] Remove useless try and reraise blocks. 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 | 25 +++++++++---------------- mic/kickstart/__init__.py | 5 +---- tools/mic | 7 ++----- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/mic/bootstrap.py b/mic/bootstrap.py index ca42a19..66c291b 100644 --- a/mic/bootstrap.py +++ b/mic/bootstrap.py @@ -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) diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py index 6594436..eb8bee2 100644 --- a/mic/kickstart/__init__.py +++ b/mic/kickstart/__init__.py @@ -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.""" diff --git a/tools/mic b/tools/mic index 02a96df..b316dbf 100755 --- 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: -- 2.7.4