aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-10-09 09:27:46 -0400
committerMike Frysinger <vapier@gentoo.org>2015-10-09 09:27:46 -0400
commit5048aad7bdfbfcc0e7e3562a80fc97a344818b55 (patch)
treee60066c7c6ba36e3cd92853cb470215c5476b30d
parentcontents: punt unused module (diff)
downloadcatalyst-5048aad7bdfbfcc0e7e3562a80fc97a344818b55.tar.gz
catalyst-5048aad7bdfbfcc0e7e3562a80fc97a344818b55.tar.bz2
catalyst-5048aad7bdfbfcc0e7e3562a80fc97a344818b55.zip
hash_utils: convert to log module
This has the nice side-effect of not needing the verbose param anymore, so the prototypes & callers all get updated to stop passing that around.
-rw-r--r--catalyst/base/genbase.py6
-rw-r--r--catalyst/base/stagebase.py6
-rw-r--r--catalyst/hash_utils.py24
-rw-r--r--catalyst/targets/stage2.py3
4 files changed, 14 insertions, 25 deletions
diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index 32459b46..a33f9240 100644
--- a/catalyst/base/genbase.py
+++ b/catalyst/base/genbase.py
@@ -48,13 +48,11 @@ class GenBase(object):
if os.path.exists(f):
if "all" in array:
for k in list(hash_map.hash_map):
- digest = hash_map.generate_hash(f,hash_=k,
- verbose=self.settings["VERBOSE"])
+ digest = hash_map.generate_hash(f, hash_=k)
myf.write(digest)
else:
for j in array:
- digest = hash_map.generate_hash(f,hash_=j,
- verbose=self.settings["VERBOSE"])
+ digest = hash_map.generate_hash(f, hash_=j)
myf.write(digest)
myf.close()
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index bffafb7d..88d71ba8 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -435,8 +435,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["source_path_hash"] = \
self.settings["hash_map"].generate_hash(
self.settings["source_path"],
- hash_ = self.settings["hash_function"],
- verbose = False)
+ hash_=self.settings["hash_function"])
print "Source path set to "+self.settings["source_path"]
if os.path.isdir(self.settings["source_path"]):
print "\tIf this is not desired, remove this directory or turn off"
@@ -464,8 +463,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["snapshot_path_hash"] = \
self.settings["hash_map"].generate_hash(
self.settings["snapshot_path"],
- hash_ = self.settings["hash_function"],
- verbose = False)
+ hash_=self.settings["hash_function"])
def set_snapcache_path(self):
self.settings["snapshot_cache_path"]=\
diff --git a/catalyst/hash_utils.py b/catalyst/hash_utils.py
index 02624221..3db61f16 100644
--- a/catalyst/hash_utils.py
+++ b/catalyst/hash_utils.py
@@ -3,6 +3,7 @@ import os
from collections import namedtuple
from subprocess import Popen, PIPE
+from catalyst import log
from catalyst.support import CatalystError
@@ -65,32 +66,28 @@ class HashMap(object):
del obj
- def generate_hash(self, file_, hash_="crc32", verbose=False):
+ def generate_hash(self, file_, hash_="crc32"):
'''Prefered method of generating a hash for the passed in file_
@param file_: the file to generate the hash for
@param hash_: the hash algorythm to use
- @param verbose: boolean
@returns the hash result
'''
try:
return getattr(self, self.hash_map[hash_].func)(
file_,
- hash_,
- verbose
- )
+ hash_)
except:
raise CatalystError("Error generating hash, is appropriate " + \
"utility installed on your system?", traceback=True)
- def calc_hash(self, file_, hash_, verbose=False):
+ def calc_hash(self, file_, hash_):
'''
Calculate the hash for "file_"
@param file_: the file to generate the hash for
@param hash_: the hash algorythm to use
- @param verbose: boolean
@returns the hash result
'''
_hash = self.hash_map[hash_]
@@ -101,36 +98,33 @@ class HashMap(object):
mylines = source.communicate()[0]
mylines=mylines[0].split()
result=mylines[0]
- if verbose:
- print _hash.id + " (%s) = %s" % (file_, result)
+ log.info('%s (%s) = %s', _hash.id, file_, result)
return result
- def calc_hash2(self, file_, hash_type, verbose=False):
+ def calc_hash2(self, file_, hash_type):
'''
Calculate the hash for "file_"
@param file_: the file to generate the hash for
@param hash_: the hash algorythm to use
- @param verbose: boolean
@returns the hash result
'''
_hash = self.hash_map[hash_type]
args = [_hash.cmd]
args.extend(_hash.args)
args.append(file_)
- #print("DEBUG: calc_hash2; args =", args)
+ log.debug('args = %r', args)
source = Popen(args, stdout=PIPE)
output = source.communicate()
lines = output[0].split('\n')
- #print("DEBUG: calc_hash2; output =", output)
+ log.debug('output = %s', output)
header = lines[0]
h_f = lines[1].split()
hash_result = h_f[0]
short_file = os.path.split(h_f[1])[1]
result = header + "\n" + hash_result + " " + short_file + "\n"
- if verbose:
- print header + " (%s) = %s" % (short_file, result)
+ log.info('%s (%s) = %s', header, short_file, result)
return result
diff --git a/catalyst/targets/stage2.py b/catalyst/targets/stage2.py
index e6965cc4..786aaa40 100644
--- a/catalyst/targets/stage2.py
+++ b/catalyst/targets/stage2.py
@@ -29,8 +29,7 @@ class stage2(StageBase):
self.settings["source_path_hash"] = \
self.settings["hash_map"].generate_hash(
self.settings["source_path"],\
- hash_=self.settings["hash_function"],
- verbose=False)
+ hash_=self.settings["hash_function"])
print "Source path set to "+self.settings["source_path"]
if os.path.isdir(self.settings["source_path"]):
print "\tIf this is not desired, remove this directory or turn off seedcache in the options of catalyst.conf"