src/eric7/MicroPython/Devices/DeviceBase.py

branch
eric7
changeset 10515
6e790462348a
parent 10439
21c28b0f9e41
child 10683
779cda568acb
diff -r 5e6362665247 -r 6e790462348a src/eric7/MicroPython/Devices/DeviceBase.py
--- a/src/eric7/MicroPython/Devices/DeviceBase.py	Fri Jan 19 09:50:47 2024 +0100
+++ b/src/eric7/MicroPython/Devices/DeviceBase.py	Sat Jan 20 12:36:40 2024 +0100
@@ -822,6 +822,28 @@
             if err:
                 raise OSError(self._shortError(err))
 
+    def rename(self, oldname, newname):
+        """
+        Public method to rename a file on the device.
+
+        @param oldname current name of the file
+        @type str
+        @param newname new name for the file
+        @type str
+        @exception OSError raised to indicate an issue with the device
+        """
+        if oldname and newname:
+            command = """
+import os as __os_
+__os_.rename('{0}', '{1}')
+del __os_
+""".format(
+                oldname, newname
+            )
+            out, err = self.executeCommands(command, mode=self._submitMode)
+            if err:
+                raise OSError(self._shortError(err))
+
     def put(self, hostFileName, deviceFileName=None):
         """
         Public method to copy a local file to the connected device.

eric ide

mercurial