From 83caa5f4560b0c10e74a6c751133668a1f34ad77 Mon Sep 17 00:00:00 2001 From: Thomas Lake Date: Sun, 12 Aug 2012 16:37:35 +0100 Subject: [PATCH] Add --update-web-assets option --- overviewer.py | 21 ++++++++++++++------- overviewer_core/assetmanager.py | 17 +++++++++++------ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/overviewer.py b/overviewer.py index 4faad85..da37d10 100755 --- a/overviewer.py +++ b/overviewer.py @@ -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 diff --git a/overviewer_core/assetmanager.py b/overviewer_core/assetmanager.py index 984c7f9..4825a65 100644 --- a/overviewer_core/assetmanager.py +++ b/overviewer_core/assetmanager.py @@ -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")