|
|
|
@ -32,13 +32,16 @@ if platform.system() == "Windows":
|
|
|
|
|
import win32com.client
|
|
|
|
|
|
|
|
|
|
def dd_iso_image(dd_progress_thread):
|
|
|
|
|
try:
|
|
|
|
|
_dd_iso_image(dd_progress_thread)
|
|
|
|
|
except:
|
|
|
|
|
o = io.StringIO()
|
|
|
|
|
traceback.print_exc(None, o)
|
|
|
|
|
log(o.getvalue())
|
|
|
|
|
dd_progress_thread.set_error(o.getvalue())
|
|
|
|
|
if platform.system() == "Windows":
|
|
|
|
|
dd_win()
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
_dd_iso_image(dd_progress_thread)
|
|
|
|
|
except:
|
|
|
|
|
o = io.StringIO()
|
|
|
|
|
traceback.print_exc(None, o)
|
|
|
|
|
log(o.getvalue())
|
|
|
|
|
dd_progress_thread.set_error(o.getvalue())
|
|
|
|
|
|
|
|
|
|
def _dd_iso_image(dd_progress_thread):
|
|
|
|
|
pbar = progressbar.ProgressBar(
|
|
|
|
@ -52,25 +55,25 @@ def _dd_iso_image(dd_progress_thread):
|
|
|
|
|
).start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while dd_process.poll() is None:
|
|
|
|
|
time.sleep(0.1) # If this time delay is not given, the Popen does not execute the actual command
|
|
|
|
|
dd_process.send_signal(signal.SIGUSR1)
|
|
|
|
|
dd_process.stderr.flush()
|
|
|
|
|
while True:
|
|
|
|
|
time.sleep(0.1)
|
|
|
|
|
out_error = dd_process.stderr.readline().decode()
|
|
|
|
|
if out_error:
|
|
|
|
|
if 'bytes' in out_error:
|
|
|
|
|
copied = int(out_error.split(' ', 1)[0])
|
|
|
|
|
config.imager_percentage = round((float(copied) / float(in_file_size) * 100))
|
|
|
|
|
pbar.update(config.imager_percentage)
|
|
|
|
|
break
|
|
|
|
|
def gui_update(percentage):
|
|
|
|
|
config.imager_percentage = percentage
|
|
|
|
|
pbar.update(percentage)
|
|
|
|
|
|
|
|
|
|
if dd_process.poll() is not None:
|
|
|
|
|
log("\nExecuting ==> sync")
|
|
|
|
|
os.sync()
|
|
|
|
|
log("ISO has been written to USB disk...")
|
|
|
|
|
return
|
|
|
|
|
unmounted_contexts = [
|
|
|
|
|
(usb.UnmountedContext(p[0], config.update_usb_mount), p[0]) for p
|
|
|
|
|
in udisks.find_partitions_on(config.usb_disk)]
|
|
|
|
|
really_unmounted = []
|
|
|
|
|
try:
|
|
|
|
|
for c, pname in unmounted_contexts:
|
|
|
|
|
c.__enter__()
|
|
|
|
|
really_unmounted.append((c, pname))
|
|
|
|
|
error = osdriver.dd_iso_image(
|
|
|
|
|
config.image_path, config.usb_disk, gui_update)
|
|
|
|
|
if error:
|
|
|
|
|
dd_progress_thread.set_error(error)
|
|
|
|
|
finally:
|
|
|
|
|
for c, pname in really_unmounted:
|
|
|
|
|
c.__exit__(None, None, None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dd_win_clean_usb(usb_disk_no):
|
|
|
|
@ -97,7 +100,6 @@ def dd_win():
|
|
|
|
|
_output = "of=\\\.\\PhysicalDrive" + str(usb_disk_no)
|
|
|
|
|
if dd_win_clean_usb(usb_disk_no) is False:
|
|
|
|
|
return
|
|
|
|
|
# of=\\.\PhysicalDrive1
|
|
|
|
|
# _output = "od=" + config.usb_disk # 'od=' option should also work.
|
|
|
|
|
# command = [windd, _input, _output, "bs=1M", "--progress"]
|
|
|
|
|
command = windd + ' ' + _input + ' ' + _output + " bs=1M" + " --progress"
|
|
|
|
@ -123,27 +125,6 @@ def dd_win():
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
def gui_update(percentage):
|
|
|
|
|
config.imager_percentage = percentage
|
|
|
|
|
pbar.update(percentage)
|
|
|
|
|
|
|
|
|
|
unmounted_contexts = [
|
|
|
|
|
(usb.UnmountedContext(p[0], config.update_usb_mount), p[0]) for p
|
|
|
|
|
in udisks.find_partitions_on(config.usb_disk)]
|
|
|
|
|
really_unmounted = []
|
|
|
|
|
try:
|
|
|
|
|
for c, pname in unmounted_contexts:
|
|
|
|
|
c.__enter__()
|
|
|
|
|
really_unmounted.append((c, pname))
|
|
|
|
|
error = osdriver.dd_iso_image(
|
|
|
|
|
config.image_path, config.usb_disk, gui_update)
|
|
|
|
|
if error:
|
|
|
|
|
dd_progress_thread.set_error(error)
|
|
|
|
|
finally:
|
|
|
|
|
for c, pname in really_unmounted:
|
|
|
|
|
c.__exit__(None, None, None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Imager(QtWidgets.QMainWindow, Ui_MainWindow):
|
|
|
|
|
"""
|
|
|
|
|