[KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of resorting to internal autotest exception types, use
either python standard exceptions or an internally defined
ConfigError exception.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/kvm_config.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index a3467a0..cce931a 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -8,6 +8,11 @@ KVM configuration file utility functions.
 @copyright: Red Hat 2008-2009
 """
 
+
+class ConfigError(Exception):
+    pass
+
+
 class config:
     """
     Parse an input file or string that follows the KVM Test Config File format
@@ -47,7 +52,7 @@ class config:
             @param filename: Path of the configuration file.
         """
         if not os.path.exists(filename):
-            raise Exception, "File %s not found" % filename
+            raise IOError("File %s not found" % filename)
         self.filename = filename
         file = open(filename, "r")
         self.list = self.parse(file, self.list)
@@ -357,7 +362,7 @@ class config:
                 # (inside an exception or inside subvariants)
                 if restricted:
                     e_msg = "Using variants in this context is not allowed"
-                    raise error.AutotestError()
+                    raise ConfigError(e_msg)
                 if self.debug and not restricted:
                     self.__debug_print(indented_line,
                                      "Entering variants block (%d dicts in"
@@ -402,7 +407,7 @@ class config:
                                             words[1])
                     if not os.path.exists(filename):
                         e_msg = "Cannot include %s -- file not found" % filename
-                        raise error.AutotestError(e_msg)
+                        raise ConfigError(e_msg)
                     new_file = open(filename, "r")
                     list = self.parse(new_file, list, restricted)
                     new_file.close()
@@ -410,7 +415,7 @@ class config:
                         self.__debug_print("", "Leaving file %s" % words[1])
                 else:
                     e_msg = "Cannot include anything because no file is open"
-                    raise error.AutotestError(e_msg)
+                    raise ConfigError(e_msg)
 
             # Parse multi-line exceptions
             # (the block is parsed for each dict separately)
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux