src/eric7/MicroPython/MicroPythonFileManager.py

branch
eric7
changeset 9765
6378da868bb0
parent 9760
11245ac9c258
child 9766
f0e22f3a5878
diff -r 57496966803c -r 6378da868bb0 src/eric7/MicroPython/MicroPythonFileManager.py
--- a/src/eric7/MicroPython/MicroPythonFileManager.py	Tue Feb 14 11:09:49 2023 +0100
+++ b/src/eric7/MicroPython/MicroPythonFileManager.py	Tue Feb 14 18:10:30 2023 +0100
@@ -68,18 +68,18 @@
 
     error = pyqtSignal(str, str)
 
-    def __init__(self, commandsInterface, parent=None):
+    def __init__(self, device, parent=None):
         """
         Constructor
 
-        @param commandsInterface reference to the commands interface object
-        @type MicroPythonCommandsInterface
+        @param device MicroPython device object
+        @type BaseDevice
         @param parent reference to the parent object
         @type QObject
         """
         super().__init__(parent)
 
-        self.__commandsInterface = commandsInterface
+        self.__device = device
 
     @pyqtSlot(str)
     def lls(self, dirname, showHidden=False):
@@ -92,7 +92,7 @@
         @type bool
         """
         try:
-            filesList = self.__commandsInterface.lls(dirname, showHidden=showHidden)
+            filesList = self.__device.lls(dirname, showHidden=showHidden)
             result = [
                 (
                     decoratedName(name, mode),
@@ -112,7 +112,7 @@
         Public slot to get the current directory of the device.
         """
         try:
-            pwd = self.__commandsInterface.pwd()
+            pwd = self.__device.pwd()
             self.currentDir.emit(pwd)
         except Exception as exc:
             self.error.emit("pwd", str(exc))
@@ -126,7 +126,7 @@
         @type str
         """
         try:
-            self.__commandsInterface.cd(dirname)
+            self.__device.cd(dirname)
             self.currentDirChanged.emit(dirname)
         except Exception as exc:
             self.error.emit("cd", str(exc))
@@ -146,7 +146,7 @@
             # only a local directory was given
             hostFileName = os.path.join(hostFileName, os.path.basename(deviceFileName))
         try:
-            self.__commandsInterface.get(deviceFileName, hostFileName)
+            self.__device.get(deviceFileName, hostFileName)
             self.getFileDone.emit(deviceFileName, hostFileName)
         except Exception as exc:
             self.error.emit("get", str(exc))
@@ -161,7 +161,7 @@
         @rtype bytes
         """
         try:
-            data = self.__commandsInterface.getData(deviceFileName)
+            data = self.__device.getData(deviceFileName)
             return data
         except Exception as exc:
             self.error.emit("getData", str(exc))
@@ -179,7 +179,7 @@
         @type str
         """
         try:
-            self.__commandsInterface.put(hostFileName, deviceFileName)
+            self.__device.put(hostFileName, deviceFileName)
             self.putFileDone.emit(hostFileName, deviceFileName)
         except Exception as exc:
             self.error.emit("put", str(exc))
@@ -190,11 +190,11 @@
 
         @param deviceFileName name of the file to write to
         @type str
-        @param content data to write
+        @param data data to write
         @type bytes
         """
         try:
-            self.__commandsInterface.putData(deviceFileName, data)
+            self.__device.putData(deviceFileName, data)
             self.putDataDone.emit(deviceFileName)
         except Exception as exc:
             self.error.emit("putData", str(exc))
@@ -208,7 +208,7 @@
         @type str
         """
         try:
-            self.__commandsInterface.rm(deviceFileName)
+            self.__device.rm(deviceFileName)
             self.deleteFileDone.emit(deviceFileName)
         except Exception as exc:
             self.error.emit("delete", str(exc))
@@ -275,15 +275,13 @@
                     destinationDict[name] = nstat
         else:
             try:
-                destinationFiles = self.__commandsInterface.lls(
-                    deviceDirectory, fullstat=True
-                )
+                destinationFiles = self.__device.lls(deviceDirectory, fullstat=True)
             except Exception as exc:
                 return [str(exc)]
             if destinationFiles is None:
                 # the destination directory does not exist
                 try:
-                    self.__commandsInterface.mkdir(deviceDirectory)
+                    self.__device.mkdir(deviceDirectory)
                 except Exception as exc:
                     return [str(exc)]
             else:
@@ -387,7 +385,7 @@
                 )
                 if os.path.isfile(sourceFilename):
                     try:
-                        self.__commandsInterface.put(sourceFilename, destFilename)
+                        self.__device.put(sourceFilename, destFilename)
                     except Exception as exc:
                         # just note issues but ignore them otherwise
                         errors.append(str(exc))
@@ -416,9 +414,7 @@
                         )
                     )
                     try:
-                        self.__commandsInterface.rmrf(
-                            destFilename, recursive=True, force=True
-                        )
+                        self.__device.rmrf(destFilename, recursive=True, force=True)
                     except Exception as exc:
                         # just note issues but ignore them otherwise
                         errors.append(str(exc))
@@ -470,9 +466,7 @@
                                 )
                             )
                             try:
-                                self.__commandsInterface.put(
-                                    sourceFilename, destFilename
-                                )
+                                self.__device.put(sourceFilename, destFilename)
                             except Exception as exc:
                                 errors.append(str(exc))
 
@@ -514,7 +508,7 @@
         @type str
         """
         try:
-            self.__commandsInterface.mkdir(dirname)
+            self.__device.mkdir(dirname)
             self.createDirectoryDone.emit()
         except Exception as exc:
             self.error.emit("mkdir", str(exc))
@@ -532,9 +526,9 @@
         """
         try:
             if recursive:
-                self.__commandsInterface.rmrf(dirname, recursive=True, force=True)
+                self.__device.rmrf(dirname, recursive=True, force=True)
             else:
-                self.__commandsInterface.rmdir(dirname)
+                self.__device.rmdir(dirname)
             self.removeDirectoryDone.emit()
         except Exception as exc:
             self.error.emit("rmdir", str(exc))
@@ -545,7 +539,7 @@
         systems.
         """
         try:
-            fsinfo = self.__commandsInterface.fileSystemInfo()
+            fsinfo = self.__device.fileSystemInfo()
             self.fsinfoDone.emit(fsinfo)
         except Exception as exc:
             self.error.emit("fileSystemInfo", str(exc))

eric ide

mercurial