← index #6980PR #10821
Related · medium · value 0.209
QUERY · ISSUE

Pyboard.py doesn't keep file path with folders on windows

openby martinlombanaopened 2021-03-02updated 2021-03-12
tools

Hi, I am using the latest pyboard.py and, per the documentation, it will keep the path, providing that the folder exists also on destination, but it does not.

When executing this:

python pyboard.py --device COM4 -f cp srptools/context.py :

We get this, and the file is copied to the root.

cp srptools/context.py :context.py

Workaround: Specify the destination path manually.

python pyboard.py --device COM4 -f cp srptools/context.py :srptools/context.py

As a bonus, it would be nice if pyboard.py created the destination path if it doesn't exist.

Thanks!

CANDIDATE · PULL REQUEST

tools/pyboard.py: Use '/' exclusively when dealing with paths.

mergedby dpgeorgeopened 2023-02-23updated 2023-02-24
tools

Currently, certain mpremote filesystem operations can fail on Windows due to a mixing of '/' and '' for path separators. Eg if filesystem_command() is called with a destination that ends in / then dest.endswith(os.path.sep) will return False, which gives the wrong behaviour (it does end in a path separator).

For similar reasons to 7e9a15966acf80ff50fdf5c52553dd56de164bb3, it's best to use '/' everywhere in pyboard.py and mpremote, because the target device understands only '/'. mpremote already does this, so the remaining place to fix it is in pyboard.y, to convert all incoming paths to use '/' instead of ''.

This effectively reverts 57fd66b80f8352e4859e6b71536b6083f9d7279c which tried to fix the problem in a different way.

See also related 1f84440538a017e463aaad9686831ce9527122b5.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied