From f44b8eb7587e923d8cc84eff1427e615f3fe2912 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Mon, 28 Jul 2014 11:50:11 +0200 Subject: [PATCH] Count the files in the squashfs image without piping to wc -l. --- src/modules/unsquashfs/main.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/unsquashfs/main.py b/src/modules/unsquashfs/main.py index ff35eb64f..043d66ff1 100644 --- a/src/modules/unsquashfs/main.py +++ b/src/modules/unsquashfs/main.py @@ -59,10 +59,8 @@ class UnsquashOperation: try: for entry in self.unpacklist: try: - unsqfsProcess = subprocess.Popen( [ "unsquashfs", "-l", entry[ "source" ] ], stdout = subprocess.PIPE ) - wcProcess = subprocess.Popen( [ "wc", "-l" ], stdin = unsqfsProcess.stdout, stdout = subprocess.PIPE ) - countString = wcProcess.communicate()[ 0 ] - filesCount = int( float( countString ) ) + sqfsList = subprocess.check_output( [ "unsquashfs", "-l", entry[ "source" ] ] ) + filesCount = sqfsList.splitlines().count() self.unpackstatus[ entry[ "source" ] ][ 'total' ] = filesCount imgBaseName = os.path.splitext( os.path.basename( entry[ "source" ] ) )[ 0 ]