def store_report(self, payload):
        """
        Save the crash report to a file. Keeping the last `offline_report_limit` files in a cyclical FIFO buffer.
        The newest crash report always named is 01
        """
        offline_reports = self.get_offline_reports()
        if offline_reports:
            # Increment the name of all existing reports 1 --> 2, 2 --> 3 etc.
            for ii, report in enumerate(reversed(offline_reports)):
                rpath, ext = os.path.splitext(report)
                n = int(re.findall('(\d+)', rpath)[-1])
                new_name = os.path.join(self.report_dir, self._report_name % (n + 1)) + ext
                shutil.copy2(report, new_name)
            os.remove(report)
            # Delete the oldest report
            if len(offline_reports) >= self.offline_report_limit:
                oldest = glob.glob(os.path.join(self.report_dir, self._report_name % (self.offline_report_limit+1) + '*'))[0]
                os.remove(oldest)
        new_report_path = os.path.join(self.report_dir, self._report_name % 1 + '.json')
        # Write a new report
        with open(new_report_path, 'w') as _f:
            json.dump(payload, _f)

        return new_report_path
def store_report ( self , payload ) : offline_reports = self . get_offline_reports ( ) if offline_reports : for ii , report in enumerate ( reversed ( offline_reports ) ) : rpath , ext = os . path . splitext ( report ) n = int ( re . findall ( '(\d+)' , rpath ) [ - 1 ] ) new_name = os . path . join ( self . report_dir , self . _report_name % ( n + 1 ) ) + ext shutil . copy2 ( report , new_name ) os . remove ( report ) if len ( offline_reports ) >= self . offline_report_limit : oldest = glob . glob ( os . path . join ( self . report_dir , self . _report_name % ( self . offline_report_limit + 1 ) + '*' ) ) [ 0 ] os . remove ( oldest ) new_report_path = os . path . join ( self . report_dir , self . _report_name % 1 + '.json' ) with open ( new_report_path , 'w' ) as _f : json . dump ( payload , _f ) return new_report_path
Save the crash report to a file. Keeping the last `offline_report_limit` files in a cyclical FIFO buffer.
        The newest crash report always named is 01