1 |
This has the nice side-effect of not needing the verbose param anymore, |
2 |
so the prototypes & callers all get updated to stop passing that around. |
3 |
--- |
4 |
catalyst/base/genbase.py | 6 ++---- |
5 |
catalyst/base/stagebase.py | 6 ++---- |
6 |
catalyst/hash_utils.py | 24 +++++++++--------------- |
7 |
catalyst/targets/stage2.py | 3 +-- |
8 |
4 files changed, 14 insertions(+), 25 deletions(-) |
9 |
|
10 |
diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py |
11 |
index 32459b4..a33f924 100644 |
12 |
--- a/catalyst/base/genbase.py |
13 |
+++ b/catalyst/base/genbase.py |
14 |
@@ -48,13 +48,11 @@ class GenBase(object): |
15 |
if os.path.exists(f): |
16 |
if "all" in array: |
17 |
for k in list(hash_map.hash_map): |
18 |
- digest = hash_map.generate_hash(f,hash_=k, |
19 |
- verbose=self.settings["VERBOSE"]) |
20 |
+ digest = hash_map.generate_hash(f, hash_=k) |
21 |
myf.write(digest) |
22 |
else: |
23 |
for j in array: |
24 |
- digest = hash_map.generate_hash(f,hash_=j, |
25 |
- verbose=self.settings["VERBOSE"]) |
26 |
+ digest = hash_map.generate_hash(f, hash_=j) |
27 |
myf.write(digest) |
28 |
myf.close() |
29 |
|
30 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py |
31 |
index bffafb7..88d71ba 100644 |
32 |
--- a/catalyst/base/stagebase.py |
33 |
+++ b/catalyst/base/stagebase.py |
34 |
@@ -435,8 +435,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
35 |
self.settings["source_path_hash"] = \ |
36 |
self.settings["hash_map"].generate_hash( |
37 |
self.settings["source_path"], |
38 |
- hash_ = self.settings["hash_function"], |
39 |
- verbose = False) |
40 |
+ hash_=self.settings["hash_function"]) |
41 |
print "Source path set to "+self.settings["source_path"] |
42 |
if os.path.isdir(self.settings["source_path"]): |
43 |
print "\tIf this is not desired, remove this directory or turn off" |
44 |
@@ -464,8 +463,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
45 |
self.settings["snapshot_path_hash"] = \ |
46 |
self.settings["hash_map"].generate_hash( |
47 |
self.settings["snapshot_path"], |
48 |
- hash_ = self.settings["hash_function"], |
49 |
- verbose = False) |
50 |
+ hash_=self.settings["hash_function"]) |
51 |
|
52 |
def set_snapcache_path(self): |
53 |
self.settings["snapshot_cache_path"]=\ |
54 |
diff --git a/catalyst/hash_utils.py b/catalyst/hash_utils.py |
55 |
index 0262422..3db61f1 100644 |
56 |
--- a/catalyst/hash_utils.py |
57 |
+++ b/catalyst/hash_utils.py |
58 |
@@ -3,6 +3,7 @@ import os |
59 |
from collections import namedtuple |
60 |
from subprocess import Popen, PIPE |
61 |
|
62 |
+from catalyst import log |
63 |
from catalyst.support import CatalystError |
64 |
|
65 |
|
66 |
@@ -65,32 +66,28 @@ class HashMap(object): |
67 |
del obj |
68 |
|
69 |
|
70 |
- def generate_hash(self, file_, hash_="crc32", verbose=False): |
71 |
+ def generate_hash(self, file_, hash_="crc32"): |
72 |
'''Prefered method of generating a hash for the passed in file_ |
73 |
|
74 |
@param file_: the file to generate the hash for |
75 |
@param hash_: the hash algorythm to use |
76 |
- @param verbose: boolean |
77 |
@returns the hash result |
78 |
''' |
79 |
try: |
80 |
return getattr(self, self.hash_map[hash_].func)( |
81 |
file_, |
82 |
- hash_, |
83 |
- verbose |
84 |
- ) |
85 |
+ hash_) |
86 |
except: |
87 |
raise CatalystError("Error generating hash, is appropriate " + \ |
88 |
"utility installed on your system?", traceback=True) |
89 |
|
90 |
|
91 |
- def calc_hash(self, file_, hash_, verbose=False): |
92 |
+ def calc_hash(self, file_, hash_): |
93 |
''' |
94 |
Calculate the hash for "file_" |
95 |
|
96 |
@param file_: the file to generate the hash for |
97 |
@param hash_: the hash algorythm to use |
98 |
- @param verbose: boolean |
99 |
@returns the hash result |
100 |
''' |
101 |
_hash = self.hash_map[hash_] |
102 |
@@ -101,36 +98,33 @@ class HashMap(object): |
103 |
mylines = source.communicate()[0] |
104 |
mylines=mylines[0].split() |
105 |
result=mylines[0] |
106 |
- if verbose: |
107 |
- print _hash.id + " (%s) = %s" % (file_, result) |
108 |
+ log.info('%s (%s) = %s', _hash.id, file_, result) |
109 |
return result |
110 |
|
111 |
|
112 |
- def calc_hash2(self, file_, hash_type, verbose=False): |
113 |
+ def calc_hash2(self, file_, hash_type): |
114 |
''' |
115 |
Calculate the hash for "file_" |
116 |
|
117 |
@param file_: the file to generate the hash for |
118 |
@param hash_: the hash algorythm to use |
119 |
- @param verbose: boolean |
120 |
@returns the hash result |
121 |
''' |
122 |
_hash = self.hash_map[hash_type] |
123 |
args = [_hash.cmd] |
124 |
args.extend(_hash.args) |
125 |
args.append(file_) |
126 |
- #print("DEBUG: calc_hash2; args =", args) |
127 |
+ log.debug('args = %r', args) |
128 |
source = Popen(args, stdout=PIPE) |
129 |
output = source.communicate() |
130 |
lines = output[0].split('\n') |
131 |
- #print("DEBUG: calc_hash2; output =", output) |
132 |
+ log.debug('output = %s', output) |
133 |
header = lines[0] |
134 |
h_f = lines[1].split() |
135 |
hash_result = h_f[0] |
136 |
short_file = os.path.split(h_f[1])[1] |
137 |
result = header + "\n" + hash_result + " " + short_file + "\n" |
138 |
- if verbose: |
139 |
- print header + " (%s) = %s" % (short_file, result) |
140 |
+ log.info('%s (%s) = %s', header, short_file, result) |
141 |
return result |
142 |
|
143 |
|
144 |
diff --git a/catalyst/targets/stage2.py b/catalyst/targets/stage2.py |
145 |
index e6965cc..786aaa4 100644 |
146 |
--- a/catalyst/targets/stage2.py |
147 |
+++ b/catalyst/targets/stage2.py |
148 |
@@ -29,8 +29,7 @@ class stage2(StageBase): |
149 |
self.settings["source_path_hash"] = \ |
150 |
self.settings["hash_map"].generate_hash( |
151 |
self.settings["source_path"],\ |
152 |
- hash_=self.settings["hash_function"], |
153 |
- verbose=False) |
154 |
+ hash_=self.settings["hash_function"]) |
155 |
print "Source path set to "+self.settings["source_path"] |
156 |
if os.path.isdir(self.settings["source_path"]): |
157 |
print "\tIf this is not desired, remove this directory or turn off seedcache in the options of catalyst.conf" |
158 |
-- |
159 |
2.5.2 |