def get(self, microbit_filename, local_filename): """ Get the referenced micro:bit filename and save it to the local filename. Emit the name of the filename when complete or emit a failure signal. """ try: microfs.get(microbit_filename, local_filename) self.on_get_file.emit(microbit_filename) except Exception as ex: logger.error(ex) self.on_get_fail.emit(microbit_filename)
def dropEvent(self, event): source = event.source() self.disable(source) if isinstance(source, MicrobitFileList): microbit_filename = source.currentItem().text() local_filename = os.path.join(self.home, microbit_filename) logger.debug("Getting {} to {}".format(microbit_filename, local_filename)) try: with microfs.get_serial() as serial: logger.info(serial.port) microfs.get(serial, microbit_filename, local_filename) super().dropEvent(event) except Exception as ex: logger.error(ex) self.enable(source)
def dropEvent(self, event): source = event.source() self.disable(source) if isinstance(source, MicrobitFileList): if self.findItems(source.currentItem().text(), Qt.MatchExactly) \ and self.show_confirm_overwrite_dialog(): microbit_filename = source.currentItem().text() local_filename = os.path.join(self.home, microbit_filename) logger.debug("Getting {} to {}".format(microbit_filename, local_filename)) try: with microfs.get_serial() as serial: logger.info(serial.port) microfs.get(serial, microbit_filename, local_filename) super().dropEvent(event) except Exception as ex: logger.error(ex) self.enable(source) self.parent().ls()