summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2009-04-23 13:01:35 -0400
committerChris Lumens <clumens@redhat.com>2009-04-23 14:17:14 -0400
commitcfac7bcb2079b463e33c2401002575d0de12d9b2 (patch)
tree488fb8e49604b3245dca24961fda684888bd56d8
parent11bbfaa2b00d1a212462c689834a9179b15cb843 (diff)
downloadanaconda-cfac7bcb2079b463e33c2401002575d0de12d9b2.tar.gz
anaconda-cfac7bcb2079b463e33c2401002575d0de12d9b2.tar.xz
anaconda-cfac7bcb2079b463e33c2401002575d0de12d9b2.zip
When catching an OSError, handle it as an object instead of a tuple (#497374).
-rw-r--r--firewall.py4
-rw-r--r--iutil.py31
-rw-r--r--livecd.py6
-rw-r--r--packages.py4
-rw-r--r--security.py6
-rw-r--r--storage/__init__.py8
-rw-r--r--syslogd.py8
-rw-r--r--timezone.py4
-rw-r--r--users.py4
-rw-r--r--yuminstall.py4
10 files changed, 38 insertions, 41 deletions
diff --git a/firewall.py b/firewall.py
index ef543e6dd..bc45cb54c 100644
--- a/firewall.py
+++ b/firewall.py
@@ -81,8 +81,8 @@ class Firewall:
log.error("would have run %s", args)
except RuntimeError, msg:
log.error ("lokkit run failed: %s", msg)
- except OSError, (errno, 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-securitylevel', 'w')
diff --git a/iutil.py b/iutil.py
index 0d7faedc7..63e3a0be9 100644
--- a/iutil.py
+++ b/iutil.py
@@ -103,8 +103,8 @@ def execWithRedirect(command, argv, stdin = None, stdout = None,
if proc.returncode is not None:
ret = proc.returncode
break
- except OSError, (errno, msg):
- errstr = "Error running %s: %s" % (command, msg)
+ except OSError as e:
+ errstr = "Error running %s: %s" % (command, e.strerror)
log.error(errstr)
runningLog.write(errstr)
runningLog.close()
@@ -168,9 +168,9 @@ def execWithCapture(command, argv, stdin = None, stderr = None, root='/'):
if proc.returncode is not None:
break
- except OSError, (errno, msg):
- log.error ("Error running " + command + ": " + msg)
- raise RuntimeError, "Error running " + command + ": " + msg
+ except OSError as e:
+ log.error ("Error running " + command + ": " + e.strerror)
+ raise RuntimeError, "Error running " + command + ": " + e.strerror
return rc
@@ -226,10 +226,9 @@ def execWithPulseProgress(command, argv, stdin = None, stdout = None,
while 1:
try:
s = os.read(p[0], 1)
- except OSError, args:
- (num, _str) = args
- if (num != 4):
- raise IOError, args
+ except OSError as e:
+ if e.errno != 4:
+ raise IOError, e.args
os.write(stdout, s)
runningLog.write(s)
@@ -240,8 +239,8 @@ def execWithPulseProgress(command, argv, stdin = None, stdout = None,
try:
(pid, status) = os.waitpid(childpid, 0)
- except OSError, (num, msg):
- log.critical("exception from waitpid: %s %s" %(num, msg))
+ except OSError as e:
+ log.critical("exception from waitpid: %s %s" %(e.errno, e.strerror))
progress and progress.pop()
@@ -259,8 +258,8 @@ def execConsole():
try:
proc = subprocess.Popen(["/bin/sh"])
proc.wait()
- except OSError, (errno, msg):
- raise RuntimeError, "Error running /bin/sh: " + msg
+ except OSError as e:
+ raise RuntimeError, "Error running /bin/sh: " + e.strerror
## Get the size of a directory and all its subdirectories.
# @param dir The name of the directory to find the size of.
@@ -338,14 +337,14 @@ def swapSuggestion(quiet=0):
def mkdirChain(dir):
try:
os.makedirs(dir, 0755)
- except OSError, (errno, msg):
+ except OSError as e:
try:
- if errno == EEXIST and stat.S_ISDIR(os.stat(dir).st_mode):
+ if e.errno == EEXIST and stat.S_ISDIR(os.stat(dir).st_mode):
return
except:
pass
- log.error("could not create directory %s: %s" % (dir, msg))
+ log.error("could not create directory %s: %s" % (dir, e.strerror))
## Get the total amount of swap memory.
# @return The total amount of swap memory in kilobytes, or 0 if unknown.
diff --git a/livecd.py b/livecd.py
index 915c0c178..280434b10 100644
--- a/livecd.py
+++ b/livecd.py
@@ -90,8 +90,8 @@ def copytree(src, dst, symlinks=False, preserveOwner=False,
if preserveSelinux:
selinux.lsetfilecon(dst, selinux.lgetfilecon(src)[1])
shutil.copystat(src, dst)
- except OSError, why:
- errors.extend((src, dst, str(why)))
+ except OSError as e:
+ errors.extend((src, dst, e.strerror))
if errors:
raise Error, errors
@@ -299,7 +299,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
try:
os.rmdir("%s/mnt/%s" %(anaconda.rootPath,
e.format.mountpoint))
- except OSError, e:
+ except OSError as e:
log.debug("error removing %s" %(tocopy,))
for e in [entry] + fsdict[tocopy]:
e.format.setup(chroot=anaconda.rootPath)
diff --git a/packages.py b/packages.py
index 04573263a..a7f5e3212 100644
--- a/packages.py
+++ b/packages.py
@@ -225,8 +225,8 @@ def setupTimezone(anaconda):
else:
try:
shutil.copyfile(tzfile, "/etc/localtime")
- except OSError, (errno, msg):
- log.error("Error copying timezone (from %s): %s" %(tzfile, msg))
+ except OSError as e:
+ log.error("Error copying timezone (from %s): %s" %(tzfile, e.strerror))
if iutil.isS390():
return
diff --git a/security.py b/security.py
index c78428782..bd5c9da32 100644
--- a/security.py
+++ b/security.py
@@ -72,7 +72,5 @@ class Security:
log.info("would have run %s" %(args,))
except RuntimeError, msg:
log.error ("lokkit run failed: %s" %(msg,))
- except OSError, (errno, msg):
- log.error ("lokkit run failed: %s" %(msg,))
-
-
+ except OSError as e:
+ log.error ("lokkit run failed: %s" % e.strerror)
diff --git a/storage/__init__.py b/storage/__init__.py
index 5b6e0f6e2..e7b53f5b6 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -1507,9 +1507,9 @@ class FSSet(object):
try:
device.format.setup(options=options,
chroot=anaconda.rootPath)
- except OSError as (num, msg):
+ except OSError as e:
if intf:
- if num == errno.EEXIST:
+ if e.errno == errno.EEXIST:
intf.messageWindow(_("Invalid mount point"),
_("An error occurred when trying "
"to create %s. Some element of "
@@ -1527,8 +1527,8 @@ class FSSet(object):
"cannot continue.\n\n"
"Press <Enter> to exit the "
"installer.")
- % (device.format.mountpoint, msg))
- log.error("OSError: (%d) %s" % (num, msg) )
+ % (device.format.mountpoint, e.strerror))
+ log.error("OSError: (%d) %s" % (e.errno, e.strerror))
sys.exit(0)
except SystemError as (num, msg):
if raiseErrors:
diff --git a/syslogd.py b/syslogd.py
index 9b95e59f2..267b7fd43 100644
--- a/syslogd.py
+++ b/syslogd.py
@@ -91,13 +91,13 @@ class InstSyslog:
return
try:
os.kill (self.pid, 15)
- except OSError, (num, msg):
- log.error("killing syslogd failed: %s %s" %(num, msg))
+ except OSError as e:
+ log.error("killing syslogd failed: %s %s" %(e.errno, e.strerror))
try:
os.waitpid (self.pid, 0)
- except OSError, (num, msg):
- log.error("exception from waitpid in syslogd::stop: %s %s" % (num, msg))
+ except OSError as e:
+ log.error("exception from waitpid in syslogd::stop: %s %s" % (e.errno, e.strerror))
self.pid = -1
diff --git a/timezone.py b/timezone.py
index f29e9a721..4b2dfbe67 100644
--- a/timezone.py
+++ b/timezone.py
@@ -44,8 +44,8 @@ class Timezone:
else:
try:
shutil.copyfile(fromFile, instPath + "/etc/localtime")
- except OSError, (errno, msg):
- log.error("Error copying timezone (from %s): %s" % (fromFile, msg))
+ except OSError as e:
+ log.error("Error copying timezone (from %s): %s" % (fromFile, e.strerror))
f = open(instPath + "/etc/sysconfig/clock", "w")
diff --git a/users.py b/users.py
index a146aa214..ec9aa051f 100644
--- a/users.py
+++ b/users.py
@@ -145,8 +145,8 @@ class Users:
try:
(pid, status) = os.waitpid(childpid, 0)
- except OSError, (num, msg):
- log.critical("exception from waitpid while creating a user: %s %s" % (num, msg))
+ except OSError as e:
+ log.critical("exception from waitpid while creating a user: %s %s" % (e.errno, e.strerror))
return False
if os.WIFEXITED(status) and (os.WEXITSTATUS(status) == 0):
diff --git a/yuminstall.py b/yuminstall.py
index 753e09969..d097eaa94 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -201,8 +201,8 @@ class AnacondaCallback:
if os.path.dirname(fn).startswith("%s/var/cache/yum/" % self.rootPath):
try:
os.unlink(fn)
- except OSError, e:
- log.debug("unable to remove file %s" %(e,))
+ except OSError as e:
+ log.debug("unable to remove file %s" %(e.strerror,))
self.donepkgs += 1
self.doneSize += self.inProgressPo.returnSimple("installedsize") / 1024.0