示例#1
0
文件: microbit.py 项目: 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)
示例#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)
示例#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)
示例#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)
示例#5
0
文件: interface.py 项目: peconia/mu
 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)
示例#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)
示例#7
0
文件: interface.py 项目: eduvik/mu
 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()
示例#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()