class NikwebHttp(object): L = logging.getLogger('nikweb.http') def __init__(self, map_definitions, **kwargs): if not os.path.exists(map_definitions): raise ValueError("Map definitions directory doesn't exist: %s" % map_definitions) self.render_factory = NikwebRenderFactory(**kwargs) # preload the map definitions self.map_def_path = os.path.abspath(os.path.normpath(map_definitions)) self.preload_definitions() def preload_definitions(self): self.L.info("Using map definitions from: %s", self.map_def_path) map_files = filter(lambda x: x.endswith('.xml'), os.listdir(self.map_def_path)) t_start = time.time() for map_file in map_files: self.L.info("Loading %s ...", os.path.splitext(os.path.split(map_file)[1])[0]) try: self.render_factory.getMap(os.path.join(self.map_def_path, map_file)) except Exception, e: self.L.warn("Couldn't load %s: %s", map_file, e) t_end = time.time() self.L.info("Loaded %d maps in %0.2f seconds.", len(map_files), (t_end-t_start))
class NikwebHttp(object): L = logging.getLogger('nikweb.http') def __init__(self, map_definitions, **kwargs): if not os.path.exists(map_definitions): raise ValueError("Map definitions directory doesn't exist: %s" % map_definitions) self.render_factory = NikwebRenderFactory(**kwargs) # preload the map definitions self.map_def_path = os.path.abspath(os.path.normpath(map_definitions)) self.preload_definitions() def preload_definitions(self): self.L.info("Using map definitions from: %s", self.map_def_path) map_files = filter(lambda x: x.endswith('.xml'), os.listdir(self.map_def_path)) t_start = time.time() for map_file in map_files: self.L.info("Loading %s ...", os.path.splitext(os.path.split(map_file)[1])[0]) try: self.render_factory.getMap( os.path.join(self.map_def_path, map_file)) except Exception, e: self.L.warn("Couldn't load %s: %s", map_file, e) t_end = time.time() self.L.info("Loaded %d maps in %0.2f seconds.", len(map_files), (t_end - t_start))
def __init__(self, map_definitions, **kwargs): if not os.path.exists(map_definitions): raise ValueError("Map definitions directory doesn't exist: %s" % map_definitions) self.render_factory = NikwebRenderFactory(**kwargs) # preload the map definitions self.map_def_path = os.path.abspath(os.path.normpath(map_definitions)) self.preload_definitions()