def delete(self, microbit_filename): """ Delete the referenced file on the micro:bit's filesystem. Emit the name of the file when complete, or emit a failure signal. """ try: microfs.rm(microbit_filename) self.on_delete_file.emit(microbit_filename) except Exception as ex: logger.error(ex) self.on_delete_fail.emit(microbit_filename)
def delete(self, device_filename): """ Delete the referenced file on the device's filesystem. Emit the name of the file when complete, or emit a failure signal. """ try: microfs.rm(device_filename, serial=self.serial) self.on_delete_file.emit(device_filename) except Exception as ex: logger.error(ex) self.on_delete_fail.emit(device_filename)
def contextMenuEvent(self, event): menu = QMenu(self) delete_action = menu.addAction("Delete (cannot be undone)") action = menu.exec_(self.mapToGlobal(event.pos())) if action == delete_action: self.setDisabled(True) self.setAcceptDrops(False) microbit_filename = self.currentItem().text() logger.info("Deleting {}".format(microbit_filename)) try: with microfs.get_serial() as serial: logger.info(serial.port) microfs.rm(serial, microbit_filename) self.takeItem(self.currentRow()) except Exception as ex: logger.error(ex) self.setDisabled(False) self.setAcceptDrops(True)