Now writes images to temporary files and atomically moves in place*
* on systems with an atomic os.rename
This commit is contained in:
@@ -144,11 +144,10 @@ directory.
|
||||
|
||||
|
||||
jsondump = json.dumps(dump, indent=4)
|
||||
with codecs.open(os.path.join(self.outputdir, 'overviewerConfig.js'), 'w', encoding='UTF-8') as f:
|
||||
f.write("var overviewerConfig = " + jsondump + ";\n")
|
||||
with util.FileReplacer(os.path.join(self.outputdir, "overviewerConfig.js")) as tmpfile:
|
||||
with codecs.open(tmpfile, 'w', encoding='UTF-8') as f:
|
||||
f.write("var overviewerConfig = " + jsondump + ";\n")
|
||||
|
||||
|
||||
|
||||
# copy web assets into destdir:
|
||||
global_assets = os.path.join(util.get_program_path(), "overviewer_core", "data", "web_assets")
|
||||
if not os.path.isdir(global_assets):
|
||||
@@ -159,23 +158,16 @@ directory.
|
||||
js_src = os.path.join(util.get_program_path(), "overviewer_core", "data", "js_src")
|
||||
if not os.path.isdir(js_src):
|
||||
js_src = os.path.join(util.get_program_path(), "js_src")
|
||||
with open(os.path.join(self.outputdir, "overviewer.js"), "w") as fout:
|
||||
# first copy in js_src/overviewer.js
|
||||
with open(os.path.join(js_src, "overviewer.js")) as f:
|
||||
fout.write(f.read())
|
||||
# now copy in the rest
|
||||
for js in os.listdir(js_src):
|
||||
if not js.endswith("overviewer.js") and js.endswith(".js"):
|
||||
with open(os.path.join(js_src,js)) as f:
|
||||
fout.write(f.read())
|
||||
|
||||
# do the same with the local copy, if we have it
|
||||
# TODO
|
||||
# if self.web_assets_path:
|
||||
# util.mirror_dir(self.web_assets_path, self.outputdir)
|
||||
|
||||
|
||||
|
||||
with util.FileReplacer(os.path.join(self.outputdir, "overviewer.js")) as tmpfile:
|
||||
with open(tmpfile, "w") as fout:
|
||||
# first copy in js_src/overviewer.js
|
||||
with open(os.path.join(js_src, "overviewer.js"), 'r') as f:
|
||||
fout.write(f.read())
|
||||
# now copy in the rest
|
||||
for js in os.listdir(js_src):
|
||||
if not js.endswith("overviewer.js") and js.endswith(".js"):
|
||||
with open(os.path.join(js_src,js)) as f:
|
||||
fout.write(f.read())
|
||||
# helper function to get a label for the given rendermode
|
||||
def get_render_mode_label(rendermode):
|
||||
info = get_render_mode_info(rendermode)
|
||||
@@ -193,7 +185,6 @@ directory.
|
||||
versionstr = "%s (%s)" % (overviewer_version.VERSION, overviewer_version.HASH[:7])
|
||||
index = index.replace("{version}", versionstr)
|
||||
|
||||
with codecs.open(os.path.join(self.outputdir, "index.html"), 'w', encoding='UTF-8') as output:
|
||||
output.write(index)
|
||||
|
||||
|
||||
with util.FileReplacer(indexpath) as indexpath:
|
||||
with codecs.open(indexpath, 'w', encoding='UTF-8') as output:
|
||||
output.write(index)
|
||||
|
||||
Reference in New Issue
Block a user