From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id F06EF13888F for ; Fri, 9 Oct 2015 21:06:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6A92C21C00E; Fri, 9 Oct 2015 21:06:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B182021C00E for ; Fri, 9 Oct 2015 21:06:49 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C2C69340564 for ; Fri, 9 Oct 2015 21:06:48 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D9A04DCD for ; Fri, 9 Oct 2015 21:06:46 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1444397266.5048aad7bdfbfcc0e7e3562a80fc97a344818b55.vapier@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/genbase.py catalyst/base/stagebase.py catalyst/hash_utils.py catalyst/targets/stage2.py X-VCS-Directories: catalyst/ catalyst/targets/ catalyst/base/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 5048aad7bdfbfcc0e7e3562a80fc97a344818b55 X-VCS-Branch: master Date: Fri, 9 Oct 2015 21:06:46 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 07d8106e-5803-450e-a2ee-db4276720bac X-Archives-Hash: 06f52272fd6c49c7da693d6fa48a15c4 commit: 5048aad7bdfbfcc0e7e3562a80fc97a344818b55 Author: Mike Frysinger gentoo org> AuthorDate: Fri Oct 9 13:27:46 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Fri Oct 9 13:27:46 2015 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=5048aad7 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. 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"