mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-15 06:53:07 +01:00
moved generated into extra dir, prepare for more embedded files
This commit is contained in:
@@ -2,10 +2,27 @@ print("running extra...")
|
||||
import gzip
|
||||
import shutil
|
||||
import os
|
||||
import sys
|
||||
import inspect
|
||||
GEN_DIR='generated'
|
||||
FILES=['web/index.html']
|
||||
|
||||
def outPath():
|
||||
#see: https://stackoverflow.com/questions/16771894/python-nameerror-global-name-file-is-not-defined
|
||||
return os.path.join(os.path.dirname(inspect.getfile(lambda: None)),GEN_DIR)
|
||||
|
||||
def checkDir():
|
||||
dn=outPath()
|
||||
if not os.path.exists(dn):
|
||||
os.makedirs(dn)
|
||||
if not os.path.isdir(dn):
|
||||
print("unable to create %s"%dn)
|
||||
return False
|
||||
return True
|
||||
|
||||
def compressFile(inFile):
|
||||
outfile=inFile+".gz"
|
||||
outfile=os.path.basename(inFile)+".gz"
|
||||
outfile=os.path.join(outPath(),outfile)
|
||||
if os.path.exists(outfile):
|
||||
otime=os.path.getmtime(outfile)
|
||||
itime=os.path.getmtime(inFile)
|
||||
@@ -16,6 +33,8 @@ def compressFile(inFile):
|
||||
with gzip.open(outfile, 'wb') as f_out:
|
||||
shutil.copyfileobj(f_in, f_out)
|
||||
|
||||
if not checkDir():
|
||||
sys.exit(1)
|
||||
for f in FILES:
|
||||
print("compressing %s"%f)
|
||||
compressFile(f)
|
||||
Reference in New Issue
Block a user