|
|
@ -12,13 +12,10 @@ import subprocess
|
|
|
|
import collections
|
|
|
|
import collections
|
|
|
|
import platform
|
|
|
|
import platform
|
|
|
|
import signal
|
|
|
|
import signal
|
|
|
|
from PyQt5 import QtGui
|
|
|
|
|
|
|
|
from PyQt5 import QtWidgets
|
|
|
|
from PyQt5 import QtWidgets
|
|
|
|
from PyQt5 import QtCore
|
|
|
|
|
|
|
|
from .gui.ui_multibootusb import Ui_MainWindow
|
|
|
|
from .gui.ui_multibootusb import Ui_MainWindow
|
|
|
|
from .gen import *
|
|
|
|
from .gen import *
|
|
|
|
from . import iso
|
|
|
|
from . import iso
|
|
|
|
from . import usb
|
|
|
|
|
|
|
|
from . import config
|
|
|
|
from . import config
|
|
|
|
from . import progressbar
|
|
|
|
from . import progressbar
|
|
|
|
|
|
|
|
|
|
|
@ -28,15 +25,14 @@ if platform.system() == "Windows":
|
|
|
|
|
|
|
|
|
|
|
|
def dd_linux():
|
|
|
|
def dd_linux():
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
input = "if=" + config.image_path
|
|
|
|
_input = "if=" + config.image_path
|
|
|
|
in_file_size = float(os.path.getsize(config.image_path))
|
|
|
|
in_file_size = float(os.path.getsize(config.image_path))
|
|
|
|
output = "of=" + config.usb_disk
|
|
|
|
_output = "of=" + config.usb_disk
|
|
|
|
os.system("umount " + config.usb_disk + "1")
|
|
|
|
os.system("umount " + config.usb_disk + "1")
|
|
|
|
command = ['dd', input, output, "bs=1M", "oflag=sync"]
|
|
|
|
command = ['dd', _input, _output, "bs=1M", "oflag=sync"]
|
|
|
|
log("Executing ==> " + " ".join(command))
|
|
|
|
log("Executing ==> " + " ".join(command))
|
|
|
|
dd_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
|
|
|
|
dd_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
|
|
|
|
|
|
|
|
|
|
|
|
# bar = progressbar.ProgressBar(redirect_stdout=True)
|
|
|
|
|
|
|
|
pbar = progressbar.ProgressBar(
|
|
|
|
pbar = progressbar.ProgressBar(
|
|
|
|
maxval=100,
|
|
|
|
maxval=100,
|
|
|
|
widgets=[
|
|
|
|
widgets=[
|
|
|
@ -73,10 +69,10 @@ def dd_win():
|
|
|
|
windd = resource_path(os.path.join("data", "tools", "dd", "dd.exe"))
|
|
|
|
windd = resource_path(os.path.join("data", "tools", "dd", "dd.exe"))
|
|
|
|
if os.path.exists(resource_path(os.path.join("data", "tools", "dd", "dd.exe"))):
|
|
|
|
if os.path.exists(resource_path(os.path.join("data", "tools", "dd", "dd.exe"))):
|
|
|
|
log("dd exist")
|
|
|
|
log("dd exist")
|
|
|
|
input = "if=" + config.image_path
|
|
|
|
_input = "if=" + config.image_path
|
|
|
|
in_file_size = float(os.path.getsize(config.image_path) / 1024 / 1024)
|
|
|
|
in_file_size = float(os.path.getsize(config.image_path) / 1024 / 1024)
|
|
|
|
output = "of=\\\.\\" + config.usb_disk
|
|
|
|
_output = "of=\\\.\\" + config.usb_disk
|
|
|
|
command = [windd, input, output, "bs=1M", "--progress"]
|
|
|
|
command = [windd, _input, _output, "bs=1M", "--progress"]
|
|
|
|
log("Executing ==> " + " ".join(command))
|
|
|
|
log("Executing ==> " + " ".join(command))
|
|
|
|
dd_process = subprocess.Popen(command, universal_newlines=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
|
|
|
|
dd_process = subprocess.Popen(command, universal_newlines=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
|
|
|
|
shell=False)
|
|
|
|
shell=False)
|
|
|
@ -127,19 +123,8 @@ class Imager(QtWidgets.QMainWindow, Ui_MainWindow):
|
|
|
|
self.ui.imager_iso_size.setText("ISO Size: " + self.iso_size + " MB")
|
|
|
|
self.ui.imager_iso_size.setText("ISO Size: " + self.iso_size + " MB")
|
|
|
|
log("ISO Size is " + self.iso_size + " MB")
|
|
|
|
log("ISO Size is " + self.iso_size + " MB")
|
|
|
|
|
|
|
|
|
|
|
|
# def onImagerComboChange(self):
|
|
|
|
@staticmethod
|
|
|
|
# config.imager_usb_disk = str(self.ui.comboBox_2.currentText())
|
|
|
|
def imager_list_usb(partition=1):
|
|
|
|
# if bool(config.imager_usb_disk):
|
|
|
|
|
|
|
|
# self.ui.imager_disk_label.setText(self.imager_usb_detail(config.imager_usb_disk, partition=0).usb_type)
|
|
|
|
|
|
|
|
# self.ui.imager_total_size.setText(usb.bytes2human(int(self.imager_usb_detail(config.imager_usb_disk, partition=0).total_size)))
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# if platform.system() == "Linux":
|
|
|
|
|
|
|
|
# self.ui.label_imager_uuid.setText("Disk Model:")
|
|
|
|
|
|
|
|
# self.ui.imager_uuid.setText(str(self.imager_usb_detail(config.imager_usb_disk, partition=0).model))
|
|
|
|
|
|
|
|
# else:
|
|
|
|
|
|
|
|
# self.ui.imager_uuid.setText(self.imager_usb_detail(config.imager_usb_disk, partition=0).model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def imager_list_usb(self, partition=1):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Function to detect whole USB disk. It uses lsblk package on Linux.
|
|
|
|
Function to detect whole USB disk. It uses lsblk package on Linux.
|
|
|
|
:param partition: What to return. By default partition is set.
|
|
|
|
:param partition: What to return. By default partition is set.
|
|
|
@ -148,7 +133,7 @@ class Imager(QtWidgets.QMainWindow, Ui_MainWindow):
|
|
|
|
disk = []
|
|
|
|
disk = []
|
|
|
|
if platform.system() == "Linux":
|
|
|
|
if platform.system() == "Linux":
|
|
|
|
output = subprocess.check_output("lsblk -i", shell=True)
|
|
|
|
output = subprocess.check_output("lsblk -i", shell=True)
|
|
|
|
if not partition == 1:
|
|
|
|
if partition != 1:
|
|
|
|
for line in output.splitlines():
|
|
|
|
for line in output.splitlines():
|
|
|
|
line = line.split()
|
|
|
|
line = line.split()
|
|
|
|
if (line[2].strip()) == b'1' and (line[5].strip()) == b'disk':
|
|
|
|
if (line[2].strip()) == b'1' and (line[5].strip()) == b'disk':
|
|
|
@ -159,7 +144,6 @@ class Imager(QtWidgets.QMainWindow, Ui_MainWindow):
|
|
|
|
if (line[2].strip()) == b'1' and line[5].strip() == b'part':
|
|
|
|
if (line[2].strip()) == b'1' and line[5].strip() == b'part':
|
|
|
|
disk.append(str("/dev/" + str(line[0].strip()[2:])))
|
|
|
|
disk.append(str("/dev/" + str(line[0].strip()[2:])))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if partition == 1 or not partition == 1:
|
|
|
|
|
|
|
|
oFS = win32com.client.Dispatch("Scripting.FileSystemObject")
|
|
|
|
oFS = win32com.client.Dispatch("Scripting.FileSystemObject")
|
|
|
|
oDrives = oFS.Drives
|
|
|
|
oDrives = oFS.Drives
|
|
|
|
for drive in oDrives:
|
|
|
|
for drive in oDrives:
|
|
|
@ -167,7 +151,8 @@ class Imager(QtWidgets.QMainWindow, Ui_MainWindow):
|
|
|
|
disk.append(drive)
|
|
|
|
disk.append(drive)
|
|
|
|
return disk
|
|
|
|
return disk
|
|
|
|
|
|
|
|
|
|
|
|
def imager_usb_detail(self, usb_disk, partition=1):
|
|
|
|
@staticmethod
|
|
|
|
|
|
|
|
def imager_usb_detail(usb_disk, partition=1):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Function to detect details of USB disk using lsblk
|
|
|
|
Function to detect details of USB disk using lsblk
|
|
|
|
:param usb_disk: path to usb disk
|
|
|
|
:param usb_disk: path to usb disk
|
|
|
@ -180,7 +165,7 @@ class Imager(QtWidgets.QMainWindow, Ui_MainWindow):
|
|
|
|
output = subprocess.check_output("lsblk -ib " + usb_disk, shell=True)
|
|
|
|
output = subprocess.check_output("lsblk -ib " + usb_disk, shell=True)
|
|
|
|
for line in output.splitlines():
|
|
|
|
for line in output.splitlines():
|
|
|
|
line = line.split()
|
|
|
|
line = line.split()
|
|
|
|
if not partition == 1:
|
|
|
|
if partition != 1:
|
|
|
|
if line[2].strip() == b'1' and line[5].strip() == b'disk':
|
|
|
|
if line[2].strip() == b'1' and line[5].strip() == b'disk':
|
|
|
|
total_size = line[3]
|
|
|
|
total_size = line[3]
|
|
|
|
if not total_size:
|
|
|
|
if not total_size:
|
|
|
@ -194,7 +179,7 @@ class Imager(QtWidgets.QMainWindow, Ui_MainWindow):
|
|
|
|
selected_usb_part = str(usb_disk)
|
|
|
|
selected_usb_part = str(usb_disk)
|
|
|
|
oFS = win32com.client.Dispatch("Scripting.FileSystemObject")
|
|
|
|
oFS = win32com.client.Dispatch("Scripting.FileSystemObject")
|
|
|
|
d = oFS.GetDrive(oFS.GetDriveName(oFS.GetAbsolutePathName(selected_usb_part)))
|
|
|
|
d = oFS.GetDrive(oFS.GetDriveName(oFS.GetAbsolutePathName(selected_usb_part)))
|
|
|
|
selected_usb_device = d.DriveLetter
|
|
|
|
# selected_usb_device = d.DriveLetter
|
|
|
|
label = (d.VolumeName).strip()
|
|
|
|
label = (d.VolumeName).strip()
|
|
|
|
if not label.strip():
|
|
|
|
if not label.strip():
|
|
|
|
label = "No label."
|
|
|
|
label = "No label."
|
|
|
|