public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] [PATCH 1/4] hash_utils: convert to log module
@ 2015-10-09 19:36 Mike Frysinger
  2015-10-09 19:36 ` [gentoo-catalyst] [PATCH 2/4] fileops: " Mike Frysinger
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Mike Frysinger @ 2015-10-09 19:36 UTC (permalink / raw
  To: gentoo-catalyst

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.
---
 catalyst/base/genbase.py   |  6 ++----
 catalyst/base/stagebase.py |  6 ++----
 catalyst/hash_utils.py     | 24 +++++++++---------------
 catalyst/targets/stage2.py |  3 +--
 4 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index 32459b4..a33f924 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 bffafb7..88d71ba 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 0262422..3db61f1 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 e6965cc..786aaa4 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"
-- 
2.5.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-09 20:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-09 19:36 [gentoo-catalyst] [PATCH 1/4] hash_utils: convert to log module Mike Frysinger
2015-10-09 19:36 ` [gentoo-catalyst] [PATCH 2/4] fileops: " Mike Frysinger
2015-10-09 19:36 ` [gentoo-catalyst] [PATCH 3/4] snapshot: " Mike Frysinger
2015-10-09 19:36 ` [gentoo-catalyst] [PATCH 4/4] config: " Mike Frysinger
2015-10-09 20:38   ` Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox