From e937782a4e88a86541d65ebd34ae1ee10dbfbb73 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Mon, 28 Jul 2014 17:46:56 +0200 Subject: [PATCH] Fix some lousy error handling --- src/modules/unsquashfs/main.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/modules/unsquashfs/main.py b/src/modules/unsquashfs/main.py index fc9416cae..30cd249ac 100644 --- a/src/modules/unsquashfs/main.py +++ b/src/modules/unsquashfs/main.py @@ -18,6 +18,7 @@ # along with Calamares. If not, see . import os +import shutil import subprocess import tempfile from collections import namedtuple @@ -61,30 +62,23 @@ class UnsquashOperation: sourceMountPath = tempfile.mkdtemp() try: for entry in self.unpacklist: - try: - sqfsList = subprocess.check_output( [ "unsquashfs", "-l", entry.source ] ) - filesCount = sqfsList.splitlines().count() - self.unpackstatus[ entry.source ].total = filesCount + 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 ] - imgMountDir = sourceMountPath + os.sep + imgBaseName - os.mkdir( imgMountDir ) - - entry.sourceDir = imgMountDir - - self.reportProgress() - - self.unsquashImage( entry ) - finally: - os.rmdir( imgMountDir ) + imgBaseName = os.path.splitext( os.path.basename( entry.source ) )[ 0 ] + imgMountDir = sourceMountPath + os.sep + imgBaseName + os.mkdir( imgMountDir ) + entry.sourceDir = imgMountDir + self.reportProgress() + self.unsquashImage( entry ) finally: - os.rmdir( sourceMountPath ) + shutil.rmtree( sourceMountPath ) def unsquashImage( self, entry ): + subprocess.check_call( [ "mount", entry.source, entry.sourceDir, "-t", "squashfs", "-o", "loop" ] ) try: - subprocess.check_call( [ "mount", entry.source, entry.sourceDir, "-t", "squashfs", "-o", "loop" ] ) - t = FileCopy( entry.sourceDir, entry.destination, self.reportProgress ) t.run() finally: