def reload(self, browscap_file_path=None): """ Reloads new data to this Browscap instance. This is useful mainly in apps that run in long living threads, like django projects. :param browscap_file_path: location of new browcap file on filesystem, or use old :type browscap_file_path: string or None :returns: None :raises: IOError """ global load_csv_file if load_csv_file is None: from pybrowscap.loader.csv import load_file as load_csv_file try: file_to_load = browscap_file_path or self.browscap_file_path log.info('Reloading browscap instance with file %s', file_to_load) if self.type == TYPE_CSV: reloaded_browscap = load_csv_file(file_to_load) self.data = reloaded_browscap.data self.regex_cache = reloaded_browscap.regex_cache self.version = reloaded_browscap.version self.release_date = reloaded_browscap.release_date self.browscap_file_path = file_to_load self.cache = {} self.reloaded_at = datetime.now() except IOError: log.exception('Error while reloading Browscap instance with file %s', file_to_load) raise
def reload(self, browscap_file_path=None): """ Reloads new data to this Browscap instance. This is useful mainly in apps that run in long living threads, like django projects. """ from pybrowscap.loader.csv import load_file as load_csv_file try: file_to_load = browscap_file_path or self.browscap_file_path if self.type == TYPE_CSV: reloaded_browscap = load_csv_file(file_to_load) self.data = reloaded_browscap.data self.regex_cache = reloaded_browscap.regex_cache self.version = reloaded_browscap.version self.release_date = reloaded_browscap.release_date self.browscap_file_path = file_to_load self.cache = {} self.reloaded_at = datetime.now() except Exception: log.exception('Error while reloading Browscap instance') raise