Example #1
0
File: microbit.py Project: opt9/mu
 def put(self, local_filename):
     """
     Put the referenced local file onto the filesystem on the micro:bit.
     Emit the name of the file on the micro:bit when complete, or emit
     a failure signal.
     """
     try:
         microfs.put(local_filename, target=None)
         self.on_put_file.emit(os.path.basename(local_filename))
     except Exception as ex:
         logger.error(ex)
         self.on_put_fail.emit(local_filename)
Example #2
0
 def put(self, local_filename, target=None):
     """
     Put the referenced local file onto the filesystem on the micro:bit.
     Emit the name of the file on the micro:bit when complete, or emit
     a failure signal.
     """
     try:
         microfs.put(local_filename, target=target, serial=self.serial)
         self.on_put_file.emit(os.path.basename(local_filename))
     except Exception as ex:
         logger.error(ex)
         self.on_put_fail.emit(local_filename)
Example #3
0
 def put(self, local_filename, dist):
     """
     Put the referenced local file onto the filesystem on the Studuino:bit.
     Emit the name of the file on the Studuino:bit when complete, or emit
     a failure signal.
     """
     try:
         filename = os.path.basename(local_filename)
         microfs.put(local_filename, target=dist + '/' + filename,
                     serial=self.serial)
         self.on_put_file.emit(filename)
     except Exception as ex:
         logger.error(ex)
         self.on_put_fail.emit(local_filename)
Example #4
0
 def flash(self):
     """
     Takes the currently active tab, compiles the Python script therein into
     a hex file and flashes it all onto the connected device.
     """
     logger.info('Flashing script')
     # Grab the Python script.
     tab = self._view.current_tab
     if tab is None:
         # There is no active text editor.
         return
     self.save()  # save current script to disk
     logger.debug('Python script file:')
     logger.debug(tab.path)
     microfs.put(microfs.get_serial(), tab.path)
Example #5
0
 def dropEvent(self, event):
     source = event.source()
     self.disable(source)
     if isinstance(source, LocalFileList):
         local_filename = os.path.join(self.home,
                                       source.currentItem().text())
         logger.info("Putting {}".format(local_filename))
         try:
             with microfs.get_serial() as serial:
                 logger.info(serial.port)
                 microfs.put(serial, local_filename)
             super().dropEvent(event)
         except Exception as ex:
             logger.error(ex)
     self.enable(source)
Example #6
0
 def dropEvent(self, event):
     source = event.source()
     self.disable(source)
     if isinstance(source, LocalFileList):
         local_filename = os.path.join(self.home,
                                       source.currentItem().text())
         logger.info("Putting {}".format(local_filename))
         try:
             with microfs.get_serial() as serial:
                 logger.info(serial.port)
                 microfs.put(serial, local_filename)
             super().dropEvent(event)
         except Exception as ex:
             logger.error(ex)
     self.enable(source)
Example #7
0
 def dropEvent(self, event):
     source = event.source()
     self.disable(source)
     if isinstance(source, LocalFileList):
         if self.findItems(source.currentItem().text(), Qt.MatchExactly) \
                  and self.show_confirm_overwrite_dialog():
             local_filename = os.path.join(self.home,
                                           source.currentItem().text())
             logger.info("Putting {}".format(local_filename))
             try:
                 with microfs.get_serial() as serial:
                     logger.info(serial.port)
                     microfs.put(serial, local_filename)
                 super().dropEvent(event)
             except Exception as ex:
                 logger.error(ex)
     self.enable(source)
     self.parent().ls()
Example #8
0
 def dropEvent(self, event):
     source = event.source()
     self.disable(source)
     if isinstance(source, LocalFileList):
         if self.findItems(source.currentItem().text(), Qt.MatchExactly) \
                  and self.show_confirm_overwrite_dialog():
             local_filename = os.path.join(self.home,
                                           source.currentItem().text())
             logger.info("Putting {}".format(local_filename))
             try:
                 with microfs.get_serial() as serial:
                     logger.info(serial.port)
                     microfs.put(serial, local_filename)
                 super().dropEvent(event)
             except Exception as ex:
                 logger.error(ex)
     self.enable(source)
     self.parent().ls()