From patchwork Mon Mar 22 02:43:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 87329 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2M2iYAk010886 for ; Mon, 22 Mar 2010 02:44:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753799Ab0CVCob (ORCPT ); Sun, 21 Mar 2010 22:44:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26597 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753655Ab0CVCo2 (ORCPT ); Sun, 21 Mar 2010 22:44:28 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2M2iRWQ032233 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 21 Mar 2010 22:44:28 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2M2iR5q017789; Sun, 21 Mar 2010 22:44:27 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o2M2iMqH031710; Sun, 21 Mar 2010 22:44:26 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 3/5] KVM test: kvm_utils.load_env(): do not fail if env file is corrupted Date: Mon, 22 Mar 2010 04:43:15 +0200 Message-Id: <1269225797-11827-3-git-send-email-mgoldish@redhat.com> In-Reply-To: <1269225797-11827-2-git-send-email-mgoldish@redhat.com> References: <1269225797-11827-1-git-send-email-mgoldish@redhat.com> <1269225797-11827-2-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 22 Mar 2010 02:44:34 +0000 (UTC) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index d386456..cc39b5d 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -22,7 +22,7 @@ def dump_env(obj, filename): file.close() -def load_env(filename, default=None): +def load_env(filename, default={}): """ Load KVM test environment from an environment file. @@ -30,11 +30,13 @@ def load_env(filename, default=None): """ try: file = open(filename, "r") + obj = cPickle.load(file) + file.close() + return obj + # Almost any exception can be raised during unpickling, so let's catch + # them all except: return default - obj = cPickle.load(file) - file.close() - return obj def get_sub_dict(dict, name):