Changeset - 03b0b1263122
[Not reviewed]
default
0 2 0
Silverwing - 3 years ago 2020-11-02 21:27:05

Fix working with newer lsblk
2 files changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
devices/__init__.py
Show inline comments
 
@@ -9,27 +9,27 @@ def get_storage_devices(removable=None, 
 
    :return: list(tuple(str, str, str))
 
        first tuple item is device name, second identifying string(VENDOR + MODEL), third - size
 
    """
 
    proc = subprocess.Popen(
 
        ['lsblk', '-dJo', 'NAME,RM,TYPE,VENDOR,MODEL,SIZE'], stdout=subprocess.PIPE, stderr=subprocess.PIPE
 
    )
 

	
 
    if proc.wait() == 0:
 
        result = proc.stdout.read()
 
        result = json.loads(result.decode('utf'))
 
        rval = []
 
        for device in result['blockdevices']:
 
            if removable and device['rm'] == '0':
 
            if removable and (device['rm'] == '0' or device['rm'] is False):
 
                continue
 
            if removable == 'False' and device['rm'] == '1':
 
            if removable == 'False' and (device['rm'] == '1' or device['rm'] is True):
 
                continue
 
            if device_type is not None and device['type'] != device_type:
 
                continue
 
            rval.append((
 
                device['name'],
 
                '{} {} {}'.format(device['vendor'].strip(), device['model'].strip(), device['size']),
 
                device['size']
 
            ))
 

	
 
        return rval
 
    else:
 
        return []
forms/mainwindow.py
Show inline comments
 
@@ -62,28 +62,29 @@ class CustomTableModel(QtCore.QAbstractT
 
        return 2
 

	
 

	
 
class MainWindow(Ui_MainWindow, QtWidgets.QMainWindow):
 
    def __init__(self, root=None):
 
        super().__init__()
 
        self.setupUi(self)
 

	
 
        self.root = root if root else tempfile.mktemp(prefix='kusbff_')
 
        os.makedirs(self.root, exist_ok=True)
 

	
 
        self.devices_model = CustomListModel()
 
        self.table_model = CustomTableModel('(Not set)')
 

	
 
        self.devices_combobox.setModel(self.devices_model)
 
        self.refresh_disk_drives()
 

	
 
        self.table_model = CustomTableModel('(Not set)')
 
        self.tableView.setModel(self.table_model)
 
        self.refresh_image_list()
 

	
 
        self.action_refresh_devices.triggered.connect(self.refresh_disk_drives)
 
        self.devices_combobox.currentIndexChanged.connect(self.on_device_change)
 
        self.action_open_floppy.triggered.connect(self.open_directory)
 
        self.action_write_floppy.triggered.connect(self.save_directory)
 
        self.action_read_image.triggered.connect(self.read_image)
 
        self.action_write_image.triggered.connect(self.write_image)
 
        self.action_format_disk.triggered.connect(self.format_one)
 
        self.action_format_usb.triggered.connect(self.format_many)
 
        self.action_about.triggered.connect(self.show_about_dialog)
0 comments (0 inline, 0 general)