def delete_read_file(self, current_file: EventStorageReaderPointer):
     data_files = self.files.get_data_files()
     if exists(self.settings.get_data_folder_path() + current_file.file):
         remove(self.settings.get_data_folder_path() + current_file.file)
         self.files.set_data_files(data_files[1:])
         log.info("FileStorage_reader -- Cleanup old data file: %s%s!",
                  self.settings.get_data_folder_path(), current_file.file)
Ejemplo n.º 2
0
 def read_state_file(self):
     try:
         state_data_node = {}
         try:
             with BufferedReader(FileIO(self.settings.get_data_folder_path() +
                                              self.files.get_state_file(), 'r')) as br:
                 state_data_node = load(br)
         except JSONDecodeError:
             log.error("Failed to decode JSON from state file")
             state_data_node = 0
         except IOError as e:
             log.warning("Failed to fetch info from state file!", e)
         reader_file = None
         reader_pos = 0
         if state_data_node:
             reader_pos = state_data_node['position']
             for file in sorted(self.files.get_data_files()):
                 if file == state_data_node['file']:
                     reader_file = file
                     break
         if reader_file is None:
             reader_file = sorted(self.files.get_data_files())[0]
             reader_pos = 0
         log.info("FileStorage_reader -- Initializing from state file: [%s:%i]",
                  self.settings.get_data_folder_path() + reader_file,
                  reader_pos)
         return EventStorageReaderPointer(reader_file, reader_pos)
     except Exception as e:
         log.exception(e)
 def delete_read_file(self, current_file: EventStorageReaderPointer):
     try:
         data_files = self.files.get_data_files()
         if exists(self.settings.get_data_folder_path() + current_file.file):
             remove(self.settings.get_data_folder_path() + current_file.file)
             data_files.remove(current_file.file)
             log.info("FileStorage_reader -- Cleanup old data file: %s%s!", self.settings.get_data_folder_path(), current_file.file)
     except Exception as e:
         log.exception(e)