summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2008-06-09 13:09:26 -0400
committerChris Lumens <clumens@redhat.com>2008-06-09 13:09:26 -0400
commitb9d746813a6c296338d55c8ccfba0d71b4838cc1 (patch)
tree78195604768ed3b644096205df1ebf1cf7fc48a2
parent9aa6eb4d890539c18e2e2fcf61c1583d71bed05f (diff)
downloadanaconda-b9d746813a6c296338d55c8ccfba0d71b4838cc1.tar.gz
anaconda-b9d746813a6c296338d55c8ccfba0d71b4838cc1.tar.xz
anaconda-b9d746813a6c296338d55c8ccfba0d71b4838cc1.zip
Move all the exceptions into a single file.
-rw-r--r--autopart.py2
-rw-r--r--errors.py150
-rw-r--r--lvm.py2
-rw-r--r--lvmErrors.py118
-rw-r--r--partErrors.py49
-rw-r--r--partedUtils.py2
-rw-r--r--partitions.py2
7 files changed, 154 insertions, 171 deletions
diff --git a/autopart.py b/autopart.py
index 9d8cac8e4..490ec1f64 100644
--- a/autopart.py
+++ b/autopart.py
@@ -31,7 +31,7 @@ import cryptodev
import partedUtils
import partRequests
from constants import *
-from partErrors import *
+from errors import *
import iutil
import isys
diff --git a/errors.py b/errors.py
index fd8b5805e..b0f663c4d 100644
--- a/errors.py
+++ b/errors.py
@@ -1,3 +1,153 @@
+#
+# errors.py: exception classes used throughout anaconda
+#
+# Copyright (C) 2002, 2007, 2008 Red Hat, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author(s): Peter Jones <pjones@redhat.com>
+# Chris Lumens <clumens@redhat.com>
+# Matt Wilson <msw@redhat.com>
+# Jeremy Katz <katzj@redhat.com>
+# Mike Fulbright <msf@redhat.com>
+#
+
+import string
+from lvm import output
+
+"""Exceptions for use in lvm operations."""
+
+class LvmError(Exception):
+ """An error occurred with lvm."""
+ def __init__(self, command, name=None):
+ self.command = command
+ self.name = name
+ self.log = self.getLvmOutput()
+
+ def getLvmOutput(self):
+ f = open(output, "r")
+ lines = reduce(lambda x,y: x + [string.strip(y),], f.readlines(), [])
+ lines = string.join(reduce(lambda x,y: x + [" %s" % (y,)], \
+ lines, []), "\n")
+ return lines
+
+ def __str__(self):
+ s = ""
+ if not self.name is None:
+ s = " for device %s" % (self.name,)
+ return "%s failed%s\nLog:\n%s" % (self.command, s, self.log)
+
+class LVCreateError(LvmError):
+ def __init__(self, vgname, lvname, size):
+ self.vgname = vgname
+ self.lvname = lvname
+ self.size = size
+ self.log = self.getLvmOutput()
+
+ def __str__(self):
+ return "lvcreate of %d Megabyte lv \"%s\" on vg \"%s\" failed\n" \
+ "Log:\n%s" % ( \
+ self.size, self.lvname, self.vgname, self.log)
+
+class LVRemoveError(LvmError):
+ def __init__(self, vgname, lvname):
+ self.vgname = vgname
+ self.lvname = lvname
+ self.log = self.getLvmOutput()
+
+ def __str__(self):
+ return "lvremove of lv \"%s\" from vg \"%s\" failed\nLog:\n%s" % ( \
+ self.lvname, self.vgname, self.log)
+
+class LVResizeError(LvmError):
+ def __init__(self, vgname, lvname):
+ self.vgname = vgname
+ self.lvname = lvname
+ self.log = self.getLvmOutput()
+
+ def __str__(self):
+ return "lvresize of lv \"%s\" from vg \"%s\" failed\nLog:\n%s" % ( \
+ self.lvname, self.vgname, self.log)
+
+class VGCreateError(LvmError):
+ def __init__(self, vgname, PESize, nodes):
+ self.vgname = vgname
+ self.PESize = PESize
+ self.nodes = nodes
+ self.log = self.getLvmOutput()
+
+ def __str__(self):
+ nodes = string.join(self.nodes, ' ')
+ return "vgcreate failed creating vg \"%s\" (PESize=%dkB) on PVs: %s\n" \
+ "Log:\n%s" % ( \
+ self.vgname, self.PESize, nodes, self.log)
+
+class VGRemoveError(LvmError):
+ def __init__(self, vgname):
+ self.vgname = vgname
+ self.log = self.getLvmOutput()
+
+ def __str__(self):
+ return "vgremove of vg \"%s\" failed\nLog:\n%s" % ( \
+ self.vgname, self.log)
+
+class PVRemoveError(LvmError):
+ def __init__(self, pvname):
+ self.pvname = pvname
+ self.log = self.getLvmOutput()
+
+ def __str__(self):
+ return "pvremove of pv \"%s\" failed\nLog:\n%s" % ( \
+ self.pvname, self.log)
+
+class PVCreateError(LvmError):
+ def __init__(self, pvname):
+ self.pvname = pvname
+ self.log = self.getLvmOutput()
+
+ def __str__(self):
+ return "pvcreate of pv \"%s\" failed\nLog:\n%s" % ( \
+ self.pvname, self.log)
+
+"""Exceptions for use in partitioning."""
+
+class PartitioningError(Exception):
+ """A critical error which must be resolved to continue the installation."""
+ def __init__(self, message=""):
+ self.message = str(message)
+
+ def __str__ (self):
+ return self.message
+
+class PartitioningWarning(Exception):
+ """A warning which may be ignored and still complete the installation."""
+ def __init__(self, message=""):
+ self.message = str(message)
+
+ def __str__ (self):
+ return self.message
+
+class LabelError(Exception):
+ """The device could not be labeled."""
+ def __init__(self, message=""):
+ self.message = str(message)
+
+ def __str__(self):
+ return self.message
+
+"""Exceptions for use in package selection."""
+
class NoSuchGroup(Exception):
def __init__ (self, value):
self.value = value
diff --git a/lvm.py b/lvm.py
index 1adb45691..6d8e7cc2b 100644
--- a/lvm.py
+++ b/lvm.py
@@ -38,7 +38,7 @@ output = "/tmp/lvmout"
lvmDevicePresent = 0
-from lvmErrors import *
+from errors import *
def has_lvm():
global lvmDevicePresent
diff --git a/lvmErrors.py b/lvmErrors.py
deleted file mode 100644
index 1a122711f..000000000
--- a/lvmErrors.py
+++ /dev/null
@@ -1,118 +0,0 @@
-#
-# lvmErrors.py: lvm error exceptions
-#
-# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Author(s): Peter Jones <pjones@redhat.com>
-#
-
-"""Exceptions for use in lvm operations."""
-
-import string
-from lvm import output
-
-class LvmError(Exception):
- """An error occurred with lvm."""
- def __init__(self, command, name=None):
- self.command = command
- self.name = name
- self.log = self.getLvmOutput()
-
- def getLvmOutput(self):
- f = open(output, "r")
- lines = reduce(lambda x,y: x + [string.strip(y),], f.readlines(), [])
- lines = string.join(reduce(lambda x,y: x + [" %s" % (y,)], \
- lines, []), "\n")
- return lines
-
- def __str__(self):
- s = ""
- if not self.name is None:
- s = " for device %s" % (self.name,)
- return "%s failed%s\nLog:\n%s" % (self.command, s, self.log)
-
-class LVCreateError(LvmError):
- def __init__(self, vgname, lvname, size):
- self.vgname = vgname
- self.lvname = lvname
- self.size = size
- self.log = self.getLvmOutput()
-
- def __str__(self):
- return "lvcreate of %d Megabyte lv \"%s\" on vg \"%s\" failed\n" \
- "Log:\n%s" % ( \
- self.size, self.lvname, self.vgname, self.log)
-
-class LVRemoveError(LvmError):
- def __init__(self, vgname, lvname):
- self.vgname = vgname
- self.lvname = lvname
- self.log = self.getLvmOutput()
-
- def __str__(self):
- return "lvremove of lv \"%s\" from vg \"%s\" failed\nLog:\n%s" % ( \
- self.lvname, self.vgname, self.log)
-
-class LVResizeError(LvmError):
- def __init__(self, vgname, lvname):
- self.vgname = vgname
- self.lvname = lvname
- self.log = self.getLvmOutput()
-
- def __str__(self):
- return "lvresize of lv \"%s\" from vg \"%s\" failed\nLog:\n%s" % ( \
- self.lvname, self.vgname, self.log)
-
-class VGCreateError(LvmError):
- def __init__(self, vgname, PESize, nodes):
- self.vgname = vgname
- self.PESize = PESize
- self.nodes = nodes
- self.log = self.getLvmOutput()
-
- def __str__(self):
- nodes = string.join(self.nodes, ' ')
- return "vgcreate failed creating vg \"%s\" (PESize=%dkB) on PVs: %s\n" \
- "Log:\n%s" % ( \
- self.vgname, self.PESize, nodes, self.log)
-
-class VGRemoveError(LvmError):
- def __init__(self, vgname):
- self.vgname = vgname
- self.log = self.getLvmOutput()
-
- def __str__(self):
- return "vgremove of vg \"%s\" failed\nLog:\n%s" % ( \
- self.vgname, self.log)
-
-class PVRemoveError(LvmError):
- def __init__(self, pvname):
- self.pvname = pvname
- self.log = self.getLvmOutput()
-
- def __str__(self):
- return "pvremove of pv \"%s\" failed\nLog:\n%s" % ( \
- self.pvname, self.log)
-
-class PVCreateError(LvmError):
- def __init__(self, pvname):
- self.pvname = pvname
- self.log = self.getLvmOutput()
-
- def __str__(self):
- return "pvcreate of pv \"%s\" failed\nLog:\n%s" % ( \
- self.pvname, self.log)
-
diff --git a/partErrors.py b/partErrors.py
deleted file mode 100644
index ed6f16f41..000000000
--- a/partErrors.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# partErrors.py: partitioning error exceptions
-#
-# Copyright (C) 2002 Red Hat, Inc. All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Author(s): Matt Wilson <msw@redhat.com>
-# Jeremy Katz <katzj@redhat.com>
-# Mike Fulbright <msf@redhat.com>
-#
-
-"""Exceptions for use in partitioning."""
-
-
-class PartitioningError(Exception):
- """A critical error which must be resolved to continue the installation."""
- def __init__(self, message=""):
- self.message = str(message)
-
- def __str__ (self):
- return self.message
-
-class PartitioningWarning(Exception):
- """A warning which may be ignored and still complete the installation."""
- def __init__(self, message=""):
- self.message = str(message)
-
- def __str__ (self):
- return self.message
-
-class LabelError(Exception):
- """The device could not be labeled."""
- def __init__(self, message=""):
- self.message = str(message)
-
- def __str__(self):
- return self.message
diff --git a/partedUtils.py b/partedUtils.py
index 81d78c787..215ac9087 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -39,7 +39,7 @@ import block
import lvm
import traceback
from flags import flags
-from partErrors import *
+from errors import *
from constants import *
import logging
diff --git a/partitions.py b/partitions.py
index d65c86a81..785a85d59 100644
--- a/partitions.py
+++ b/partitions.py
@@ -34,7 +34,7 @@ import sys
from constants import *
from flags import flags
-from partErrors import *
+from errors import *
import fsset
import raid