Upload into temporary file; Rename it after upload was finished
This commit is contained in:
parent
40fce7763e
commit
f35da0a3c8
@ -78,9 +78,8 @@ def main(nodeip, luafile, volatile=None, outfile=None):
|
||||
outfile=luafile
|
||||
else:
|
||||
print "Flashing " + luafile + " as " + outfile
|
||||
sendCmd(s, "file.remove(\"" + outfile +"\");", True)
|
||||
sendCmd(s, "w= file.writeline", True)
|
||||
sendCmd(s, "file.open(\"" + outfile + "\",\"w+\");", True)
|
||||
sendCmd(s, "file.open(\"temp.lua\",\"w+\");", True)
|
||||
else:
|
||||
print "Executing " + luafile + " on nodemcu"
|
||||
|
||||
@ -115,6 +114,11 @@ def main(nodeip, luafile, volatile=None, outfile=None):
|
||||
print "Cannot close the file"
|
||||
sys.exit(4)
|
||||
|
||||
sendCmd(s, "file.remove(\"" + outfile +"\");", True)
|
||||
if (not sendCmd(s, "file.rename(\"temp.lua\",\""+ outfile + "\")")):
|
||||
print "Cannot move temporary file to " + outfile
|
||||
|
||||
|
||||
# Check if the file exists:
|
||||
if (not sendRecv(s, "=file.exists(\"" + outfile + "\")", "true")):
|
||||
print("Cannot send " + outfile + " to the ESP")
|
||||
|
Loading…
Reference in New Issue
Block a user