eric6/MicroPython/MicroPythonFileSystem.py

branch
micropython
changeset 7083
217862c28319
parent 7082
ec199ef0cfc6
child 7084
3eddfc540614
diff -r ec199ef0cfc6 -r 217862c28319 eric6/MicroPython/MicroPythonFileSystem.py
--- a/eric6/MicroPython/MicroPythonFileSystem.py	Wed Jul 24 20:12:19 2019 +0200
+++ b/eric6/MicroPython/MicroPythonFileSystem.py	Thu Jul 25 19:55:40 2019 +0200
@@ -329,7 +329,7 @@
         assert name
         
         commands = [
-            "import os"
+            "import os",
             "\n".join([
                 "def remove_file(name, recursive=False, force=False):",
                 "    try:",
@@ -413,6 +413,9 @@
         
         with open(hostFileName, "rb") as hostFile:
             content = hostFile.read()
+            # convert eol '\r'
+            content = content.replace(b"\r\n", b"\r")
+            content = content.replace(b"\n", b"\r")
         
         if not deviceFileName:
             deviceFileName = os.path.basename(hostFileName)
@@ -478,6 +481,9 @@
             raise IOError(self.__shortError(err))
         
         # write the received bytes to the local file
+        # convert eol to "\n"
+        out = out.replace(b"\r\n", b"\n")
+        out = out.replace(b"\r", b"\n")
         with open(hostFileName, "wb") as hostFile:
             hostFile.write(out)
         return True
@@ -602,6 +608,8 @@
     @signal rsyncDone(localName, deviceName) emitted after the rsync operation
         has been completed
     @signal rsyncMessages(list) emitted with a list of messages
+    @signal rsyncProgressMessage(msg) emitted to send a message about what
+        rsync is doing
     @signal removeDirectoryDone() emitted after a directory has been deleted
     @signal createDirectoryDone() emitted after a directory was created
     @signal synchTimeDone() emitted after the time was synchronizde to the
@@ -622,6 +630,7 @@
     deleteFileDone = pyqtSignal(str)
     rsyncDone = pyqtSignal(str, str)
     rsyncMessages = pyqtSignal(list)
+    rsyncProgressMessage = pyqtSignal(str)
     removeDirectoryDone = pyqtSignal()
     createDirectoryDone = pyqtSignal()
     synchTimeDone = pyqtSignal()
@@ -770,10 +779,11 @@
         @return tuple containing a list of messages and list of errors
         @rtype tuple of (list of str, list of str)
         """
+        # TODO: get rid of messages and replace by rsyncProgressMessage signal
         messages = []
         errors = []
         
-        if not os.isdir(hostDirectory):
+        if not os.path.isdir(hostDirectory):
             return ([], [self.tr(
                 "The given name '{0}' is not a directory or does not exist.")
                 .format(hostDirectory)

eric ide

mercurial