Open AlexStz opened 5 years ago
Or port "fix: Fix posix-style paths from Windows (wendlers#72)" from junhuanchen/mpfshell
(change os.path.join
to posixpath.join
)
🆗 thanks !!!! I know. XD
According to the https://github.com/wendlers/mpfshell/commit/18993e022c79b39da8babdace03cba14e7d5de3e to fix.
But I'm not sure if it will affect other systems.
Your suggestion?
check this.
on Windows 7+ everything is OK. (I don't know how to WinXP or Vista) on Linux - also everything is OK. (posix system:) on Mac - I don’t check, none...
пн, 20 мая 2019 г. в 08:21, Juwan notifications@github.com:
According to the wendlers/mpfshell@18993e0 https://github.com/wendlers/mpfshell/commit/18993e022c79b39da8babdace03cba14e7d5de3e to fix.
But I'm not sure if it will affect other systems.
Your suggestion?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/junhuanchen/mpfshell-lite/issues/1?email_source=notifications&email_token=AILA4O3FIE2ZSEE2SBMW5DDPWI7PDA5CNFSM4HNVRSQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVXZU5Y#issuecomment-493853303, or mute the thread https://github.com/notifications/unsubscribe-auth/AILA4O2SJFUQ74HVAQS6WOTPWI7PDANCNFSM4HNVRSQQ .
if use "posixpath" all paths with "/" - none "\" or "\" !
пн, 20 мая 2019 г. в 09:22, Juwan notifications@github.com:
check this.
[image: 图片] https://user-images.githubusercontent.com/32978053/58003280-0c272d80-7b13-11e9-87cc-0cc78c96ee72.png
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/junhuanchen/mpfshell-lite/issues/1?email_source=notifications&email_token=AILA4O52UDBGW3MBUH662PDPWJGTDA5CNFSM4HNVRSQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVX5F5Y#issuecomment-493867767, or mute the thread https://github.com/notifications/unsubscribe-auth/AILA4O6VIRJT5OIIGSUCVE3PWJGTDANCNFSM4HNVRSQQ .
this in function "__parse_file_names()" and next -> "Class Tokenizer" ( variable "valid_fnchars")... I need to think. "re.Scanner" -> "tokens". I know this badly. I will dig the Internet.
пн, 20 мая 2019 г. в 09:36, Alex St stz.alex@gmail.com:
if use "posixpath" all paths with "/" - none "\" or "\" !
пн, 20 мая 2019 г. в 09:22, Juwan notifications@github.com:
check this.
[image: 图片] https://user-images.githubusercontent.com/32978053/58003280-0c272d80-7b13-11e9-87cc-0cc78c96ee72.png
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/junhuanchen/mpfshell-lite/issues/1?email_source=notifications&email_token=AILA4O52UDBGW3MBUH662PDPWJGTDA5CNFSM4HNVRSQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVX5F5Y#issuecomment-493867767, or mute the thread https://github.com/notifications/unsubscribe-auth/AILA4O6VIRJT5OIIGSUCVE3PWJGTDANCNFSM4HNVRSQQ .
If this is the Windows path will go wrong.
At this time need '\' to '/' , as .replace("\\","/"), The lcd function is also required.
I'll check later
Now all "args" all commands (lcd, cd, gt, rm, put...) need "posix" path (c:/User/Juwan). This is in function "parse_file_names()" and next -> "Class Tokenizer". All commands use "on local" or "on remote"(board) system. On remote (board) need ONLY posix paths. Need duplicate "parse_file_names()" for local system commands (lcd, rf, runfile...) (in Class Tokenizer-> validfnchars = "A-Za-z0-9%#~@/\$!*.+-\:\\" -> here added "\\"). Or completely replace function "__parse_file_names()" with your own.
Corrected
valid_fnchars = "A-Za-z0-9_%#~@/\$!\*\.\+\-\:\\\\"
-> here added "\\\\"
Errors none. (lines starting tokens: and rest: - for debugging)
But I think a few questions.
windows is C:\
linux is /root
mac unknown.
Whether we need to judge a function or a regular expression by the system.
if os == win validfnchars = "A-Za-z0-9%#~@/\$!*.+-\:\\" elif os == linux validfnchars = "A-Za-z0-9%#~@/\$!*.+-\:"
Like this code.
Today 520 (is I love you) so I'll update it the day after tomorrow XD (521 to wo ai ni in Chinese)
I think that there is no need to divide into different "local" operating systems. And the remote is always "linux" (board). If there is no such path, now give error.
valid_fnchars = "A-Za-z0-9_%#~@/\$!\*\.\+\-\:\\\\"
- All valid characters in the path are listed here.
Аf an unspecified character appears in the string (path from "args") -> "__parse_file_names(args)" give error "Invalid filename given: %s" ->since "tokenizer.tokenize(args)" was able to split the string by the missing in "valid_fnchars" character and return to "rest" the second part of the line.
I think that need only split parse_file_names on "local" and "remote" commands. Or need write another "check" function to test real paths depending on OS (replace "parse_file_names") with many-many code... :)
p.s. Chinese valentines day... :)
If you still want to implement a real path check of the local system, read to start: is_path_exists_or_creatable(). And python pathlib.
Beyond sanity. Beyond pain. You will find Python portability concerns. (Cecil Curry Copyrighted)
:)
Maybe this is the best way. about is_path_exists_or_creatable() and python pathlib.
After that, we need to add some test cases to check the various paths, and I'll update unit_test for that.
I think any system path should be converted back to Linux, as you say
In file mpfexp.py -> def put(src) ->
(src='probeled.py')
Raise exception: string 284:self.exec_("f = open('%s', 'wb')" % self._fqn(dst))
self._fqn(dst) ='/flash\probeled.py'
!!!Need add to all
os.path.join
->.replace("\\","/")
Example:to: