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 962EF13888F for ; Fri, 9 Oct 2015 19:36:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 252C521C014; Fri, 9 Oct 2015 19:36:12 +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 C2CA821C014 for ; Fri, 9 Oct 2015 19:36:11 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 093F23406A7 for ; Fri, 9 Oct 2015 19:36:10 +0000 (UTC) From: Mike Frysinger To: gentoo-catalyst@lists.gentoo.org Subject: [gentoo-catalyst] [PATCH 2/4] fileops: convert to log module Date: Fri, 9 Oct 2015 15:36:05 -0400 Message-Id: <1444419367-779-2-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 2.5.2 In-Reply-To: <1444419367-779-1-git-send-email-vapier@gentoo.org> References: <1444419367-779-1-git-send-email-vapier@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Archives-Salt: 8044b7e1-1672-4c1a-95e9-cd2e4c8da306 X-Archives-Hash: 6cec75fa48804eef50f7e091651989fc --- catalyst/fileops.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/catalyst/fileops.py b/catalyst/fileops.py index 2aa39f6..8fb2a36 100644 --- a/catalyst/fileops.py +++ b/catalyst/fileops.py @@ -20,6 +20,8 @@ from stat import ST_UID, ST_GID, ST_MODE from snakeoil.osutils import (ensure_dirs as snakeoil_ensure_dirs, pjoin, listdir_files) # pylint: enable=unused-import + +from catalyst import log from catalyst.support import CatalystError @@ -61,31 +63,31 @@ def clear_dir(target, mode=0o755, chg_flags=False, remove=False): @remove: boolean, passed through to clear_dir() @return boolean ''' - #print "fileops.clear_dir()" + log.debug('start: %s', target) if not target: - #print "fileops.clear_dir(), no target... returning" + log.debug('no target... returning') return False if os.path.isdir(target): - print "Emptying directory" , target + log.info('Emptying directory: %s', target) # stat the dir, delete the dir, recreate the dir and set # the proper perms and ownership try: - #print "fileops.clear_dir(), os.stat()" + log.debug('os.stat()') mystat=os.stat(target) # There's no easy way to change flags recursively in python if chg_flags and os.uname()[0] == "FreeBSD": os.system("chflags -R noschg " + target) - #print "fileops.clear_dir(), shutil.rmtree()" + log.debug('shutil.rmtree()') shutil.rmtree(target) if not remove: - #print "fileops.clear_dir(), ensure_dirs()" + log.debug('ensure_dirs()') ensure_dirs(target, mode=mode) os.chown(target, mystat[ST_UID], mystat[ST_GID]) os.chmod(target, mystat[ST_MODE]) - except Exception as e: - print CatalystError("clear_dir(); Exeption: %s" % str(e)) + except Exception: + log.error('clear_dir failed', exc_info=True) return False else: - print "fileops.clear_dir(), %s is not a directory" % (target) - #print "fileops.clear_dir(), DONE, returning True" + log.info('clear_dir failed: %s: is not a directory', target) + log.debug('DONE, returning True') return True -- 2.5.2