Commit dcb69712 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

sw-fm: Changes in rename script

These changes make sure we completely overwrite the files we write. Otherwise,
with short ELMA crate hostnames and passwords, the rename script wrote the proper
values, but then left some characters from the previous files and these
characters could get in the way of running the shell or Python scripts.
parent 5a99de97
......@@ -4,35 +4,35 @@ import sys
from subprocess import *
from string import Template
sys.argv[1] = sys.argv[1].lower()
try:
with open("ubuntu/%s/pyts/ptsdefine.py" % (sys.argv[1]), "r+") as f:
sys.argv[1] = sys.argv[1].lower()
with open("ubuntu/%s/pyts/ptsdefine.py" % (sys.argv[1]), "r") as f:
buf = f.read()
buf = Template(buf)
buf = buf.substitute(BOARD=sys.argv[1], ELMAIP=sys.argv[2], ELMAPWD=sys.argv[3], ELMASLOT=sys.argv[4])
f.seek(0)
with open("ubuntu/%s/pyts/ptsdefine.py" % (sys.argv[1]), "w") as f:
f.write(buf)
with open("ubuntu/%s/shell/get-fan-speeds" % (sys.argv[1]), "r+") as f:
with open("ubuntu/%s/shell/get-fan-speeds" % (sys.argv[1]), "r") as f:
buf = f.read()
buf = Template(buf)
buf = buf.substitute(ELMAIP=sys.argv[2], ELMAPWD=sys.argv[3])
f.seek(0)
with open("ubuntu/%s/shell/get-fan-speeds" % (sys.argv[1]), "w") as f:
f.write(buf)
with open("ubuntu/%s/shell/men-on" % (sys.argv[1]), "r+") as f:
with open("ubuntu/%s/shell/men-on" % (sys.argv[1]), "r") as f:
buf = f.read()
buf = Template(buf)
buf = buf.substitute(ELMAIP=sys.argv[2], ELMAPWD=sys.argv[3])
f.seek(0)
with open("ubuntu/%s/shell/men-on" % (sys.argv[1]), "w") as f:
f.write(buf)
with open("ubuntu/%s/shell/men-off" % (sys.argv[1]), "r+") as f:
with open("ubuntu/%s/shell/men-off" % (sys.argv[1]), "r") as f:
buf = f.read()
buf = Template(buf)
buf = buf.substitute(ELMAIP=sys.argv[2], ELMAPWD=sys.argv[3])
f.seek(0)
with open("ubuntu/%s/shell/men-off" % (sys.argv[1]), "w") as f:
f.write(buf)
except IndexError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment