From patchwork Wed Aug 12 15:59:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 40910 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7CFwLLU005478 for ; Wed, 12 Aug 2009 15:58:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754033AbZHLP51 (ORCPT ); Wed, 12 Aug 2009 11:57:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754031AbZHLP51 (ORCPT ); Wed, 12 Aug 2009 11:57:27 -0400 Received: from mx2.redhat.com ([66.187.237.31]:42765 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754024AbZHLP5Z (ORCPT ); Wed, 12 Aug 2009 11:57:25 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7CFvQRs005540; Wed, 12 Aug 2009 11:57:26 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n7CFvPJY004549; Wed, 12 Aug 2009 11:57:25 -0400 Received: from localhost.localdomain (dhcp-1-31.tlv.redhat.com [10.35.1.31]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n7CFvFCI029667; Wed, 12 Aug 2009 11:57:24 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH v2 06/11] KVM test: kvm_config.py: do not fail when including a nonexistent file Date: Wed, 12 Aug 2009 18:59:58 +0300 Message-Id: <5fbc30f0d24e3d4b12b93f40fe14264e5963048c.1250091576.git.mgoldish@redhat.com> In-Reply-To: <05eac6f84757616309273b01ac4d8800efbdb083.1250091576.git.mgoldish@redhat.com> References: <1250092803-32477-1-git-send-email-mgoldish@redhat.com> <10a541e518180735e86a4dbc8e759912d0ec314c.1250091576.git.mgoldish@redhat.com> <42ceeed70c7c1ec9f4d78d91d67a290f3ac11e6e.1250091576.git.mgoldish@redhat.com> <8284ff0173612b63412132bb8c864f2c8a258b55.1250091576.git.mgoldish@redhat.com> <05eac6f84757616309273b01ac4d8800efbdb083.1250091576.git.mgoldish@redhat.com> In-Reply-To: <10a541e518180735e86a4dbc8e759912d0ec314c.1250091576.git.mgoldish@redhat.com> References: <10a541e518180735e86a4dbc8e759912d0ec314c.1250091576.git.mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- client/tests/kvm/kvm_config.py | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) 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)