DFRobot / uPyCraft_src

137 stars 82 forks source link

Fix crashes and on Windows with files across multiple drives/paths #4

Open MarkSmithAU opened 6 years ago

MarkSmithAU commented 6 years ago

Fantastic IDE, thank you! :)

I have fixed some bugs found on Windows when working across different drives and paths. The program assumes the working directory will be on the same drive etc which makes the DownLoadAndRun functionality break (silently).

I have fixed this with a few small changes and it now works OK for me. After fixing this I found a few similar issues with the ctrl.py file where it had to strip off the drive letter properly otherwise it sent D:/ to micropython in run commands etc which failed.

These changes should work across *nix and Windows but I have only tested them on Windows.

Original error with prints on the input paths to show why it was breaking, with 'z' being the username: pcOpenFile:D:/ds18b20test.py convert D:/ds18b20test.py 0 ds18b20test.py D:/ds18b20test.py cmd=uitouart::: Traceback (most recent call last): File "C:\gitsrc\uPyCraft_src\uPyCraft.py", line 1492, in slotDownloadFileAndRun if self.slotDownloadFile(): File "C:\gitsrc\uPyCraft_src\uPyCraft.py", line 1479, in slotDownloadFile myfile=open(str(rootDirectoryPath+afile[1:]),'w',encoding='utf-8') OSError: [Errno 22] Invalid argument: 'C:/Users/z:/ds18b20test.py' -1

jhlucky commented 6 years ago

@MarkSmithAU The latest version is compatible with Windows and Linux, but for the lack of consideration in logic, it will lead to errors in disks except the C disk. This problem will be solved in the further uPyCaft and will be released together with the MAC version. Thanks for your attention.

jhlucky commented 6 years ago

@MarkSmithAU It caused by rootDirectoryPath. linux: /home/user/ windows: C:\Users\Administrator In windows, files in D disk or F disk ... filename not contains the rootDirectoryPath.lead to errors. If you run in C disk,it's OK.