eric6/MicroPython/CircuitPythonDevices.py

branch
micropython
changeset 7132
c4682cfcd160
parent 7129
3cc19aec959a
child 7134
21d23ca51680
--- a/eric6/MicroPython/CircuitPythonDevices.py	Mon Aug 12 14:53:07 2019 +0200
+++ b/eric6/MicroPython/CircuitPythonDevices.py	Mon Aug 12 14:54:06 2019 +0200
@@ -26,6 +26,8 @@
     """
     Class implementing the device for CircuitPython boards.
     """
+    DeviceVolumeName = "CIRCUITPY"
+    
     def __init__(self, microPythonWidget, parent=None):
         """
         Constructor
@@ -45,8 +47,7 @@
         self.microPython.setActionButtons(
             run=True, repl=True, files=True, chart=HAS_QTCHART)
         
-        workspace = self.getWorkspace()
-        if workspace.endswith("CIRCUITPY"):
+        if self.__deviceVolumeMounted():
             self.microPython.setActionButtons(open=True, save=True)
     
     def forceInterrupt(self):
@@ -125,7 +126,16 @@
         @return flag indicating file access via local directory
         @type bool
         """
-        return True
+        return self.__deviceVolumeMounted()
+    
+    def __deviceVolumeMounted(self):
+        """
+        Private method to check, if the device volume is mounted.
+        
+        @return flag indicated a mounted device
+        @rtype bool
+        """
+        return self.getWorkspace().endswith(self.DeviceVolumeName)
     
     def getWorkspace(self):
         """
@@ -136,7 +146,7 @@
         """
         # Attempts to find the path on the filesystem that represents the
         # plugged in CIRCUITPY board.
-        deviceDirectory = Utilities.findVolume("CIRCUITPY")
+        deviceDirectory = Utilities.findVolume(self.DeviceVolumeName)
         
         if deviceDirectory:
             return deviceDirectory
@@ -167,7 +177,6 @@
         # TODO: add menu entry to copy a .mpy or .py file to the
         #       device library (creating the /lib folder if it doesn't
         #       exist already)
-        # TODO: add menu entry to cross-compile a .py file (using mpy-cross)
     
     @pyqtSlot()
     def __flashCircuitPython(self):

eric ide

mercurial