コード例 #1
0
 def on_connected_hw_device_changed(self, cur_hw_device: HWDevice):
     self.cur_hw_device = cur_hw_device
     if self.on_validate_hw_device(cur_hw_device):
         if self.current_step in (Step.STEP_NO_HW_ERROR, Step.STEP_NONE):
             self.set_current_step(Step.STEP_SETTINGS)
         else:
             self.update_ui()
         hw_model = self.cur_hw_device.get_hw_model()
         if hw_model and not self.latest_firmwares.get(hw_model):
             WndUtils.run_thread(self, self.get_latest_firmware_thread,
                                 (hw_model, ))
     else:
         self.set_current_step(Step.STEP_NO_HW_ERROR)
コード例 #2
0
    def go_to_next_step(self):
        if self.current_step == Step.STEP_SELECT_FIRMWARE_SOURCE:
            if self.hw_firmware_source_type == FirmwareSource.INTERNET:
                if not self.selected_firmware_source_web:
                    WndUtils.error_msg('No firmware selected.')
                    return
            elif self.hw_firmware_source_type == FirmwareSource.LOCAL_FILE:
                if not os.path.isfile(self.selected_firmware_source_file):
                    WndUtils.error_msg('You must enter the name and path to the firmware file to be uploaded to the '
                                       'device.')
                    return

            self.current_step = Step.STEP_PREPARE_FIRMWARE_DATA
            self.set_controls_initial_state_for_step(False)
            self.update_ui()
            WndUtils.run_thread(self, self.prepare_firmware_upload_thread, ())

        elif self.current_step == Step.STEP_PREPARE_FIRMWARE_DATA:
            # reconnect hardware wallet device to check if it in bootloader mode
            self.hw_devices.open_hw_session(self.cur_hw_device, force_reconnect=True)
            if self.cur_hw_device and self.cur_hw_device.hw_client:
                if self.cur_hw_device.bootloader_mode:
                    if self.upload_firmware_thread_obj is None:
                        self.current_step = Step.STEP_UPLOADING_FIRMWARE
                        self.set_controls_initial_state_for_step(False)
                        self.update_ui()
                        self.upload_firmware_thread_obj = WndUtils.run_thread(self, self.upload_firmware_thread, ())
                    else:
                        logging.error('Thread upload_firmware_thread is already running')
                else:
                    WndUtils.error_msg("Enter your hardware wallet into bootloader mode.")
            else:
                WndUtils.error_msg("Your hardware wallet doesn't seem to be connected.")

        elif self.current_step == Step.STEP_UPLOADING_FIRMWARE:
            self.current_step = Step.STEP_FINISHED_UPDATE
            self.set_controls_initial_state_for_step(False)
            self.update_ui()
コード例 #3
0
 def start(self):
     """ Run saving thread after GUI initializes. """
     if not self.thread:
         self.thread = WndUtils.run_thread(None, self.save_data_thread, ())
コード例 #4
0
 def load_remote_firmware_list(self):
     if not self.load_remote_firmware_thread_obj:
         self.load_remote_firmware_thread_obj = WndUtils.run_thread(self, self.load_remote_firmware_list_thread, (),
                                                                    on_thread_finish=self.display_firmware_list)
     else:
         logging.warning('Thread load_remote_firmware_list_thread is already running')