Esempio n. 1
0
 def add_repl(self):
     """
     Detect a connected MicroPython based device and, if found, connect to
     the REPL and display it to the user.
     """
     device_port, serial_number = self.find_device()
     if device_port:
         try:
             self.view.add_micropython_repl(device_port, self.name,
                                            self.force_interrupt)
             logger.info('Started REPL on port: {}'.format(device_port))
             self.repl = True
         except IOError as ex:
             logger.error(ex)
             self.repl = False
             info = _("Click on the device's reset button, wait a few"
                      " seconds and then try again.")
             self.view.show_message(str(ex), info)
         except Exception as ex:
             logger.error(ex)
     else:
         message = _('Could not find an attached device.')
         information = _('Please make sure the device is plugged into this'
                         ' computer.\n\nIt must have a version of'
                         ' MicroPython (or CircuitPython) flashed onto it'
                         ' before the REPL will work.\n\nFinally, press the'
                         " device's reset button and wait a few seconds"
                         ' before trying again.')
         self.view.show_message(message, information)
Esempio n. 2
0
 def add_plotter(self):
     """
     Check if REPL exists, and if so, enable the plotter pane!
     """
     device_port, serial_number = self.find_device()
     if device_port:
         try:
             self.view.add_micropython_plotter(device_port, self.name, self)
             logger.info('Started plotter')
             self.plotter = True
         except IOError as ex:
             logger.error(ex)
             self.plotter = False
             info = _("Click on the device's reset button, wait a few"
                      " seconds and then try again.")
             self.view.show_message(str(ex), info)
         except Exception as ex:
             logger.error(ex)
     else:
         message = _('Could not find an attached device.')
         information = _('Please make sure the device is plugged into this'
                         ' computer.\n\nIt must have a version of'
                         ' MicroPython (or CircuitPython) flashed onto it'
                         ' before the Plotter will work.\n\nFinally, press'
                         " the device's reset button and wait a few seconds"
                         ' before trying again.')
         self.view.show_message(message, information)
Esempio n. 3
0
 def validate_email(self, value):
     self.reset_form = self.password_reset_form_class(
         data=self.initial_data)
     if not self.reset_form.is_valid():
         from pylint.checkers.typecheck import _
         raise serializers.ValidationError(_('Error'))  # noqa: F821
     return value
Esempio n. 4
0
 def on_data_flood(self):
     """
     Handle when the plotter is being flooded by data (which usually causes
     Mu to become unresponsive). In this case, remove the plotter and
     display a warning dialog to explain what's happened and how to fix
     things (usually, put a time.sleep(x) into the code generating the
     data).
     """
     logger.error('Plotting data flood detected.')
     self.view.remove_plotter()
     self.plotter = None
     msg = _('Data Flood Detected!')
     info = _("The plotter is flooded with data which will make Mu "
              "unresponsive and freeze. As a safeguard, the plotter has "
              "been stopped.\n\n"
              "Flooding is when chunks of data of more than 1024 bytes are "
              "repeatedly sent to the plotter.\n\n"
              "To fix this, make sure your code prints small tuples of "
              "data between calls to 'sleep' for a very short period of "
              "time.")
     self.view.show_message(msg, info)
Esempio n. 5
0
 def validate_email(self, email):
     email = get_adapter().clean_email(email)
     if email and email_address_exists(email):
         raise serializers.ValidationError(
             _("A user is already registered with this e-mail address."))
     return email