mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-27 04:33:04 +00:00
Extracted webroot into usable files
This commit is contained in:
16
scripts/addversion.py
Normal file
16
scripts/addversion.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import os
|
||||
|
||||
FILENAME_VERSION_H = 'src/version.h'
|
||||
version = os.environ.get('GITHUB_REF')
|
||||
if version == None:
|
||||
version = "SNAPSHOT"
|
||||
|
||||
import datetime
|
||||
|
||||
hf = """
|
||||
#ifndef VERSION
|
||||
#define VERSION "{}"
|
||||
#endif
|
||||
""".format(version)
|
||||
with open(FILENAME_VERSION_H, 'w+') as f:
|
||||
f.write(hf)
|
||||
25
scripts/makeweb.py
Normal file
25
scripts/makeweb.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
webroot = "web"
|
||||
srcroot = "src/web/root"
|
||||
|
||||
if not os.path.exists(srcroot):
|
||||
os.mkdir(srcroot)
|
||||
|
||||
for filename in os.listdir(webroot):
|
||||
basename = re.sub("[^0-9a-zA-Z]+", "_", filename)
|
||||
|
||||
srcfile = webroot + "/" + filename
|
||||
dstfile = srcroot + "/" + basename + ".h"
|
||||
|
||||
varname = basename.upper()
|
||||
|
||||
with open(dstfile, "w") as dst:
|
||||
dst.write("const char ")
|
||||
dst.write(varname)
|
||||
dst.write("[] PROGMEM = R\"==\"==(\n")
|
||||
with open(srcfile, "r") as src:
|
||||
for line in src.readlines():
|
||||
dst.write(line)
|
||||
dst.write("\n)==\"==\";\n")
|
||||
Reference in New Issue
Block a user