mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-25 03:15:44 -05:00
Fix some lousy error handling
This commit is contained in:
parent
4fc2efb7fa
commit
e937782a4e
1 changed files with 12 additions and 18 deletions
|
@ -18,6 +18,7 @@
|
||||||
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
@ -61,30 +62,23 @@ class UnsquashOperation:
|
||||||
sourceMountPath = tempfile.mkdtemp()
|
sourceMountPath = tempfile.mkdtemp()
|
||||||
try:
|
try:
|
||||||
for entry in self.unpacklist:
|
for entry in self.unpacklist:
|
||||||
try:
|
sqfsList = subprocess.check_output( [ "unsquashfs", "-l", entry.source ] )
|
||||||
sqfsList = subprocess.check_output( [ "unsquashfs", "-l", entry.source ] )
|
filesCount = sqfsList.splitlines().count()
|
||||||
filesCount = sqfsList.splitlines().count()
|
self.unpackstatus[ entry.source ].total = filesCount
|
||||||
self.unpackstatus[ entry.source ].total = filesCount
|
|
||||||
|
|
||||||
imgBaseName = os.path.splitext( os.path.basename( entry.source ) )[ 0 ]
|
imgBaseName = os.path.splitext( os.path.basename( entry.source ) )[ 0 ]
|
||||||
imgMountDir = sourceMountPath + os.sep + imgBaseName
|
imgMountDir = sourceMountPath + os.sep + imgBaseName
|
||||||
os.mkdir( imgMountDir )
|
os.mkdir( imgMountDir )
|
||||||
|
entry.sourceDir = imgMountDir
|
||||||
entry.sourceDir = imgMountDir
|
self.reportProgress()
|
||||||
|
self.unsquashImage( entry )
|
||||||
self.reportProgress()
|
|
||||||
|
|
||||||
self.unsquashImage( entry )
|
|
||||||
finally:
|
|
||||||
os.rmdir( imgMountDir )
|
|
||||||
finally:
|
finally:
|
||||||
os.rmdir( sourceMountPath )
|
shutil.rmtree( sourceMountPath )
|
||||||
|
|
||||||
|
|
||||||
def unsquashImage( self, entry ):
|
def unsquashImage( self, entry ):
|
||||||
|
subprocess.check_call( [ "mount", entry.source, entry.sourceDir, "-t", "squashfs", "-o", "loop" ] )
|
||||||
try:
|
try:
|
||||||
subprocess.check_call( [ "mount", entry.source, entry.sourceDir, "-t", "squashfs", "-o", "loop" ] )
|
|
||||||
|
|
||||||
t = FileCopy( entry.sourceDir, entry.destination, self.reportProgress )
|
t = FileCopy( entry.sourceDir, entry.destination, self.reportProgress )
|
||||||
t.run()
|
t.run()
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Add table
Reference in a new issue