Unthreadify FileCopy in unsquashfs.

main
Teo Mrnjavac 11 years ago
parent f44b8eb758
commit c42d021b61

@ -26,14 +26,12 @@ import os
import subprocess import subprocess
import re import re
from threading import Thread
COPY_CMD = 'rsync -ar --progress %(source)s %(dest)s' COPY_CMD = 'rsync -ar --progress %(source)s %(dest)s'
ON_POSIX = 'posix' in sys.builtin_module_names ON_POSIX = 'posix' in sys.builtin_module_names
class FileCopyThread( Thread ): class FileCopy:
""" Update the value of the progress bar so that we get some movement """ """ Update the value of the progress bar so that we get some movement """
def __init__( self, source, dest, progress_cb ): def __init__( self, source, dest, progress_cb ):
# Environment used for executing rsync properly # Environment used for executing rsync properly
@ -54,13 +52,6 @@ class FileCopyThread( Thread ):
self.progress_cb = progress_cb self.progress_cb = progress_cb
super( FileCopyThread, self ).__init__()
def kill( self ):
if self.process.poll() is None:
self.process.kill()
def run( self ): def run( self ):
num_files_copied = 0 num_files_copied = 0

@ -22,7 +22,7 @@ import subprocess
import tempfile import tempfile
from libcalamares import * from libcalamares import *
from filecopy import FileCopyThread from filecopy import FileCopy
class UnsquashOperation: class UnsquashOperation:
@ -81,9 +81,8 @@ class UnsquashOperation:
try: try:
subprocess.check_call( [ "mount", entry[ "source" ], entry[ "sourceDir" ], "-t", "squashfs", "-o", "loop" ] ) subprocess.check_call( [ "mount", entry[ "source" ], entry[ "sourceDir" ], "-t", "squashfs", "-o", "loop" ] )
t = FileCopyThread( entry[ "sourceDir" ], entry[ "destination" ], self.reportProgress ) t = FileCopy( entry[ "sourceDir" ], entry[ "destination" ], self.reportProgress )
t.start() t.run()
t.join()
finally: finally:
subprocess.check_call( [ "umount", "-l", entry[ "sourceDir" ] ] ) subprocess.check_call( [ "umount", "-l", entry[ "sourceDir" ] ] )

Loading…
Cancel
Save