diff options
author | Papoteur <papoteur@mageia.org> | 2021-01-22 08:50:02 +0100 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2021-01-22 08:50:02 +0100 |
commit | f7eb28ed86ede5f0f75f400351a652683b937c95 (patch) | |
tree | 695b274dfea07000d51d679d8608cb4ec3a99b6f | |
parent | 867e58b28fe08dfe9bf7c75a936d24eb1d7fc686 (diff) | |
download | isodumper-f7eb28ed86ede5f0f75f400351a652683b937c95.tar isodumper-f7eb28ed86ede5f0f75f400351a652683b937c95.tar.gz isodumper-f7eb28ed86ede5f0f75f400351a652683b937c95.tar.bz2 isodumper-f7eb28ed86ede5f0f75f400351a652683b937c95.tar.xz isodumper-f7eb28ed86ede5f0f75f400351a652683b937c95.zip |
Manage disabling signals event when operation is running
Fix update on event
Add some debug logging
-rwxr-xr-x | lib/isodumper.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py index 97a46f3..1b5b1b9 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -192,16 +192,6 @@ class IsoDumper(basedialog.BaseDialog): self.devicelist.addItem(label, sel) return True - def active_signal(self): - print("Active") - self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesAdded.connect(self.refresh_signal) - self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesRemoved.connect(self.refresh_signal) - - def deactive_signal(self): - print("Désactive") - #self.u.iface["org.freedesktop.DBus.ObjectManager"].onInterfacesAdded = None - #self.u.iface["org.freedesktop.DBus.ObjectManager"].onInterfacesRemoved = None - def udev_wait(self, operation): wait = Popen(["udevadm", "settle", "--timeout=15"], stderr=PIPE) wait.communicate() @@ -228,6 +218,13 @@ class IsoDumper(basedialog.BaseDialog): self.dialog.recalcLayout() self.initial_state() + def update_list_on_event(self): + selitem = self.devicelist.selectedItem().label() + self.devicelist.deleteAllItems() + self.get_devices(selected = selitem) + if self.devicelist.selectedItem().label() != selitem: + self.restore() + def refresh_signal(self, device, params): self.devicelist.deleteAllItems() self.get_devices() @@ -279,7 +276,8 @@ class IsoDumper(basedialog.BaseDialog): def do_format(self): #code, format_type, name = self.ask_format() - if self.partition_cb.value() != "": + if self.partition_cb.value() != "": + self.operation = True format_type = list(self.format_type.keys())[list(self.format_type.values()).index(self.partition_cb.value())] if format_type == 'persist': self.emergency(_("Persistence partition is to use when writing a Live ISO image.")) @@ -380,6 +378,7 @@ class IsoDumper(basedialog.BaseDialog): logging.warning(message) self.emergency(message) else: + self.operation = True self.returncode = 0 source = self.dev.split('(')[1].split(')')[0] message = _('Backup to: {}').format(dest) @@ -441,9 +440,9 @@ class IsoDumper(basedialog.BaseDialog): self.progress.setLabel(_('Writing {source} to {target}').format(source=source.split('/')[-1], target=target.split('/')[-1])) message = _('Executing copy from {source} to {target}').format(source=source, target=target) + self.operation = True self.logger(message) logging.info(message) - self.deactive_signal() bus = SystemBus() iface = bus.get("org.mageia.Magiback", "Isodumper") success, message = self.u.do_unmount(target) @@ -535,7 +534,7 @@ class IsoDumper(basedialog.BaseDialog): self.initial_state() else: self.initial_state() - self.active_signal() + self.operation = False def success(self): self.operation = False @@ -556,6 +555,7 @@ class IsoDumper(basedialog.BaseDialog): you close the application.")) if self.ask_OK(info): return + def confirm_close(self, *args): if not self.operation: # no writing , backup nor format running self.close() @@ -807,7 +807,6 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog self.dialog.destroy() yui.YUILoader.deleteUI() exit() - self.active_signal() self.device_selected() self.dialog.recalcLayout() @@ -828,7 +827,11 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog def device_changed(self, a, b): - self.uEventQueue.put({'event': "device-changed", 'value': True}) + logging.debug(f"Signal {a}") + if not self.operation: + if 'drives' in a.split('/'): + logging.debug('device-changed') + self.uEventQueue.put({'event': "device-changed", 'value': True}) def ask_image(self): self.img_name = yui.YUI.app().askForExistingFile("", "*.iso *.img", self.ChooseImage) @@ -999,6 +1002,7 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog #break try: item = self.uEventQueue.get_nowait() + logging.debug(f"Dealing with {item['event']}") if item['event'] == "device-changed": self.update_list_on_event() except Exception as e: |