40 lines
1.8 KiB
Python
40 lines
1.8 KiB
Python
import os
|
|
import json
|
|
|
|
def get_config(path):
|
|
with open(path, "r") as f:
|
|
return json.load(f)
|
|
|
|
def get_config_pub(path):
|
|
with open(path, "r") as f:
|
|
codeString = json.load(f)
|
|
return codeString["quickfaas"]["uploadFuncs"][0]["script"]
|
|
|
|
def get_config_sub(path):
|
|
with open(path, "r") as f:
|
|
codeString = json.load(f)
|
|
return codeString["quickfaas"]["downloadFuncs"][0]["script"]
|
|
|
|
def code_to_string(path):
|
|
with open(path, "r") as f:
|
|
return f.read()
|
|
|
|
def write_code(path, codestr):
|
|
with open(path, "w") as f:
|
|
f.write(codestr)
|
|
|
|
def write_config(path, config, pub, sub):
|
|
with open(path, "w") as f:
|
|
config["quickfaas"]["uploadFuncs"][0]["script"] = pub
|
|
config["quickfaas"]["downloadFuncs"][0]["script"] = sub
|
|
json.dump(config, f, indent=4)
|
|
|
|
root = os.getcwd()
|
|
devicetype = "rigpump"
|
|
startversion = 3
|
|
deviceconfig = "device_supervisor_" + devicetype +"v" + str(startversion) + ".cfg"
|
|
|
|
#write_code(root + "/" + devicetype + "/v" + str(startversion) + "/pub" + "/sendData.py", get_config_pub(root + "/" + devicetype + "/v" + str(startversion) + "/" + deviceconfig))
|
|
#write_code(root + "/" + devicetype + "/v" + str(startversion) + "/sub" + "/receiveCommand.py", get_config_sub(root + "/" + devicetype + "/v" + str(startversion) + "/" + deviceconfig))
|
|
|
|
write_config(root + "/" + devicetype + "/v" + str(startversion + 1) + "/device_supervisor_" + devicetype + "v" + str(startversion + 1) + ".cfg", get_config(root + "/" + devicetype + "/v" + str(startversion) + "/device_supervisor_" + devicetype + "v" + str(startversion) + ".cfg"), code_to_string(root + "/" + devicetype + "/v" + str(startversion + 1) + "/pub" + "/sendData.py"), code_to_string(root + "/" + devicetype + "/v" + str(startversion + 1) + "/sub" + "/receiveCommand.py")) |