[PATCH] common_lib.cartesian_config: Turn missing includes into fatal errors

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

 



There's no point in including a file not necessary on a
cartesian config file, so it's more likely that the file
missing is actually a harmful problem.

So turn the missing file into a MissingIncludeError and
throw it.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/common_lib/cartesian_config.py |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/client/common_lib/cartesian_config.py b/client/common_lib/cartesian_config.py
index ac04c24..62bc925 100755
--- a/client/common_lib/cartesian_config.py
+++ b/client/common_lib/cartesian_config.py
@@ -28,7 +28,7 @@ Cartesian configuration format file parser.
 @copyright: Red Hat 2008-2011
 """
 
-import re, os, sys, optparse, collections
+import re, os, optparse, collections
 
 class ParserError:
     def __init__(self, msg, line=None, filename=None, linenum=None):
@@ -45,6 +45,17 @@ class ParserError:
             return "%s (%s:%s)" % (self.msg, self.filename, self.linenum)
 
 
+class MissingIncludeError:
+    def __init__(self, line, filename, linenum):
+        self.line = line
+        self.filename = filename
+        self.linenum = linenum
+
+    def __str__(self):
+        return ("%r (%s:%s): file does not exist or it's not a regular "
+                "file" % (self.line, self.filename, self.linenum))
+
+
 num_failed_cases = 5
 
 
@@ -462,8 +473,7 @@ class Parser(object):
                     filename = os.path.join(os.path.dirname(cr.filename),
                                             filename)
                 if not os.path.isfile(filename):
-                    self._warn("%r (%s:%s): file doesn't exist or is not a "
-                               "regular file", line, cr.filename, linenum)
+                    raise MissingIncludeError(line, cr.filename, linenum)
                     continue
                 node = self._parse(FileReader(filename), node)
                 continue
-- 
1.7.7

--
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