Add --update-web-assets option
This commit is contained in:
@@ -83,6 +83,8 @@ def main():
|
||||
help="Prints the location and hash of terrain.png, useful for debugging terrain.png problems")
|
||||
parser.add_option("-V", "--version", dest="version",
|
||||
help="Displays version information and then exits", action="store_true")
|
||||
parser.add_option("--update-web-assets", dest='update_web_assets', action="store_true",
|
||||
help="Update web assets. Will *not* render tiles or update overviewerConfig.js")
|
||||
|
||||
# Log level options:
|
||||
parser.add_option("-q", "--quiet", dest="quiet", action="count", default=0,
|
||||
@@ -334,6 +336,18 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
||||
logging.exception("Could not create the output directory.")
|
||||
return 1
|
||||
|
||||
########################################################################
|
||||
# Now we start the actual processing, now that all the configuration has
|
||||
# been gathered and validated
|
||||
# create our asset manager... ASSMAN
|
||||
assetMrg = assetmanager.AssetManager(destdir, config.get('customwebassets', None))
|
||||
|
||||
# If we've been asked to update web assets, do that and then exit
|
||||
if options.update_web_assets:
|
||||
assetMrg.output_noconfig()
|
||||
logging.info("Web assets have been updated")
|
||||
return 0
|
||||
|
||||
# The changelist support.
|
||||
changelists = {}
|
||||
for render in config['renders'].itervalues():
|
||||
@@ -347,13 +361,6 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
||||
out = changelists[path]
|
||||
render['changelist'] = out.fileno()
|
||||
|
||||
|
||||
########################################################################
|
||||
# Now we start the actual processing, now that all the configuration has
|
||||
# been gathered and validated
|
||||
# create our asset manager... ASSMAN
|
||||
assetMrg = assetmanager.AssetManager(destdir, config.get('customwebassets', None))
|
||||
|
||||
tilesets = []
|
||||
|
||||
# saves us from creating the same World object over and over again
|
||||
|
||||
@@ -135,6 +135,17 @@ directory.
|
||||
blank = Image.new("RGBA", (1,1), tileset.options.get('bgcolor'))
|
||||
blank.save(os.path.join(self.outputdir, tileset.options.get('name'), "blank." + tileset.options.get('imgformat')))
|
||||
|
||||
# write out config
|
||||
jsondump = json.dumps(dump, indent=4)
|
||||
with 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 assets, modify index.html
|
||||
self.output_noconfig()
|
||||
|
||||
|
||||
def output_noconfig(self):
|
||||
|
||||
# copy web assets into destdir:
|
||||
global_assets = os.path.join(util.get_program_path(), "overviewer_core", "data", "web_assets")
|
||||
@@ -168,12 +179,6 @@ directory.
|
||||
with open(os.path.join(js_src,js)) as f:
|
||||
fout.write(f.read())
|
||||
|
||||
# write out config
|
||||
jsondump = json.dumps(dump, indent=4)
|
||||
with 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")
|
||||
|
||||
# Add time and version in index.html
|
||||
indexpath = os.path.join(self.outputdir, "index.html")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user