diff -r 979562f350bf -r 8dc5acb30a8b eric6/MicroPython/CircuitPythonDevices.py --- a/eric6/MicroPython/CircuitPythonDevices.py Wed Feb 03 19:14:35 2021 +0100 +++ b/eric6/MicroPython/CircuitPythonDevices.py Wed Feb 03 19:15:58 2021 +0100 @@ -38,6 +38,8 @@ @type QObject """ super(CircuitPythonDevice, self).__init__(microPythonWidget, parent) + + self.__workspace = self.__findWorkspace() def setButtons(self): """ @@ -135,7 +137,7 @@ @return flag indicated a mounted device @rtype bool """ - return self.getWorkspace(silent=True).endswith(self.DeviceVolumeName) + return self.DeviceVolumeName in self.getWorkspace(silent=True) def getWorkspace(self, silent=False): """ @@ -146,12 +148,32 @@ @return workspace directory used for saving files @rtype str """ - # Attempts to find the path on the filesystem that represents the - # plugged in CIRCUITPY board. - deviceDirectory = Utilities.findVolume(self.DeviceVolumeName) + if self.__workspace: + # return cached entry + return self.__workspace + else: + self.__workspace = self.__findWorkspace(silent=silent) + return self.__workspace + + def __findWorkspace(self, silent=False): + """ + Public method to find the workspace directory. - if deviceDirectory: - return deviceDirectory + @param silent flag indicating silent operations + @type bool + @return workspace directory used for saving files + @rtype str + """ + # Attempts to find the paths on the filesystem that represents the + # plugged in CIRCUITPY boards. + deviceDirectories = Utilities.findVolume(self.DeviceVolumeName, + all=True) + + if deviceDirectories: + if len(deviceDirectories) == 1: + return deviceDirectories[0] + else: + return self.selectDeviceDirectory(deviceDirectories) else: # return the default workspace and give the user a warning (unless # silent mode is selected)