Fix some lousy error handling

This commit is contained in:
Teo Mrnjavac 2014-07-28 17:46:56 +02:00
parent 4fc2efb7fa
commit e937782a4e

View file

@ -18,6 +18,7 @@
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
import subprocess
import tempfile
from collections import namedtuple
@ -61,7 +62,6 @@ 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
@ -69,22 +69,16 @@ class UnsquashOperation:
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 )
finally:
os.rmdir( sourceMountPath )
shutil.rmtree( sourceMountPath )
def unsquashImage( self, entry ):
try:
subprocess.check_call( [ "mount", entry.source, entry.sourceDir, "-t", "squashfs", "-o", "loop" ] )
try:
t = FileCopy( entry.sourceDir, entry.destination, self.reportProgress )
t.run()
finally: