Author: fw Date: 2009-05-24 20:22:36 +0000 (Sun, 24 May 2009) New Revision: 11971 Modified: lib/python/debian_support.py Log: lib/python/debian_support.py (updateFile): fix the fix Also support both the hashlib and sha modules. Modified: lib/python/debian_support.py ==================================================================--- lib/python/debian_support.py 2009-05-24 20:18:48 UTC (rev 11970) +++ lib/python/debian_support.py 2009-05-24 20:22:36 UTC (rev 11971) @@ -17,11 +17,16 @@ """This module implements facilities to deal with Debian-specific metadata.""" +import types import os import re -import hashlib -import types +try: + import sha + sha = sha.new +except ImportError: + from hashlib import sha + import apt_pkg apt_pkg.init() @@ -185,7 +190,7 @@ del listReleases def readLinesSHA1(lines): - m = hashlib.sha() + m = sha() for l in lines: m.update(l) return m.hexdigest() @@ -391,8 +396,8 @@ if new_hash <> remote_hash: if verbose: print "updateFile: patch failed, got %s instead of %s" \ - % (new_hash, remote_hash)) - return return downloadFile(remote, local) + % (new_hash, remote_hash) + return downloadFile(remote, local) replaceFile(lines, local) return lines