From e3bcfd234622e951d22fbfab631173e7c2a57a6b Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 24 Jan 2013 02:41:26 +0100 Subject: [PATCH] Create all hash objects with hashlib's "new" function. --- python/pakfire/client/builder.py | 2 +- python/pakfire/packages/file.py | 2 +- python/pakfire/packages/packager.py | 4 ++-- python/pakfire/server.py | 3 ++- python/pakfire/util.py | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/python/pakfire/client/builder.py b/python/pakfire/client/builder.py index 9798cc48e..9aefa1c4f 100644 --- a/python/pakfire/client/builder.py +++ b/python/pakfire/client/builder.py @@ -408,7 +408,7 @@ class ClientBuilder(object): # Check if the download checksum matches (if provided). if self.build_source_hash512: - h = hashlib.sha512() + h = hashlib.new("sha512") f = open(tmpfile, "rb") while True: buf = f.read(BUFFER_SIZE) diff --git a/python/pakfire/packages/file.py b/python/pakfire/packages/file.py index 55f969450..990f6f7b3 100644 --- a/python/pakfire/packages/file.py +++ b/python/pakfire/packages/file.py @@ -211,7 +211,7 @@ class FilePackage(base.Package): continue # Calc hash of the current configuration file. - config_hash1 = hashlib.sha512() + config_hash1 = hashlib.new("sha512") f = open(target) while True: buf = f.read(BUFFER_SIZE) diff --git a/python/pakfire/packages/packager.py b/python/pakfire/packages/packager.py index a4566028e..c8e1c7814 100644 --- a/python/pakfire/packages/packager.py +++ b/python/pakfire/packages/packager.py @@ -104,7 +104,7 @@ class Packager(object): # Calculating the hash sum of the added file # and store it in the chksums file. f = open(filename) - h = hashlib.sha512() + h = hashlib.new("sha512") while True: buf = f.read(BUFFER_SIZE) if not buf: @@ -164,7 +164,7 @@ class Packager(object): # Calculate SHA512 hash of regular files. if m.isreg(): mobj = datafile.extractfile(m) - h = hashlib.sha512() + h = hashlib.new("sha512") while True: buf = mobj.read(BUFFER_SIZE) diff --git a/python/pakfire/server.py b/python/pakfire/server.py index 64e3dd519..edc070fd8 100644 --- a/python/pakfire/server.py +++ b/python/pakfire/server.py @@ -82,7 +82,8 @@ class Source(object): @property def path(self): - h = hashlib.sha1(self.url) + h = hashlib.new("sha1") + h.update(self.url) # XXX path is to be changed return "/var/cache/pakfire/sources/%s" % h.hexdigest() diff --git a/python/pakfire/util.py b/python/pakfire/util.py index 9fa011a27..84128cd9c 100644 --- a/python/pakfire/util.py +++ b/python/pakfire/util.py @@ -197,7 +197,7 @@ def format_speed(s): return "%sB/s" % format_size(s) def calc_hash1(filename=None, data=None): - h = hashlib.sha1() + h = hashlib.new("sha1") if filename: f = open(filename) -- 2.39.5