From: Mike Frysinger <vapier@gentoo.org>
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 [thread overview]
Message-ID: <1444419367-779-2-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1444419367-779-1-git-send-email-vapier@gentoo.org>
---
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
next prev parent reply other threads:[~2015-10-09 19:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-09 19:36 [gentoo-catalyst] [PATCH 1/4] hash_utils: convert to log module Mike Frysinger
2015-10-09 19:36 ` Mike Frysinger [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1444419367-779-2-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gentoo-catalyst@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox