Mostly replaces 'except Foo, e' with 'except Foo as e', but there are a few areas where some logic gets reworked. --- anaconda | 4 +- pyanaconda/__init__.py | 2 +- pyanaconda/backend.py | 4 +- pyanaconda/booty/bootloaderInfo.py | 25 ++++--- pyanaconda/booty/s390.py | 2 +- pyanaconda/firewall.py | 4 +- pyanaconda/gui.py | 18 +++-- pyanaconda/image.py | 120 +++++++++++++++----------------- pyanaconda/iutil.py | 18 +++-- pyanaconda/iw/GroupSelector.py | 6 +- pyanaconda/iw/account_gui.py | 2 +- pyanaconda/iw/partition_gui.py | 7 +- pyanaconda/iw/raid_dialog_gui.py | 2 +- pyanaconda/iw/task_gui.py | 6 +- pyanaconda/kickstart.py | 11 ++-- pyanaconda/livecd.py | 10 ++-- pyanaconda/rescue.py | 69 +++++++----------- pyanaconda/security.py | 6 +- pyanaconda/storage/devices.py | 6 +- pyanaconda/storage/formats/__init__.py | 6 +- pyanaconda/storage/formats/fs.py | 2 +- pyanaconda/storage/iscsi.py | 6 +- pyanaconda/storage/partitioning.py | 2 +- pyanaconda/storage/zfcp.py | 6 +- pyanaconda/textw/add_drive_text.py | 6 +- pyanaconda/textw/keyboard_text.py | 4 +- pyanaconda/textw/netconfig_text.py | 16 ++-- pyanaconda/textw/userauth_text.py | 2 +- pyanaconda/upgrade.py | 2 +- pyanaconda/users.py | 8 +- pyanaconda/vnc.py | 37 ++++------ pyanaconda/yuminstall.py | 54 +++++++-------- utils/log_picker/sending/ftpsender.py | 2 +- 33 files changed, 222 insertions(+), 253 deletions(-) diff --git a/anaconda b/anaconda index 7c1751e..75fd189 100755 --- a/anaconda +++ b/anaconda @@ -474,7 +474,7 @@ def runRescueMode(anaconda, opts): # We need an interface before running kickstart execute methods for # storage. - from snack import * + from snack import SnackScreen screen = SnackScreen() anaconda.intf = rescue.RescueInterface(screen) @@ -881,7 +881,7 @@ if __name__ == "__main__": users.createLuserConf(anaconda.rootPath) if opts.rescue: - runRescueMode(anaconda) + runRescueMode(anaconda, opts) # comment out the next line to make exceptions non-fatal from pyanaconda.exception import initExceptionHandling diff --git a/pyanaconda/__init__.py b/pyanaconda/__init__.py index 3b58028..99419cf 100644 --- a/pyanaconda/__init__.py +++ b/pyanaconda/__init__.py @@ -233,7 +233,7 @@ class Anaconda(object): try: from gui import InstallInterface - except Exception, e: + except Exception as e: from flags import flags stdoutLog.error("Exception starting GUI installer: %s" %(e,)) # if we're not going to really go into GUI mode, we need to get diff --git a/pyanaconda/backend.py b/pyanaconda/backend.py index 65a1de0..b5a7323 100644 --- a/pyanaconda/backend.py +++ b/pyanaconda/backend.py @@ -74,7 +74,7 @@ class AnacondaBackend: for f in glob.glob(DD_FIRMWARE+"/*"): try: shutil.copyfile(f, "%s/lib/firmware/" % anaconda.rootPath) - except IOError, e: + except IOError as e: log.error("Could not copy firmware file %s: %s" % (f, e.strerror)) def doPostInstall(self, anaconda): @@ -93,7 +93,7 @@ class AnacondaBackend: if os.path.exists(DD_ALL): try: shutil.copytree(DD_ALL, anaconda.rootPath + "/root/DD") - except IOError, e: + except IOError as e: pass storage.writeEscrowPackets(anaconda) diff --git a/pyanaconda/booty/bootloaderInfo.py b/pyanaconda/booty/bootloaderInfo.py index 7eee4ec..c297557 100644 --- a/pyanaconda/booty/bootloaderInfo.py +++ b/pyanaconda/booty/bootloaderInfo.py @@ -268,21 +268,22 @@ class BootImages: if part.partType not in (parted.PARTITION_NORMAL, parted.PARTITION_LOGICAL) or not part.format: continue - type = part.format.type - - if type in dosFilesystems and not foundDos and doesDualBoot() and \ + if part.format.type in dosFilesystems and \ + not foundDos and doesDualBoot() and \ not part.getFlag(parted.PARTITION_DIAG): try: bootable = checkForBootBlock(part.path) - retval.append((part, type)) - foundDos = True - except: + except (OSError, struct.error): pass - elif type == "appleboot" and iutil.getPPCMachine() == "PMac" and part.bootable: + else: + retval.append((part, part.format.type)) + foundDos = True + elif part.format.type == "appleboot" and \ + iutil.getPPCMachine() == "PMac" and part.bootable: foundAppleBootstrap = True - elif type in ["hfs", "hfs+"] and foundAppleBootstrap: + elif part.format.type in ["hfs", "hfs+"] and foundAppleBootstrap: # questionable for same reason as above, but on mac this time - retval.append((part, type)) + retval.append((part, part.format.type)) if addRoot: rootDevice = storage.rootDevice @@ -392,7 +393,7 @@ class bootloaderInfo(object): try: lilo.delImage(label) - except IndexError, msg: + except IndexError as msg: pass sl = LiloConfigFile(imageType = "image", path = kernelFile) @@ -517,7 +518,7 @@ class bootloaderInfo(object): try: ele = self._drivelist.pop(self._drivelist.index(i)) self._drivelist.insert(0, ele) - except: + except LookupError: pass def _getDriveList(self): @@ -627,7 +628,7 @@ class efiBootloaderInfo(bootloaderInfo): def addNewEfiEntry(self, instRoot): try: bootdev = self.storage.mountpoints["/boot/efi"].name - except: + except (KeyError, AttributeError): bootdev = "sda1" link = "%s%s/%s" % (instRoot, "/etc/", self.configname) diff --git a/pyanaconda/booty/s390.py b/pyanaconda/booty/s390.py index 60fc013..38f6a9e 100644 --- a/pyanaconda/booty/s390.py +++ b/pyanaconda/booty/s390.py @@ -38,7 +38,7 @@ class s390BootloaderInfo(bootloaderInfo): try: lilo.delImage(label) - except IndexError, msg: + except IndexError as msg: pass sl = LiloConfigFile(imageType = "image", path = kernelFile) diff --git a/pyanaconda/firewall.py b/pyanaconda/firewall.py index 750d755..c11b671 100644 --- a/pyanaconda/firewall.py +++ b/pyanaconda/firewall.py @@ -80,10 +80,8 @@ class Firewall: stderr="/dev/null") else: log.error("would have run %s", args) - except RuntimeError, msg: + except (RuntimeError, OSError) as msg: log.error ("lokkit run failed: %s", msg) - except OSError as e: - log.error ("lokkit run failed: %s", e.strerror) else: f = open(instPath + '/etc/sysconfig/system-config-firewall', 'w') diff --git a/pyanaconda/gui.py b/pyanaconda/gui.py index 92cae55..35ee5d1 100755 --- a/pyanaconda/gui.py +++ b/pyanaconda/gui.py @@ -104,7 +104,7 @@ def copyScreenshots(): if not os.access(destDir, os.R_OK): try: os.mkdir(destDir, 0750) - except: + except OSError: window = MessageWindow("Error Saving Screenshot", _("An error occurred saving screenshots " "to disk."), type="warning") @@ -150,7 +150,7 @@ def takeScreenShot(): gtk.gdk.screen_height()) if screenshot: - while (1): + while True: sname = "screenshot-%04d.png" % ( screenshotIndex,) if not os.access(screenshotDir + '/' + sname, os.R_OK): break @@ -166,7 +166,8 @@ def takeScreenShot(): window = MessageWindow(_("Saving Screenshot"), _("A screenshot named '%s' has been saved.") % (sname,) , type="ok") - except: + except Exception: + # FIXME: find out what exceptions gtk.gdk.Pixbuf might actually raise window = MessageWindow(_("Error Saving Screenshot"), _("An error occurred while saving " "the screenshot. If this occurred " @@ -347,7 +348,7 @@ def getPixbuf(file): try: pixbuf = gtk.gdk.pixbuf_new_from_file(fn) - except RuntimeError, msg: + except RuntimeError as msg: log.error("unable to read %s: %s" %(file, msg)) pixbuf = None @@ -744,7 +745,8 @@ class MessageWindow: import pdb try: pdb.set_trace() - except: + except Exception: + # FIXME: what exceptions might pdb.set_trace raise? sys.exit(-1) try: # switch back @@ -875,7 +877,7 @@ class DetailedMessageWindow(MessageWindow): if __builtins__.get("type")(line) != unicode: try: line = unicode(line, encoding='utf-8') - except UnicodeDecodeError, e: + except UnicodeDecodeError as e: log.error("UnicodeDecodeException: line = %s" % (line,)) log.error("UnicodeDecodeException: %s" % (str(e),)) @@ -1266,7 +1268,7 @@ class InstallControlWindow: import pdb try: pdb.set_trace() - except: + except Exception: sys.exit(-1) try: # switch back @@ -1308,7 +1310,7 @@ class InstallControlWindow: loaded = imp.load_module(moduleName, *found) newScreenClass = loaded.__dict__[className] break - except ImportError, e: + except ImportError as e: stdout_log.error("loading interface component %s" % className) stdout_log.error(traceback.format_exc()) win = MessageWindow(_("Error!"), diff --git a/pyanaconda/image.py b/pyanaconda/image.py index ed74976..a17ac2d 100644 --- a/pyanaconda/image.py +++ b/pyanaconda/image.py @@ -18,7 +18,7 @@ # import isys, iutil -import os, os.path, stat, string, sys +import os, os.path, stat, sys from constants import * import gettext @@ -34,61 +34,60 @@ def findFirstIsoImage(path, messageWindow): files = os.listdir(path) arch = _arch - for file in files: - what = path + '/' + file + for f in files: + what = path + '/' + f log.debug("Checking %s" % (what)) if not isys.isIsoImage(what): continue + log.debug("mounting %s on /mnt/cdimage", what) try: - log.debug("mounting %s on /mnt/cdimage", what) - isys.mount(what, "/mnt/cdimage", fstype = "iso9660", readOnly = True) - - if os.access("/mnt/cdimage/.discinfo", os.R_OK): - log.debug("Reading .discinfo") - f = open("/mnt/cdimage/.discinfo") - try: - f.readline() # skip timestamp - f.readline() # skip release description - discArch = string.strip(f.readline()) # read architecture - except: - discArch = None - - f.close() - - log.debug("discArch = %s" % discArch) - if discArch != arch: - isys.umount("/mnt/cdimage", removeDir=False) - continue - - # If there's no repodata, there's no point in trying to - # install from it. - if not os.access("/mnt/cdimage/repodata", os.R_OK): - log.warning("%s doesn't have repodata, skipping" %(what,)) - isys.umount("/mnt/cdimage", removeDir=False) - continue - - # warn user if images appears to be wrong size - if os.stat(what)[stat.ST_SIZE] % 2048: - rc = messageWindow(_("Warning"), - _("The ISO image %s has a size which is not " - "a multiple of 2048 bytes. This may mean " - "it was corrupted on transfer to this computer." - "\n\n" - "It is recommended that you exit and abort your " - "installation, but you can choose to continue if " - "you think this is in error.") % (file,), - type="custom", custom_icon="warning", - custom_buttons= [_("_Exit installer"), - _("_Continue")]) - if rc == 0: - sys.exit(0) - - log.info("Found disc at %s" % file) - isys.umount("/mnt/cdimage", removeDir=False) - return file + isys.mount(what, "/mnt/cdimage", fstype="iso9660", readOnly=True) except SystemError: - pass + continue + + if not os.access("/mnt/cdimage/.discinfo", os.R_OK): + isys.umount("/mnt/cdimage", removeDir=False) + continue + + log.debug("Reading .discinfo") + f = open("/mnt/cdimage/.discinfo") + f.readline() # skip timestamp + f.readline() # skip release description + discArch = f.readline().strip() # read architecture + f.close() + + log.debug("discArch = %s" % discArch) + if discArch != arch: + isys.umount("/mnt/cdimage", removeDir=False) + continue + + # If there's no repodata, there's no point in trying to + # install from it. + if not os.access("/mnt/cdimage/repodata", os.R_OK): + log.warning("%s doesn't have repodata, skipping" %(what,)) + isys.umount("/mnt/cdimage", removeDir=False) + continue + + # warn user if images appears to be wrong size + if os.stat(what)[stat.ST_SIZE] % 2048: + rc = messageWindow(_("Warning"), + _("The ISO image %s has a size which is not " + "a multiple of 2048 bytes. This may mean " + "it was corrupted on transfer to this computer." + "\n\n" + "It is recommended that you exit and abort your " + "installation, but you can choose to continue if " + "you think this is in error.") % (f,), + type="custom", custom_icon="warning", + custom_buttons= [_("_Exit installer"), + _("_Continue")]) + if rc == 0: + sys.exit(0) + + log.info("Found disc at %s" % f) + isys.umount("/mnt/cdimage", removeDir=False) + return f return None @@ -132,7 +131,7 @@ def mountDirectory(methodstr, messageWindow): try: isys.mount(device, "/mnt/isodir", fstype=fstype, options=options) break - except SystemError, msg: + except SystemError as msg: log.error("couldn't mount ISO source directory: %s" % msg) ans = messageWindow(_("Couldn't Mount ISO Source"), _("An error occurred mounting the source " @@ -160,7 +159,7 @@ def mountImage(isodir, tree, messageWindow): isoImage = "%s/%s" % (isodir, image) isys.mount(isoImage, tree, fstype = 'iso9660', readOnly = True) break - except: + except SystemError: ans = messageWindow(_("Missing ISO 9660 Image"), _("The installer has tried to mount the " "installation image, but cannot find it on " @@ -186,7 +185,7 @@ def scanForMedia(tree, storage): storage.devicetree.updateDeviceFormat(dev) try: dev.format.mount(mountpoint=tree) - except: + except Exception: continue if not verifyMedia(tree): @@ -209,7 +208,7 @@ def unmountCD(dev, messageWindow): try: dev.format.unmount() break - except Exception, e: + except Exception as e: log.error("exception in _unmountCD: %s" %(e,)) messageWindow(_("Error"), _("An error occurred unmounting the disc. " @@ -223,17 +222,8 @@ def verifyMedia(tree, timestamp=None): f = open("%s/.discinfo" % tree) newStamp = f.readline().strip() - - try: - descr = f.readline().strip() - except: - descr = None - - try: - arch = f.readline().strip() - except: - arch = None - + descr = f.readline().strip() + arch = f.readline().strip() f.close() if timestamp is not None: diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py index 0960378..62a8a97 100644 --- a/pyanaconda/iutil.py +++ b/pyanaconda/iutil.py @@ -464,7 +464,7 @@ def mkdirChain(dir): try: if e.errno == EEXIST and stat.S_ISDIR(os.stat(dir).st_mode): return - except: + except OSError: pass log.error("could not create directory %s: %s" % (dir, e.strerror)) @@ -779,7 +779,10 @@ def strip_markup(text): return r.encode("utf-8") def notify_kernel(path, action="change"): - """ Signal the kernel that the specified device has changed. """ + """ Signal the kernel that the specified device has changed. + + Exceptions raised: ValueError, IOError + """ log.debug("notifying kernel of '%s' event on device %s" % (action, path)) path = os.path.join(path, "uevent") if not path.startswith("/sys/") or not os.access(path, os.W_OK): @@ -813,9 +816,8 @@ def numeric_type(num): return num def reIPL(anaconda, loader_pid): - try: - ipldev = anaconda.id.bootloader.getDevice() - except: + ipldev = anaconda.bootloader.getDevice() + if not ipldev: message = _("Error determining boot device's disk name") log.warning(message) return message @@ -824,9 +826,9 @@ def reIPL(anaconda, loader_pid): rc = execWithRedirect("chreipl", ["node", "/dev/" + ipldev], stdout = "/dev/tty5", stderr = "/dev/tty5") - except Exception, e: + except RuntimeError as e: log.info("Unable to set reIPL device to %s: %s", - ipldev, e.message) + ipldev, e) if rc: anaconda.canReIPL = False @@ -857,7 +859,7 @@ def resetRpmDb(rootdir): for rpmfile in glob.glob("%s/var/lib/rpm/__db.*" % rootdir): try: os.unlink(rpmfile) - except Exception, e: + except OSError as e: log.debug("error %s removing file: %s" %(e,rpmfile)) def parseNfsUrl(nfsurl): diff --git a/pyanaconda/iw/GroupSelector.py b/pyanaconda/iw/GroupSelector.py index 6a3a675..92c7dc3 100644 --- a/pyanaconda/iw/GroupSelector.py +++ b/pyanaconda/iw/GroupSelector.py @@ -64,7 +64,7 @@ def sanitizeString(s, translate = True): if type(s) != unicode: try: s = unicode(s, "utf-8") - except UnicodeDecodeError, e: + except UnicodeDecodeError as e: sys.stderr.write("Unable to convert %s to a unicode object: %s\n" % (s, e)) return "" return s @@ -114,7 +114,7 @@ def _selectPackage(ayum, group, pkg): grpid = group.groupid try: txmbrs = ayum.install(name = pkg) - except yum.Errors.InstallError, e: + except yum.Errors.InstallError as e: log = logging.getLogger("yum.verbose") log.info("No package named %s available to be installed: %s" %(pkg, e)) else: @@ -208,7 +208,7 @@ class OptionalPackageSelector: def __getPackageObject(self, pkgname): try: pkgs = self.ayum.pkgSack.returnNewestByName(pkgname) - except: + except yum.Errors.YumBaseError: return None if not pkgs: diff --git a/pyanaconda/iw/account_gui.py b/pyanaconda/iw/account_gui.py index f467300..67859e1 100644 --- a/pyanaconda/iw/account_gui.py +++ b/pyanaconda/iw/account_gui.py @@ -122,7 +122,7 @@ class AccountWindow (InstallWindow): try: cracklib.FascistCheck(pw) - except ValueError, e: + except ValueError as e: msg = gettext.ldgettext("cracklib", e) ret = self.intf.messageWindow(_("Weak Password"), _("You have provided a weak password: %s") % msg, diff --git a/pyanaconda/iw/partition_gui.py b/pyanaconda/iw/partition_gui.py index 95197bf..4c9bba2 100644 --- a/pyanaconda/iw/partition_gui.py +++ b/pyanaconda/iw/partition_gui.py @@ -598,7 +598,8 @@ class DiskTreeModelHelper: key = self.columns[key] try: return self.model.get_value(self.iter, key) - except: + except Exception: + # FIXME: what exceptions might actually get raised here? return None def __setitem__(self, key, value): @@ -1584,12 +1585,12 @@ class PartitionWindow(InstallWindow): try: doPartitioning(self.storage) rc = 0 - except PartitioningError, msg: + except PartitioningError as msg: self.intf.messageWindow(_("Error Partitioning"), _("Could not allocate requested partitions: %s.") % (msg), custom_icon="error") rc = -1 - except PartitioningWarning, msg: + except PartitioningWarning as msg: # XXX somebody other than me should make this look better # XXX this doesn't handle the 'delete /boot partition spec' case # (it says 'add anyway') diff --git a/pyanaconda/iw/raid_dialog_gui.py b/pyanaconda/iw/raid_dialog_gui.py index aeeb8f1..e63ed6b 100644 --- a/pyanaconda/iw/raid_dialog_gui.py +++ b/pyanaconda/iw/raid_dialog_gui.py @@ -222,7 +222,7 @@ class RaidEditor: parents=raidmembers, totalDevices=len(raidmembers), memberDevices=members) - except ValueError, e: + except ValueError as e: self.intf.messageWindow(_("Error"), str(e), custom_icon="error") continue diff --git a/pyanaconda/iw/task_gui.py b/pyanaconda/iw/task_gui.py index 75d0910..24ad9ce 100644 --- a/pyanaconda/iw/task_gui.py +++ b/pyanaconda/iw/task_gui.py @@ -140,13 +140,13 @@ class RepoEditor: try: return mapping[method.split(':')[0].lower()] - except: + except (AttributeError, KeyError): return 0 def _addAndEnableRepo(self, repo): try: self.backend.ayum.repos.add(repo) - except yum.Errors.DuplicateRepoError, e: + except yum.Errors.DuplicateRepoError as e: self.intf.messageWindow(_("Error"), _("The repository %s has already been added. Please " "choose a different repository name and " @@ -375,7 +375,7 @@ class RepoEditor: try: os.unlink("%s/cachecookie" % self.repo.cachedir) os.unlink("%s/repomd.xml" % self.repo.cachedir) - except: + except OSError: pass self.repo.disable() diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index 4edd50d..3123dc3 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -104,12 +104,13 @@ class AnacondaKSScript(Script): try: f = open(messages, "r") + except IOError as e: + err = None + else: err = f.readlines() f.close() for l in err: log.error("\t%s" % l) - except: - err = None if self.errorOnFail: if intf != None: @@ -985,7 +986,7 @@ class RaidData(commands.raid.F15_RaidData): try: request = storage.newMDArray(**kwargs) - except ValueError, e: + except ValueError as e: raise KickstartValueError, formatErrorMsg(self.lineno, msg=str(e)) if self.fsprofile and hasattr(request.format, "fsprofile"): @@ -1107,7 +1108,7 @@ class ZFCP(commands.zfcp.F14_ZFCP): fcp = commands.zfcp.F14_ZFCP.parse(self, args) try: storage.zfcp.ZFCP().addFCP(fcp.devnum, fcp.wwpn, fcp.fcplun) - except ValueError, e: + except ValueError as e: log.warning(str(e)) return fcp @@ -1442,7 +1443,7 @@ def selectPackages(anaconda): try: anaconda.backend.selectGroup(grp.name, (default, optional)) - except NoSuchGroup, e: + except NoSuchGroup as e: if ksdata.packages.handleMissing == KS_MISSING_IGNORE or ignoreAll: pass else: diff --git a/pyanaconda/livecd.py b/pyanaconda/livecd.py index c1918a9..af05fda 100644 --- a/pyanaconda/livecd.py +++ b/pyanaconda/livecd.py @@ -61,7 +61,7 @@ def copytree(src, dst, symlinks=False, preserveOwner=False, def trySetfilecon(src, dest): try: selinux.lsetfilecon(dest, selinux.lgetfilecon(src)[1]) - except: + except OSError: log.error("Could not set selinux context on file %s" % dest) # copy of shutil.copytree which doesn't require dst to not exist @@ -90,11 +90,11 @@ def copytree(src, dst, symlinks=False, preserveOwner=False, trySetfilecon(srcname, dstname) shutil.copystat(srcname, dstname) - except (IOError, os.error), why: + except (IOError, OSError) as why: errors.append((srcname, dstname, str(why))) # catch the Error from the recursive copytree so that we can # continue with other files - except Error, err: + except Error as err: errors.extend(err.args[0]) try: if preserveOwner: @@ -130,7 +130,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend): try: anaconda.storage.umountFilesystems(swapoff = False) os.rmdir(anaconda.rootPath) - except Exception, e: + except Exception as e: log.error("Unable to unmount filesystems: %s" % e) def doPreInstall(self, anaconda): @@ -156,7 +156,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend): try: buf = os.read(osfd, readamt) written = os.write(rootfd, buf) - except: + except (IOError, OSError): rc = anaconda.intf.messageWindow(_("Error"), _("There was an error installing the live image to " "your hard drive. This could be due to bad media. " diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py index e7077e9..bb21bf3 100644 --- a/pyanaconda/rescue.py +++ b/pyanaconda/rescue.py @@ -31,10 +31,12 @@ import sys import os import isys from storage import mountExistingSystem +from storage.errors import StorageError from installinterfacebase import InstallInterfaceBase import iutil import shutil import time +import re import network import subprocess from pykickstart.constants import * @@ -77,14 +79,14 @@ class RescueInterface(InstallInterfaceBase): elif type == "custom": tmpbut = [] for but in custom_buttons: - tmpbut.append(string.replace(but,"_","")) + tmpbut.append(but.replace("_","")) rc = ButtonChoiceWindow(self.screen, title, text, width=60, buttons=tmpbut) idx = 0 for b in tmpbut: - if string.lower(b) == rc: + if b.lower() == rc: return idx idx = idx + 1 return 0 @@ -149,7 +151,7 @@ def makeFStab(instPath = ""): if buf: f.write(buf) f.close() - except IOError, e: + except IOError as e: log.info("failed to write /etc/fstab: %s" % e) # make sure they have a resolv.conf in the chroot @@ -190,9 +192,7 @@ def makeResolvConf(instPath): # def startNetworking(network, intf): # do lo first - try: - os.system("/usr/sbin/ifconfig lo 127.0.0.1") - except: + if os.system("/usr/sbin/ifconfig lo 127.0.0.1"): log.error("Error trying to start lo in rescue.py::startNetworking()") # start up dhcp interfaces first @@ -236,7 +236,7 @@ def runRescue(anaconda): "nsswitch.conf", "selinux", "mke2fs.conf" ]: try: os.symlink('/mnt/runtime/etc/' + file, '/etc/' + file) - except: + except OSError: pass # see if they would like networking enabled @@ -248,7 +248,7 @@ def runRescue(anaconda): _("Do you want to start the network interfaces on " "this system?"), [_("Yes"), _("No")]) - if rc != string.lower(_("No")): + if rc != _("No").lower(): anaconda.intf = RescueInterface(screen) if not anaconda.intf.enableNetwork(anaconda): @@ -303,14 +303,14 @@ def runRescue(anaconda): "command shell.\n\n") % (anaconda.rootPath,), [_("Continue"), _("Read-Only"), _("Skip"), _("Advanced")] ) - if rc == string.lower(_("Skip")): + if rc == _("Skip").lower(): runShell(screen) sys.exit(0) - elif rc == string.lower(_("Advanced")): + elif rc == _("Advanced").lower(): addDialog = addDriveDialog(anaconda) addDialog.addDriveDialog(screen) continue - elif rc == string.lower(_("Read-Only")): + elif rc == _("Read-Only").lower(): readOnly = 1 else: readOnly = 0 @@ -347,7 +347,7 @@ def runRescue(anaconda): scroll = scroll, height = height, help = "multipleroot") - if button == string.lower (_("Exit")): + if button == _("Exit").lower(): root = None else: root = disks[choice] @@ -395,7 +395,7 @@ def runRescue(anaconda): if not readOnly: try: anaconda.storage.turnOnSwap() - except: + except StorageError: log.error("Error enabling swap") # and /selinux too @@ -405,7 +405,7 @@ def runRescue(anaconda): try: fd = open("%s/.autorelabel" % anaconda.rootPath, "w+") fd.close() - except Exception, e: + except IOError: log.warning("cannot touch /.autorelabel") # set a library path to use mounted fs @@ -414,27 +414,18 @@ def runRescue(anaconda): os.environ["LD_LIBRARY_PATH"] = ":".join(libdirs + mounted) # find groff data dir + gversion = None try: glst = os.listdir("/mnt/sysimage/usr/share/groff") - + except OSError: + pass + else: # find a directory which is a numeral, its where # data files are - gversion = None for gdir in glst: - try: - isone = 1 - for idx in range(0, len(gdir)): - if string.find(string.digits + '.', gdir[idx]) == -1: - isone = 0 - break - if isone: - gversion = gdir - break - except: - gversion = None - continue - except: - gversion = None + if re.match(r'\d[.\d]+\d$', gdir): + gversion = gdir + break if gversion is not None: gpath = "/mnt/sysimage/usr/share/groff/"+gversion @@ -445,18 +436,12 @@ def runRescue(anaconda): try: if os.access("/usr/bin/bash", os.R_OK): os.symlink ("/usr/bin/bash", "/bin/bash") - except: + except OSError: pass - except: - # This looks horrible, but all it does is catch every exception, - # and reraise those in the tuple check. This lets programming - # errors raise exceptions, while any runtime error will - # still result in a shell - (exc, val) = sys.exc_info()[0:2] - log.error(str(exc)+": "+str(val)) - if exc in (IndexError, ValueError, SyntaxError): - raise exc, val, sys.exc_info()[2] - + except (ValueError, LookupError, SyntaxError, NameError): + raise + except Exception as e: + log.error("runRescue caught exception: %s" % e) if anaconda.ksdata: log.error("An error occurred trying to mount some or all of your system") else: @@ -497,7 +482,7 @@ def runRescue(anaconda): anaconda.storage.makeMtab(root=anaconda.rootPath) try: makeResolvConf(anaconda.rootPath) - except Exception, e: + except (OSError, IOError) as e: log.error("error making a resolv.conf: %s" %(e,)) msgStr = _("Your system is mounted under the %s directory.") % (anaconda.rootPath,) ButtonChoiceWindow(screen, _("Rescue"), msgStr, [_("OK")] ) diff --git a/pyanaconda/security.py b/pyanaconda/security.py index 6686251..5c71012 100644 --- a/pyanaconda/security.py +++ b/pyanaconda/security.py @@ -79,10 +79,8 @@ class Security: iutil.execWithRedirect("/usr/sbin/lokkit", args, root = instPath, stdout = "/dev/null", stderr = "/dev/null") - except RuntimeError, msg: + except (RuntimeError, OSError) as msg: log.error ("lokkit run failed: %s" %(msg,)) - except OSError as e: - log.error ("lokkit run failed: %s" % e.strerror) args = ["--update", "--nostart"] + shlex.split(self.auth) if self._addFingerprint(instPath): @@ -92,5 +90,5 @@ class Security: iutil.execWithRedirect("/usr/sbin/authconfig", args, stdout = "/dev/tty5", stderr = "/dev/tty5", root = instPath) - except RuntimeError, msg: + except RuntimeError as msg: log.error("Error running %s: %s", args, msg) diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py index d1e767f..e8e65fd 100644 --- a/pyanaconda/storage/devices.py +++ b/pyanaconda/storage/devices.py @@ -601,7 +601,7 @@ class StorageDevice(Device): path = os.path.normpath("/sys/%s" % self.sysfsPath) try: notify_kernel(path, action="change") - except Exception, e: + except (ValueError, IOError) as e: log.warning("failed to notify kernel of change: %s" % e) @property @@ -2065,7 +2065,7 @@ class LVMVolumeGroupDevice(DMDevice): status=self.status) try: self.parents.remove(device) - except ValueError, e: + except ValueError: raise ValueError("cannot remove non-member PV device from VG") device.removeChild() @@ -2465,7 +2465,7 @@ class LVMLogicalVolumeDevice(DMDevice): # LVs being active (filesystems mounted, &c), so don't let # it bring everything down. StorageDevice._postTeardown(self, recursive=recursive) - except Exception as e: + except StorageError: if recursive: log.debug("vg %s teardown failed; continuing" % self.vg.name) else: diff --git a/pyanaconda/storage/formats/__init__.py b/pyanaconda/storage/formats/__init__.py index 46b4aea..1f051e7 100644 --- a/pyanaconda/storage/formats/__init__.py +++ b/pyanaconda/storage/formats/__init__.py @@ -114,7 +114,7 @@ def collect_device_format_classes(): # imputil is deprecated in python 2.6 try: globals()[mod_name] = __import__(mod_name, globals(), locals(), [], -1) - except ImportError, e: + except ImportError: log.debug("import of device format module '%s' failed" % mod_name) def get_device_format_class(fmt_type): @@ -245,7 +245,7 @@ class DeviceFormat(object): if self.device.startswith("/dev/mapper/"): try: name = dm_node_from_name(os.path.basename(self.device)) - except Exception, e: + except DMError: log.warning("failed to get dm node for %s" % self.device) return elif self.device: @@ -254,7 +254,7 @@ class DeviceFormat(object): path = get_sysfs_path_by_name(name) try: notify_kernel(path, action="change") - except Exception, e: + except (ValueError, IOError) as e: log.warning("failed to notify kernel of change: %s" % e) diff --git a/pyanaconda/storage/formats/fs.py b/pyanaconda/storage/formats/fs.py index d65bdd0..95f8770 100644 --- a/pyanaconda/storage/formats/fs.py +++ b/pyanaconda/storage/formats/fs.py @@ -1348,7 +1348,7 @@ class NTFS(FS): try: min = l.split(":")[1].strip() minSize = int(min) + 250 - except Exception, e: + except (IndexError, ValueError) as e: minSize = None log.warning("Unable to parse output for minimum size on %s: %s" %(self.device, e)) diff --git a/pyanaconda/storage/iscsi.py b/pyanaconda/storage/iscsi.py index c706c93..ebaabe5 100644 --- a/pyanaconda/storage/iscsi.py +++ b/pyanaconda/storage/iscsi.py @@ -102,7 +102,7 @@ class iscsi(object): initiatorname = libiscsi.get_firmware_initiator_name() self._initiator = initiatorname self.initiatorSet = True - except: + except Exception: pass # So that users can write iscsi() to get the singleton instance @@ -130,7 +130,7 @@ class iscsi(object): try: found_nodes = libiscsi.discover_firmware() - except: + except Exception: # an exception here means there is no ibft firmware, just return return @@ -140,7 +140,7 @@ class iscsi(object): log.info("iscsi._startIBFT logged in to %s %s %s" % (node.name, node.address, node.port)) self.nodes.append(node) self.ibftNodes.append(node) - except IOError, e: + except IOError as e: log.error("Could not log into ibft iscsi target %s: %s" % (node.name, str(e))) pass diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py index a0f529a..65902ff 100644 --- a/pyanaconda/storage/partitioning.py +++ b/pyanaconda/storage/partitioning.py @@ -626,7 +626,7 @@ def getBestFreeSpaceRegion(disk, part_type, req_size, # parted.Geometry.overlapsWith can handle this try: free_geom = extended.geometry.intersect(_range) - except ArithmeticError, e: + except ArithmeticError: # this freespace region does not lie within the extended # partition's geometry free_geom = None diff --git a/pyanaconda/storage/zfcp.py b/pyanaconda/storage/zfcp.py index 001fc4c..9622c19 100644 --- a/pyanaconda/storage/zfcp.py +++ b/pyanaconda/storage/zfcp.py @@ -370,7 +370,7 @@ class ZFCP: try: self.addFCP(devnum, wwpn, fcplun) - except ValueError, e: + except ValueError as e: if self.intf: self.intf.messageWindow(_("Error"), str(e)) else: @@ -390,7 +390,7 @@ class ZFCP: for d in self.fcpdevs: try: d.offlineDevice() - except ValueError, e: + except ValueError as e: log.warn(str(e)) def startup(self, intf=None): @@ -409,7 +409,7 @@ class ZFCP: for d in self.fcpdevs: try: d.onlineDevice() - except ValueError, e: + except ValueError as e: log.warn(str(e)) def writeKS(self, f): diff --git a/pyanaconda/textw/add_drive_text.py b/pyanaconda/textw/add_drive_text.py index b558005..72f9b46 100644 --- a/pyanaconda/textw/add_drive_text.py +++ b/pyanaconda/textw/add_drive_text.py @@ -316,19 +316,19 @@ class addDriveDialog(object): if newdrv[choice] == "Add zFCP LUN": try: return self.addZFCPDriveDialog(screen) - except ValueError, e: + except ValueError as e: ButtonChoiceWindow(screen, _("Error"), str(e)) return INSTALL_BACK elif newdrv[choice] == "Add FCoE SAN": try: return self.addFcoeDriveDialog(screen) - except ValueError, e: + except ValueError as e: ButtonChoiceWindow(screen, _("Error"), str(e)) return INSTALL_BACK else: try: return self.addIscsiDriveDialog(screen) - except (ValueError, IOError), e: + except (ValueError, IOError) as e: ButtonChoiceWindow(screen, _("Error"), str(e)) return INSTALL_BACK diff --git a/pyanaconda/textw/keyboard_text.py b/pyanaconda/textw/keyboard_text.py index 324dceb..6200504 100644 --- a/pyanaconda/textw/keyboard_text.py +++ b/pyanaconda/textw/keyboard_text.py @@ -61,7 +61,7 @@ class KeyboardWindow: # FIXME: eventually, kbd.activate will do this try: isys.loadKeymap(keyboards[choice]) - except SystemError, (errno, msg): - log.error("Could not install keymap %s: %s" % (keyboards[choice], msg)) + except SystemError as e: + log.error("Could not install keymap %s: %s" % (keyboards[choice], e)) return INSTALL_OK diff --git a/pyanaconda/textw/netconfig_text.py b/pyanaconda/textw/netconfig_text.py index 7a44516..7f31b84 100644 --- a/pyanaconda/textw/netconfig_text.py +++ b/pyanaconda/textw/netconfig_text.py @@ -275,10 +275,10 @@ class NetworkConfiguratorText: if self.ipv4Method == "v4manual": try: network.sanityCheckIPString(self.ipv4Address) - except network.IPMissing, msg: + except network.IPMissing as msg: self._handleIPMissing(_("IPv4 Address")) return False - except network.IPError, msg: + except network.IPError as msg: self._handleIPError(_("IPv4 Address"), msg) return False @@ -294,7 +294,7 @@ class NetworkConfiguratorText: if self.ipv4Gateway: try: network.sanityCheckIPString(self.ipv4Gateway) - except network.IPError, msg: + except network.IPError as msg: self._handleIPError(_("IPv4 Gateway"), msg) return False @@ -303,7 +303,7 @@ class NetworkConfiguratorText: addr.split() try: network.sanityCheckIPString(addr) - except network.IPError, msg: + except network.IPError as msg: self._handleIPError(_("IPv4 Nameserver"), msg) return False @@ -311,10 +311,10 @@ class NetworkConfiguratorText: if self.ipv6Method == "v6manual": try: network.sanityCheckIPString(self.ipv6Address) - except network.IPMissing, msg: + except network.IPMissing as msg: self._handleIPMissing(_("IPv6 Address")) return False - except network.IPError, msg: + except network.IPError as msg: self._handleIPError(_("IPv6 Address"), msg) return False @@ -330,7 +330,7 @@ class NetworkConfiguratorText: if self.ipv6Gateway: try: network.sanityCheckIPString(self.ipv6Gateway) - except network.IPError, msg: + except network.IPError as msg: self._handleIPError(_("IPv6 Gateway"), msg) return False if self.ipv6Nameserver: @@ -338,7 +338,7 @@ class NetworkConfiguratorText: addr.split() try: network.sanityCheckIPString(addr) - except network.IPError, msg: + except network.IPError as msg: self._handleIPError(_("IPv6 Nameserver"), msg) return False diff --git a/pyanaconda/textw/userauth_text.py b/pyanaconda/textw/userauth_text.py index 090c9d9..b488962 100644 --- a/pyanaconda/textw/userauth_text.py +++ b/pyanaconda/textw/userauth_text.py @@ -78,7 +78,7 @@ class RootPasswordWindow: else: try: cracklib.FascistCheck(entry1.value()) - except ValueError, e: + except ValueError as e: msg = gettext.ldgettext("cracklib", e) ret = anaconda.intf.messageWindow(_("Weak Password"), _("You have provided a weak password: %s\n\n" diff --git a/pyanaconda/upgrade.py b/pyanaconda/upgrade.py index 427e7ff..2402365 100644 --- a/pyanaconda/upgrade.py +++ b/pyanaconda/upgrade.py @@ -308,7 +308,7 @@ def upgradeMountFilesystems(anaconda): if not ctx or ctx == "unlabeled": flags.selinux = False log.info("Disabled SELinux for upgrade based on /.autorelabel") - except Exception, e: + except Exception as e: log.warning("error checking selinux state: %s" %(e,)) def setSteps(anaconda): diff --git a/pyanaconda/users.py b/pyanaconda/users.py index 709c35a..129bda3 100644 --- a/pyanaconda/users.py +++ b/pyanaconda/users.py @@ -42,7 +42,7 @@ def createLuserConf(instPath, algoname='sha512'): log.info("created new libuser.conf at %s with instPath=\"%s\"" % \ (fn,instPath)) fd = open(fn, 'w') - except: + except (OSError, IOError, KeyError): createTmp = True if createTmp: @@ -120,7 +120,7 @@ class Users: self.admin.addGroup(groupEnt) os._exit(0) - except Exception, e: + except Exception as e: log.critical("Error when creating new group: %s" % str(e)) os._exit(1) @@ -195,7 +195,7 @@ class Users: self.admin.modifyGroup(grp) os._exit(0) - except Exception, e: + except Exception as e: log.critical("Error when creating new user: %s" % str(e)) os._exit(1) @@ -223,7 +223,7 @@ class Users: try: if self.admin.lookupUserByName(username): os._exit(0) - except Exception, e: + except Exception as e: log.critical("Error when searching for user: %s" % str(e)) os._exit(1) diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py index 54335be..887df9f 100644 --- a/pyanaconda/vnc.py +++ b/pyanaconda/vnc.py @@ -72,7 +72,7 @@ class VncServer: self.password=pfile.readline().strip() pfile.close() os.unlink(self.pw_init_file) - except: + except (OSError, IOError): self.password="" def setVNCPassword(self): @@ -104,23 +104,20 @@ class VncServer: devices = netinfo.netdevices active_devs = network.getActiveNetDevs() + self.ip = None if active_devs != []: - dev = devices[active_devs[0]] - + devname = devices[active_devs[0]].iface try: - devname = dev.iface ips = (isys.getIPAddresses(devname, version=4) + isys.getIPAddresses(devname, version=6)) - self.ip = ips[0] - log.info("IPs (using first) of device %s: %s" % (devname, ips)) - - if self.ip == "127.0.0.1" or self.ip == "::1": - self.ip = None - except Exception, e: + except Exception as e: log.warning("Got an exception trying to get the self.ip addr " "of %s: %s" % (devname, e)) - else: - self.ip = None + else: + if ips and ips[0] not in ("127.0.0.1", "::1"): + log.info("IPs (using first) of device %s: %s" % (devname, + ips)) + self.ip = ips[0] self.name = network.getDefaultHostname(self.anaconda) ipstr = self.ip @@ -159,14 +156,12 @@ class VncServer: def openlogfile(self): try: - err = os.open(self.log_file, os.O_RDWR | os.O_CREAT) - if err < 0: - sys.stderr.write("error opening %s\n", log) - return None - else: - return err - except: - return None + fd = os.open(self.log_file, os.O_RDWR | os.O_CREAT) + except OSError as e: + sys.stderr.write("error opening %s: %s\n", (self.log_file, e)) + fd = None + + return fd def connectToView(self): """Attempt to connect to self.vncconnecthost""" @@ -225,7 +220,7 @@ class VncServer: "SecurityTypes=None"] try: xvncp = subprocess.Popen(xvnccommand, stdout=self.openlogfile(), stderr=subprocess.STDOUT) - except: + except OSError: stdoutLog.critical("Could not start the VNC server. Aborting.") sys.exit(1) diff --git a/pyanaconda/yuminstall.py b/pyanaconda/yuminstall.py index 6621b70..82fbbf7 100644 --- a/pyanaconda/yuminstall.py +++ b/pyanaconda/yuminstall.py @@ -20,7 +20,7 @@ from flags import flags from errors import * -from ConfigParser import ConfigParser +import ConfigParser import sys import os import os.path @@ -184,11 +184,9 @@ class AnacondaCallback: f = open(fn, 'r') self.openfile = f - except yum.Errors.NoMoreMirrorsRepoError: + except (yum.Errors.NoMoreMirrorsRepoError, IOError): self.ayum._handleFailure(po) - except IOError: - self.ayum._handleFailure(po) - except yum.Errors.RepoError, e: + except yum.Errors.RepoError: continue self.inProgressPo = po @@ -355,7 +353,7 @@ class AnacondaYum(yum.YumBase): try: self.configBaseURL() break - except SystemError, e: + except SystemError as e: self.anaconda.intf.messageWindow(_("Error Setting Up Repository"), _("The following error occurred while setting up the " "installation repository:\n\n%(e)s\n\nPlease provide the " @@ -388,7 +386,7 @@ class AnacondaYum(yum.YumBase): return dev.format.unmount() - except: + except Exception: pass else: if verifyMedia(self.tree, None): @@ -418,7 +416,7 @@ class AnacondaYum(yum.YumBase): dev.format.unmount() dev.eject() - except: + except Exception: self.anaconda.intf.messageWindow(_("Error"), _("Unable to access the disc.")) @@ -653,7 +651,7 @@ class AnacondaYum(yum.YumBase): valid addon repos and if so, return a list of (repo name, repo URL). """ retval = [] - c = ConfigParser() + c = ConfigParser.ConfigParser() # If there's no .treeinfo for this repo, don't bother looking for addons. treeinfo = self._getTreeinfo(baseurl, proxy_url) @@ -663,9 +661,9 @@ class AnacondaYum(yum.YumBase): # We need to know which variant is being installed so we know what addons # are valid options. try: - ConfigParser.read(c, treeinfo) + ConfigParser.ConfigParser.read(c, treeinfo) variant = c.get("general", "variant") - except: + except ConfigParser.Error: return retval section = "variant-%s" % variant @@ -722,16 +720,16 @@ class AnacondaYum(yum.YumBase): read. Since there's no redhat-release package in /mnt/sysimage (and won't be for quite a while), we need to do our own substutition. """ - c = ConfigParser() + c = ConfigParser.ConfigParser() treeinfo = self._getTreeinfo(self._baseRepoURL, self.proxy_url) if not treeinfo: return productVersion - ConfigParser.read(c, treeinfo) + ConfigParser.ConfigParser.read(c, treeinfo) try: return c.get("general", "version") - except: + except ConfigParser.Error: return productVersion # Override this method so yum doesn't nuke our existing logging config. @@ -886,7 +884,7 @@ class AnacondaYum(yum.YumBase): try: self.repos.add(repo) log.info("added repository %s with URL %s" % (repo.name, repo.mirrorlist or repo.baseurl[0])) - except: + except yum.Errors.DuplicateRepoError: log.warning("ignoring duplicate repository %s with URL %s" % (repo.name, repo.mirrorlist or repo.baseurl[0])) self.repos.setCacheDir(self.conf.cachedir) @@ -897,11 +895,9 @@ class AnacondaYum(yum.YumBase): try: yum.YumBase.downloadHeader(self, po) break - except yum.Errors.NoMoreMirrorsRepoError: - self._handleFailure(po) - except IOError: + except (yum.Errors.NoMoreMirrorsRepoError, IOError): self._handleFailure(po) - except yum.Errors.RepoError, e: + except yum.Errors.RepoError: continue def _handleFailure(self, package): @@ -993,7 +989,7 @@ class AnacondaYum(yum.YumBase): self.populateTs(keepold=0) self.dsCallback.pop() self.dsCallback = None - except RepoError, e: + except RepoError as e: msg = _("There was an error running your transaction for " "the following reason: %s\n") % str(e) @@ -1033,7 +1029,7 @@ class AnacondaYum(yum.YumBase): try: self.runTransaction(cb=cb) - except YumBaseError, probs: + except YumBaseError as probs: # FIXME: we need to actually look at these problems... probTypes = { rpm.RPMPROB_NEW_FILE_CONFLICT : _('file conflicts'), rpm.RPMPROB_FILE_CONFLICT : _('file conflicts'), @@ -1310,7 +1306,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon fn(repo) if callback: callback.disconnect() - except RepoError, e: + except RepoError: if callback: callback.disconnect() buttons = [_("_Exit installer"), _("Edit"), _("_Retry")] @@ -1515,7 +1511,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon return DISPATCH_BACK break - except RepoError, e: + except RepoError as e: # FIXME: would be nice to be able to recover here rc = anaconda.intf.messageWindow(_("Error"), _("Unable to read package metadata. This may be " @@ -1574,7 +1570,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon for i in dirList: try: os.mkdir(anaconda.rootPath + i) - except os.error, (errno, msg): + except OSError: pass # log.error("Error making directory %s: %s" % (i, msg)) @@ -1721,14 +1717,14 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon iutil.execWithRedirect("yum", ["clean", "all"], stdout="/dev/tty5", stderr="/dev/tty5", root = anaconda.rootPath) - except: + except RuntimeError: pass # nuke preupgrade if flags.cmdline.has_key("preupgrade") and os.path.exists("%s/var/cache/yum/anaconda-upgrade" %(anaconda.rootPath,)): try: shutil.rmtree("%s/var/cache/yum/anaconda-upgrade" %(anaconda.rootPath,)) - except: + except (OSError, IOError): pass # XXX: write proper lvm config @@ -1754,7 +1750,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon try: grp = self.ayum.comps.return_group(group) if grp.selected: return True - except yum.Errors.GroupsError, e: + except yum.Errors.GroupsError: pass return False @@ -1777,7 +1773,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon mbrs = self.ayum.selectGroup(group, group_package_types=types) if len(mbrs) == 0 and self.isGroupSelected(group): return - except yum.Errors.GroupsError, e: + except yum.Errors.GroupsError: # try to find out if it's the name or translated name gid = self.__getGroupId(group) if gid is not None: @@ -1791,7 +1787,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon def deselectGroup(self, group, *args): try: self.ayum.deselectGroup(group, force=True) - except yum.Errors.GroupsError, e: + except yum.Errors.GroupsError: # try to find out if it's the name or translated name gid = self.__getGroupId(group) if gid is not None: diff --git a/utils/log_picker/sending/ftpsender.py b/utils/log_picker/sending/ftpsender.py index 92f7184..9ecf095 100644 --- a/utils/log_picker/sending/ftpsender.py +++ b/utils/log_picker/sending/ftpsender.py @@ -42,6 +42,6 @@ class FtpSender(SenderBaseClass): ftp.storbinary('STOR %s' % os.path.basename(filename), \ file(filename)) ftp.quit() - except ftplib.all_errors, e: + except ftplib.all_errors as e: raise SenderError("FTP upload failed: %(error)s" % {'error':e}) -- 1.7.3.5 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list