mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
testing brotlin compression
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import copytree, rmtree, copyfileobj
|
from shutil import copytree, rmtree, copyfileobj
|
||||||
from subprocess import check_output, Popen, PIPE, STDOUT, CalledProcessError
|
|
||||||
import os
|
import os
|
||||||
import gzip
|
import gzip
|
||||||
|
# import brotli
|
||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
@@ -11,6 +11,10 @@ def gzipFile(file):
|
|||||||
with gzip.open(file + '.gz', 'wb') as f_out:
|
with gzip.open(file + '.gz', 'wb') as f_out:
|
||||||
copyfileobj(f_in, f_out)
|
copyfileobj(f_in, f_out)
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
|
# with open(file + '.br', 'wb') as f_out:
|
||||||
|
# with open(file, 'rb') as f_in:
|
||||||
|
# f_out.write(brotli.compress(f_in.read(), quality=11))
|
||||||
|
# os.remove(file)
|
||||||
|
|
||||||
def flagExists(flag):
|
def flagExists(flag):
|
||||||
buildFlags = env.ParseFlags(env["BUILD_FLAGS"])
|
buildFlags = env.ParseFlags(env["BUILD_FLAGS"])
|
||||||
@@ -29,16 +33,19 @@ def buildWeb():
|
|||||||
with open("./src/i18n/i18n-util.ts", "w") as w:
|
with open("./src/i18n/i18n-util.ts", "w") as w:
|
||||||
w.write(text)
|
w.write(text)
|
||||||
env.Execute("npm run build")
|
env.Execute("npm run build")
|
||||||
|
|
||||||
buildPath = Path("build")
|
buildPath = Path("build")
|
||||||
wwwPath = Path("../data/www")
|
wwwPath = Path("../data/www")
|
||||||
|
|
||||||
if wwwPath.exists() and wwwPath.is_dir():
|
if wwwPath.exists() and wwwPath.is_dir():
|
||||||
rmtree(wwwPath)
|
rmtree(wwwPath)
|
||||||
if not flagExists("PROGMEM_WWW"):
|
|
||||||
print("Copying web files to data directory")
|
print("Copying web files to data directory")
|
||||||
copytree(buildPath, wwwPath)
|
copytree(buildPath, wwwPath)
|
||||||
for currentpath, folders, files in os.walk(wwwPath):
|
for currentpath, folders, files in os.walk(wwwPath):
|
||||||
for file in files:
|
for file in files:
|
||||||
gzipFile(os.path.join(currentpath, file))
|
gzipFile(os.path.join(currentpath, file))
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user