From patchwork Fri Jan 29 05:36:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 75654 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 o0T5aDiu025228 for ; Fri, 29 Jan 2010 05:36:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750996Ab0A2FgK (ORCPT ); Fri, 29 Jan 2010 00:36:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751108Ab0A2FgK (ORCPT ); Fri, 29 Jan 2010 00:36:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16539 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750950Ab0A2FgJ (ORCPT ); Fri, 29 Jan 2010 00:36:09 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0T5a8qk018001 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 29 Jan 2010 00:36:08 -0500 Received: from localhost.localdomain (vpn-11-140.rdu.redhat.com [10.11.11.140]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0T5a5AX009461; Fri, 29 Jan 2010 00:36:06 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: Fixing sha/md5 deprecation messages Date: Fri, 29 Jan 2010 03:36:03 -0200 Message-Id: <1264743363-11136-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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]); Fri, 29 Jan 2010 05:36:14 +0000 (UTC) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index 5452026..b1f184e 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -4,10 +4,14 @@ KVM test utility functions. @copyright: 2008-2009 Red Hat Inc. """ -import md5, sha, thread, subprocess, time, string, random, socket, os, signal +import thread, subprocess, time, string, random, socket, os, signal +try: + import hashlib +except ImportError: + import md5, sha import select, re, logging, commands, cPickle, pty from autotest_lib.client.bin import utils -from autotest_lib.client.common_lib import error +from autotest_lib.client.common_lib import error, logging_config import kvm_subprocess @@ -789,9 +793,15 @@ def hash_file(filename, size=None, method="md5"): f = open(filename, 'rb') if method == "md5": - hash = md5.new() + try: + hash = hashlib.new('md5') + except NameError: + hash = md5.new() elif method == "sha1": - hash = sha.new() + try: + hash = hashlib.new('sha1') + except NameError: + hash = sha.new() else: logging.error("Unknown hash type %s, returning None" % method) return None diff --git a/client/tests/kvm/ppm_utils.py b/client/tests/kvm/ppm_utils.py index 8ff31da..aaea298 100644 --- a/client/tests/kvm/ppm_utils.py +++ b/client/tests/kvm/ppm_utils.py @@ -4,8 +4,11 @@ Utility functions to deal with ppm (qemu screendump format) files. @copyright: Red Hat 2008-2009 """ -import md5, os, struct, time, re - +import os, struct, time, re +try: + import hashlib +except ImportError: + import md5 # Some directory/filename utils, for consistency @@ -120,7 +123,10 @@ def image_md5sum(width, height, data): @data: PPM file data """ header = "P6\n%d %d\n255\n" % (width, height) - md5obj = md5.new(header) + try: + md5obj = hashlib.md5(header) + except NameError: + md5obj = md5.new(header) md5obj.update(data) return md5obj.hexdigest() diff --git a/client/tests/kvm/tests/steps.py b/client/tests/kvm/tests/steps.py index 456fb44..8ebe7c1 100644 --- a/client/tests/kvm/tests/steps.py +++ b/client/tests/kvm/tests/steps.py @@ -4,7 +4,7 @@ Utilities to perform automatic guest installation using step files. @copyright: Red Hat 2008-2009 """ -import os, time, md5, re, shutil, logging +import os, time, re, shutil, logging from autotest_lib.client.common_lib import utils, error import kvm_utils, ppm_utils, kvm_subprocess try: