diff mbox

[KVM-AUTOTEST,v2,06/11] KVM test: kvm_config.py: do not fail when including a nonexistent file

Message ID 5fbc30f0d24e3d4b12b93f40fe14264e5963048c.1250091576.git.mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Aug. 12, 2009, 3:59 p.m. UTC
Instead of failing, just print a warning.  Included files may not always be
crucial for tests to run (kvm_cdkeys.cfg for example).

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_config.py |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index e478a55..7ff7a07 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -406,17 +406,18 @@  class config:
                 if self.filename:
                     filename = os.path.join(os.path.dirname(self.filename),
                                             words[1])
-                    if not os.path.exists(filename):
-                        e_msg = "Cannot include %s -- file not found" % filename
-                        raise error.AutotestError(e_msg)
-                    new_file = open(filename, "r")
-                    list = self.parse(new_file, list, restricted)
-                    new_file.close()
-                    if self.debug and not restricted:
-                        self.__debug_print("", "Leaving file %s" % words[1])
+                    if os.path.exists(filename):
+                        new_file = open(filename, "r")
+                        list = self.parse(new_file, list, restricted)
+                        new_file.close()
+                        if self.debug and not restricted:
+                            self.__debug_print("", "Leaving file %s" % words[1])
+                    else:
+                        print ("WARNING: Cannot include %s -- "
+                               "file not found" % filename)
                 else:
-                    e_msg = "Cannot include anything because no file is open"
-                    raise error.AutotestError(e_msg)
+                    print ("WARNING: Cannot include %s because no file is "
+                           "currently open" % words[1])
 
             # Parse multi-line exceptions
             # (the block is parsed for each dict separately)