How to use the jrnl.Utils.load function in jrnl

To help you get started, we’ve selected a few jrnl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / qpid / qpid / cpp / management / python / lib / qpidstore / janal.py View on Github external
def _analyze(self):
        """Perform the journal file analysis by reading and comparing the file headers of each journal data file"""
        owi_found = False
        flist = []
        for i in range(0, self.__jinf.get_num_jrnl_files()):
            jfn = os.path.join(self.__jinf.get_current_dir(), "%s.%04x.jdat" % (self.__jinf.get_jrnl_base_name(), i))
            fhandle = open(jfn)
            fhdr = jrnl.Utils.load(fhandle, jrnl.Hdr)
            if fhdr.empty():
                break
            this_tup = (i, jfn, fhdr.owi(), fhdr.rid, fhdr.fro, fhdr.timestamp_str())
            flist.append(this_tup)
            if i == 0:
                init_owi = fhdr.owi()
                self.__oldest = this_tup
            elif fhdr.owi() != init_owi and not owi_found:
                self.__oldest = this_tup
                owi_found = True
        return flist
github apache / qpid / qpid / cpp / management / python / lib / qpidstore / janal.py View on Github external
def _get_next_record(self):
        """Get the next record in the file for analysis"""
        if self._is_file_full():
            if self._advance_jrnl_file():
                return True
        try:
            hdr = jrnl.Utils.load(self._file, jrnl.Hdr)
        except:
            return True
        if hdr.empty():
            return True
        if hdr.check():
            return True
        self._rec_cnt += 1
        self._file_hdr_owi = self._file_hdr.owi()
        if self._first_rec_flag:
            if self._file_hdr.fro != hdr.foffs:
                raise jerr.FirstRecordOffsetMismatch(self._file_hdr.fro, hdr.foffs)
            else:
                if self._rflag:
                    print " * fro ok: 0x%x" % self._file_hdr.fro
                self._first_rec_flag = False
        stop = False
github apache / qpid / qpid / cpp / management / python / lib / qpidstore / janal.py View on Github external
print "Recovering journals",
        if self._file != None and self._is_file_full():
            self._file.close()
            self._file_num = self._incr_file_num()
            if self._file_num == self._start_file_num:
                return True
            if self._start_file_num == 0:
                self._last_file_flag = self._file_num == self._jinfo.get_num_jrnl_files() - 1
            else:
                self._last_file_flag = self._file_num == self._start_file_num - 1
        if self._file_num < 0 or self._file_num >= self._jinfo.get_num_jrnl_files():
            raise jerr.BadFileNumberError(self._file_num)
        jfn = os.path.join(self._jinfo.get_current_dir(), "%s.%04x.jdat" %
                           (self._jinfo.get_jrnl_base_name(), self._file_num))
        self._file = open(jfn)
        self._file_hdr = jrnl.Utils.load(self._file, jrnl.Hdr)
        if fro_seek_flag and self._file.tell() != self._fro:
            self._file.seek(self._fro)
        self._first_rec_flag = True
        if not self._qflag:
            if self._rflag:
                print jfn, ": ", self._file_hdr
            elif self._vflag:
                print "* Reading %s" % jfn
            else:
                print ".",
                sys.stdout.flush()
        return False