]>
Commit | Line | Data |
---|---|---|
91d1c8a9 MT |
1 | From e3bcfd234622e951d22fbfab631173e7c2a57a6b Mon Sep 17 00:00:00 2001 |
2 | From: Michael Tremer <michael.tremer@ipfire.org> | |
3 | Date: Thu, 24 Jan 2013 02:41:26 +0100 | |
4 | Subject: [PATCH 06/17] Create all hash objects with hashlib's "new" function. | |
5 | ||
6 | --- | |
7 | python/pakfire/client/builder.py | 2 +- | |
8 | python/pakfire/packages/file.py | 2 +- | |
9 | python/pakfire/packages/packager.py | 4 ++-- | |
10 | python/pakfire/server.py | 3 ++- | |
11 | python/pakfire/util.py | 2 +- | |
12 | 5 files changed, 7 insertions(+), 6 deletions(-) | |
13 | ||
14 | diff --git a/python/pakfire/client/builder.py b/python/pakfire/client/builder.py | |
15 | index 9798cc4..9aefa1c 100644 | |
16 | --- a/python/pakfire/client/builder.py | |
17 | +++ b/python/pakfire/client/builder.py | |
18 | @@ -408,7 +408,7 @@ class ClientBuilder(object): | |
19 | ||
20 | # Check if the download checksum matches (if provided). | |
21 | if self.build_source_hash512: | |
22 | - h = hashlib.sha512() | |
23 | + h = hashlib.new("sha512") | |
24 | f = open(tmpfile, "rb") | |
25 | while True: | |
26 | buf = f.read(BUFFER_SIZE) | |
27 | diff --git a/python/pakfire/packages/file.py b/python/pakfire/packages/file.py | |
28 | index 55f9694..990f6f7 100644 | |
29 | --- a/python/pakfire/packages/file.py | |
30 | +++ b/python/pakfire/packages/file.py | |
31 | @@ -211,7 +211,7 @@ class FilePackage(base.Package): | |
32 | continue | |
33 | ||
34 | # Calc hash of the current configuration file. | |
35 | - config_hash1 = hashlib.sha512() | |
36 | + config_hash1 = hashlib.new("sha512") | |
37 | f = open(target) | |
38 | while True: | |
39 | buf = f.read(BUFFER_SIZE) | |
40 | diff --git a/python/pakfire/packages/packager.py b/python/pakfire/packages/packager.py | |
41 | index a456602..c8e1c78 100644 | |
42 | --- a/python/pakfire/packages/packager.py | |
43 | +++ b/python/pakfire/packages/packager.py | |
44 | @@ -104,7 +104,7 @@ class Packager(object): | |
45 | # Calculating the hash sum of the added file | |
46 | # and store it in the chksums file. | |
47 | f = open(filename) | |
48 | - h = hashlib.sha512() | |
49 | + h = hashlib.new("sha512") | |
50 | while True: | |
51 | buf = f.read(BUFFER_SIZE) | |
52 | if not buf: | |
53 | @@ -164,7 +164,7 @@ class Packager(object): | |
54 | # Calculate SHA512 hash of regular files. | |
55 | if m.isreg(): | |
56 | mobj = datafile.extractfile(m) | |
57 | - h = hashlib.sha512() | |
58 | + h = hashlib.new("sha512") | |
59 | ||
60 | while True: | |
61 | buf = mobj.read(BUFFER_SIZE) | |
62 | diff --git a/python/pakfire/server.py b/python/pakfire/server.py | |
63 | index 64e3dd5..edc070f 100644 | |
64 | --- a/python/pakfire/server.py | |
65 | +++ b/python/pakfire/server.py | |
66 | @@ -82,7 +82,8 @@ class Source(object): | |
67 | ||
68 | @property | |
69 | def path(self): | |
70 | - h = hashlib.sha1(self.url) | |
71 | + h = hashlib.new("sha1") | |
72 | + h.update(self.url) | |
73 | ||
74 | # XXX path is to be changed | |
75 | return "/var/cache/pakfire/sources/%s" % h.hexdigest() | |
76 | diff --git a/python/pakfire/util.py b/python/pakfire/util.py | |
77 | index 9fa011a..84128cd 100644 | |
78 | --- a/python/pakfire/util.py | |
79 | +++ b/python/pakfire/util.py | |
80 | @@ -197,7 +197,7 @@ def format_speed(s): | |
81 | return "%sB/s" % format_size(s) | |
82 | ||
83 | def calc_hash1(filename=None, data=None): | |
84 | - h = hashlib.sha1() | |
85 | + h = hashlib.new("sha1") | |
86 | ||
87 | if filename: | |
88 | f = open(filename) | |
89 | -- | |
90 | 1.8.1.2 | |
91 |