#506 use minified files for off-line installer

This commit is contained in:
Mikayla Fischler 2024-06-29 16:02:25 -04:00
parent 347f67c8ee
commit df8c71f12e

View File

@ -3,6 +3,9 @@ import json
import os import os
import sys import sys
path_prefix = "./_minified/"
# recursively encode files with base64
def encode_recursive(path): def encode_recursive(path):
list = {} list = {}
@ -18,11 +21,12 @@ def encode_recursive(path):
return list return list
# encode listed files with base64
def encode_files(files): def encode_files(files):
list = {} list = {}
for item in files: for item in files:
item_path = './' + item item_path = path_prefix + './' + item
handle = open(item_path, 'r') handle = open(item_path, 'r')
list[item] = base64.b64encode(bytes(handle.read(), 'UTF-8')).decode('ASCII') list[item] = base64.b64encode(bytes(handle.read(), 'UTF-8')).decode('ASCII')
@ -30,19 +34,20 @@ def encode_files(files):
return list return list
# file manifest (reflects imgen.py)
manifest = { manifest = {
"files" : { "files" : {
# common files # common files
"system" : encode_files([ "initenv.lua", "startup.lua", "configure.lua", "LICENSE" ]), "system" : encode_files([ "initenv.lua", "startup.lua", "configure.lua", "LICENSE" ]),
"common" : encode_recursive("./scada-common"), "common" : encode_recursive(path_prefix + "./scada-common"),
"graphics" : encode_recursive("./graphics"), "graphics" : encode_recursive(path_prefix + "./graphics"),
"lockbox" : encode_recursive("./lockbox"), "lockbox" : encode_recursive(path_prefix + "./lockbox"),
# platform files # platform files
"reactor-plc" : encode_recursive("./reactor-plc"), "reactor-plc" : encode_recursive(path_prefix + "./reactor-plc"),
"rtu" : encode_recursive("./rtu"), "rtu" : encode_recursive(path_prefix + "./rtu"),
"supervisor" : encode_recursive("./supervisor"), "supervisor" : encode_recursive(path_prefix + "./supervisor"),
"coordinator" : encode_recursive("./coordinator"), "coordinator" : encode_recursive(path_prefix + "./coordinator"),
"pocket" : encode_recursive("./pocket"), "pocket" : encode_recursive(path_prefix + "./pocket"),
}, },
"depends" : { "depends" : {
"reactor-plc" : [ "reactor-plc", "system", "common", "graphics", "lockbox" ], "reactor-plc" : [ "reactor-plc", "system", "common", "graphics", "lockbox" ],
@ -53,6 +58,7 @@ manifest = {
} }
} }
# write the application installation items as Lua tables
def write_items(body, items, indent): def write_items(body, items, indent):
indent_str = " " * indent indent_str = " " * indent
for key, value in items.items(): for key, value in items.items():
@ -66,6 +72,7 @@ def write_items(body, items, indent):
return body return body
for app in [ "reactor-plc", "rtu", "supervisor", "coordinator", "pocket" ]: for app in [ "reactor-plc", "rtu", "supervisor", "coordinator", "pocket" ]:
f = open("_" + app + ".lua", "w") f = open("_" + app + ".lua", "w")
body = "local application = {\n" body = "local application = {\n"