From f35da0a3c807f8dae9a056057f2162fcc01b9935 Mon Sep 17 00:00:00 2001 From: Ollo Date: Thu, 6 Jan 2022 16:46:33 +0100 Subject: [PATCH] Upload into temporary file; Rename it after upload was finished --- tools/tcpFlash.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/tcpFlash.py b/tools/tcpFlash.py index b2a2be1..f66ab57 100755 --- a/tools/tcpFlash.py +++ b/tools/tcpFlash.py @@ -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" @@ -114,6 +113,11 @@ def main(nodeip, luafile, volatile=None, outfile=None): if (not sendCmd(s, "file.close();")): 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")):