Hello,
i seek a method to copy a file on the board
i find uos.rename() , etc ... but what comand use for copy a file .py ( for exemple blink.py to main.py)
thanks by advance
Roger
file copy .py on board
Re: file copy .py on board
There is no built-in method for that. You have to use a little python script. e.g.
And the call:
from <script_name> import copy
copy(source, target)
If target is a directory, the source file will be copied into that directory.
Code: Select all
import os
def copy(s, t):
try:
if os.stat(t)[0] & 0x4000: # is directory
t = t.rstrip("/") + "/" + s
except OSError:
pass
with open(s, "rb") as s:
with open(t, "wb") as t:
while True:
l = s.read(512)
if not l: break
t.write(l)
from <script_name> import copy
copy(source, target)
If target is a directory, the source file will be copied into that directory.