Esempio n. 1
0
    def _update_device_info(self):
        info_file_name = "INFO_UF2.TXT"
        suitable_volumes = {
            vol
            for vol in list_volumes(skip_letters=["A"])
            if os.path.exists(os.path.join(vol, info_file_name))
        }

        if len(suitable_volumes) == 0:
            self._device_info = None
            device_text = self._get_missing_device_instructions()
        elif len(suitable_volumes) > 1:
            self._device_info = None
            device_text = ("Found more than one device:\n  " +
                           "\n  ".join(sorted(suitable_volumes)) + "\n\n" +
                           "Please keep only one in bootloader mode!")
        else:
            vol = suitable_volumes.pop()
            model = "Unknown device"
            with open(os.path.join(vol, info_file_name),
                      encoding="utf-8") as fp:
                for line in fp:
                    if line.startswith("Model:"):
                        model = line[len("Model:"):].strip()
                        break

            self._device_info = {"volume": vol, "model": model}
            device_text = "%s at %s is ready" % (model, vol)

        self.device_label.configure(text=device_text)
Esempio n. 2
0
    def get_possible_targets(cls):
        all_vol_infos = [
            (vol, cls.find_device_board_id_and_model(vol))
            for vol in list_volumes(skip_letters=["A"])
        ]

        return [(info[0], info[1][0], info[1][1]) for info in all_vol_infos if info[1] is not None]
Esempio n. 3
0
 def _update_device_info(self):
     info_file_name = "INFO_UF2.TXT"
     suitable_volumes = {vol for vol in list_volumes(skip_letters=["A"]) 
                         if os.path.exists(os.path.join(vol, info_file_name))}
     
     if len(suitable_volumes) == 0:
         self._device_info = None
         device_text = (
               "Device not connected or not in bootloader mode.\n"
             + "\n"
             + "After connecting the device to a USB port, double-press its reset button\n"
             + "and wait for couple of seconds until OS mounts it in bootloader mode.\n"
             + "\n"
             + "If nothing happens, then try again with longer or shorter pauses between the\n"
             + "presses (or just a single press) or wait longer until this message disappears.\n"
         )
     elif len(suitable_volumes) > 1:
         self._device_info = None
         device_text = (
               "Found more than one device:\n  "
               + "\n  ".join(sorted(suitable_volumes))
               + "\n\n"
               + "Please keep only one in bootloader mode!"
         )
     else:
         vol = suitable_volumes.pop()
         model = "Unknown device"
         with open(os.path.join(vol,  info_file_name), encoding="utf-8") as fp:
             for line in fp:
                 if line.startswith("Model:"):
                     model = line[len("Model:"):].strip()
                     break
                 
         self._device_info = {"volume" : vol, "model" : model}
         device_text = "%s at %s is ready" % (model, vol)
     
     self.device_label.configure(text=device_text)