def get_counters(config): from infi.app_repo.persistent_dict import PersistentDict ftp_counters = PersistentDict(config.ftpserver_counters_filepath) ftp_counters.load() web_counters = PersistentDict(config.webserver_counters_filepath) web_counters.load() all_counters = {} all_counters.update(ftp_counters) for key, value in web_counters.items(): all_counters[key] = all_counters.get(key, value) + 1 return all_counters
def _register_counters(self): from infi.app_repo.persistent_dict import PersistentDict def _func(response): if response.status_code == 200: key = flask.request.path self.counters[key] = self.counters.get(key, 0) + 1 return response self.counters = PersistentDict(self.app_repo_config.webserver_counters_filepath) self.counters.load() self.after_request(_func)