FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 06-20-2012, 12:11 AM
Will Woods
 
Default pylorax.imgutils: add debug logging

Add some useful debug logging info to various functions in
pylorax.imgutils.
---
src/pylorax/imgutils.py | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py
index c78d179..164c554 100644
--- a/src/pylorax/imgutils.py
+++ b/src/pylorax/imgutils.py
@@ -41,6 +41,8 @@ def mkcpio(rootdir, outfile, compression="xz", compressargs=["-9"]):
if compression is None:
compression = "cat" # this is a little silly
compressargs = []
+ logger.debug("mkcpio %s | %s %s > %s", rootdir, compression,
+ " ".join(compressargs), outfile)
find = Popen(["find", ".", "-print0"], stdout=PIPE, preexec_fn=chdir)
cpio = Popen(["cpio", "--null", "--quiet", "-H", "newc", "-o"],
stdin=find.stdout, stdout=PIPE, preexec_fn=chdir)
@@ -53,7 +55,9 @@ def mksquashfs(rootdir, outfile, compression="default", compressargs=[]):
'Make a squashfs image containing the given rootdir.'
if compression != "default":
compressargs = ["-comp", compression] + compressargs
- return call(["mksquashfs", rootdir, outfile] + compressargs)
+ cmd = ["mksquashfs", rootdir, outfile] + compressargs
+ logger.debug(" ".join(cmd))
+ return call(cmd)

######## Utility functions ###############################################

@@ -106,24 +110,32 @@ def mount(dev, opts="", mnt=None):
raises CalledProcessError if mount fails.'
if mnt is None:
mnt = tempfile.mkdtemp(prefix="lorax.imgutils.")
+ logger.debug("make tmp mountdir %s", mnt)
mount = ["mount"]
if opts:
mount += ["-o", opts]
- check_call(mount + [dev, mnt])
+ mount += [dev, mnt]
+ logger.debug(" ".join(mount))
+ check_call(mount)
return mnt

def umount(mnt):
'Unmount the given mountpoint. If the mount was a temporary dir created
by mount, it will be deleted. Returns false if the unmount fails.'
- rv = call(["umount", mnt])
+ umount = ["umount"]
+ umount += [mnt]
+ logger.debug(" ".join(umount))
+ rv = call(umount)
if 'lorax.imgutils' in mnt:
os.rmdir(mnt)
+ logger.debug("remove tmp mountdir %s", mnt)
return (rv == 0)

def copytree(src, dest, preserve=True):
'Copy a tree of files using cp -a, thus preserving modes, timestamps,
links, acls, sparse files, xattrs, selinux contexts, etc.
If preserve is False, uses cp -R (useful for modeless filesystems)'
+ logger.debug("copytree %s %s", src, dest)
chdir = lambda: os.chdir(src)
cp = ["cp", "-a"] if preserve else ["cp", "-R", "-L"]
check_call(cp + [".", os.path.abspath(dest)], preexec_fn=chdir)
--
1.7.10.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 03:26 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org