def save_cache(cls, outputdir): cache_file = os.path.join(outputdir, "uuidcache.dat") caps = get_fs_caps(outputdir) with FileReplacer(cache_file, caps) as cache_file_name: with closing(gzip.GzipFile(cache_file_name, "wb")) as gz: gz.write(json.dumps(cls.uuid_cache).encode()) logging.info("Wrote UUID cache with %d entries.", len(cls.uuid_cache.keys()))
def save_cache(cls, outputdir): cache_file = os.path.join(outputdir, "uuidcache.dat") caps = get_fs_caps(outputdir) with FileReplacer(cache_file, caps) as cache_file_name: with closing(gzip.GzipFile(cache_file_name, "wb")) as gz: json.dump(cls.uuid_cache, gz) logging.info("Wrote UUID cache with %d entries", len(cls.uuid_cache.keys()))
import os from overviewer_core import util from overviewer_core.files import FileReplacer, get_fs_caps outputdir = '/var/www/minecraft/map' # create overviewer.js from the source js files 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 FileReplacer(os.path.join(outputdir, "overviewer.js"), capabilities=get_fs_caps(outputdir)) 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())