problem_report - Store, load, and handle problem reports.
| Use Case | Command | Description |
|---|---|---|
| 📄 Create crash report | report = ProblemReport(type='Crash') | Initialize a fresh crash report with current time |
| 📂 Load report from file | report.load(open('file.crash', 'rb')) | Read binary RFC822 report |
| 💾 Write report to file | report.write(open('file.crash', 'wb')) | Write report preserving binary data |
| 📎 Attach binary file | report['Key'] = ('file.bin', True, limit) | Attach and gzip-compress a file |
| 📧 Write MIME report | report.write_mime(open('out.mime', 'wb')) | Output multipart MIME with attachments |
| 🕒 Get timestamp | report.get_timestamp() | Unix timestamp from Date field |
builtins.object
CompressedValuecollections.UserDict(collections.abc.MutableMapping)
ProblemReportclass CompressedValue(builtins.object)
Represent a ProblemReport value which is gzip compressed.
Methods defined here:__init__(self, value=None, name=None) — Initialize an empty CompressedValue object with an optional name.__len__(self) — Return length of uncompressed value.get_value(self) — Return uncompressed value.set_value(self, value) — Set uncompressed value.splitlines(self) — Behaves like splitlines() for a normal string.write(self, file) — Write uncompressed value into given file-like object.__dict__ — dictionary for instance variables (if defined)__weakref__ — list of weak references to the object (if defined)class ProblemReport(collections.UserDict)
__init__(self, type='Crash', date=None) — Initialize a fresh problem report. type can be 'Crash', 'Packaging', 'KernelCrash' or 'KernelOops'. date is the desired date/time string; if None (default), the current local time is used.__setitem__(self, k, v)add_to_existing(self, reportfile, keep_times=False) — Add this report's data to an already existing report file. The file will be temporarily chmod'ed to 000 to prevent frontends from picking up a hal-updated report file. If keep_times is True, then the file's atime and mtime restored after updating.extract_keys(self, file, bin_keys, dir) — Extract only one binary element from the problem_report. Binary elements like kernel crash dumps can be very big. This method extracts directly files without loading the report into memory.get_timestamp(self) -> int — Get timestamp (seconds since epoch) from Date field. Return None if it is not present.has_removed_fields(self) — Check if the report has any keys which were not loaded. This could happen when using binary=False in load().load(self, file, binary=True, key_filter=None) — Initialize problem report from a file-like object. If binary is False, binary data is not loaded; the dictionary key is created, but its value will be an empty string. If it is True, it is transparently uncompressed and available as dictionary byte array values. If binary is 'compressed', the compressed value is retained, and the dictionary value will be a CompressedValue object. This is useful if the compressed value is still useful (to avoid recompression if the file needs to be written back). file needs to be opened in binary mode. If key_filter is given, only those keys will be loaded. Files are in RFC822 format, but with case sensitive keys.new_keys(self) — Return newly added keys. Return the set of keys which have been added to the report since it was constructed or loaded.write(self, file, > — Write information into the given file-like object. If only_new is True, only keys which have been added since the last load() are written (i. e. those returned by new_keys()). If a value is a string, it is written directly. Otherwise it must be a tuple of the form (file, encode=True, limit=None, fail_on_empty=False). The first argument can be a file name or a file-like object, which will be read and its content will become the value of this key. 'encode' specifies whether the contents will be gzip compressed and base64-encoded (this defaults to True). If limit is set to a positive integer, the file is not attached if it's larger than the given limit, and the entire key will be removed. If fail_on_empty is True, reading zero bytes will cause an IOError. file needs to be opened in binary mode. Files are written in RFC822 format.write_mime(self, file, attach_treshold=5, extra_headers={}, skip_keys=None, priority_fields=None) — Write MIME/Multipart RFC 2822 formatted data into file. file must be a file-like object, not a path. It needs to be opened in binary mode. If a value is a string or a CompressedValue, it is written directly. Otherwise it must be a tuple containing the source file and an optional boolean value (in that order); the first argument can be a file name or a file-like object, which will be read and its content will become the value of this key. The file will be gzip compressed, unless the key already ends in .gz. attach_treshold specifies the maximum number of lines for a value to be included into the first inline text part. All bigger values (as well as all non-ASCII ones) will become an attachment, as well as text values bigger than 1 kB. Extra MIME preamble headers can be specified, too, as a dictionary. skip_keys is a set/list specifying keys which are filtered out and not written to the destination file. priority_fields is a set/list specifying the order in which keys should appear in the destination file.__abstractmethods__ = frozenset()__contains__(self, key) — # Modify __contains__ to work correctly when __missing__ is present__copy__(self)__delitem__(self, key)__getitem__(self, key)__ior__(self, other)__iter__(self)__len__(self)__or__(self, other) — Return self|value.__repr__(self) — Return repr(self).__ror__(self, other) — Return value|self.copy(self)fromkeys(iterable, value=None) from abc.ABCMeta__dict__ — dictionary for instance variables (if defined)__weakref__ — list of weak references to the object (if defined)clear(self) — D.clear() -> None. Remove all items from D.pop(self, key, default=<object object at 0x7f1119308190>) — D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.popitem(self) — D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.setdefault(self, key, default=None) — D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in Dupdate(self, other=(), /, **kwds) — D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v__eq__(self, other) — Return self==value.get(self, key, default=None) — D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.items(self) — D.items() -> a set-like object providing a view on D's itemskeys(self) — D.keys() -> a set-like object providing a view on D's keysvalues(self) — D.values() -> an object providing a view on D's values__hash__ = None__reversed__ = None__subclasshook__(C) from abc.ABCMeta — Abstract classes can override this to customize issubclass(). This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).__class_getitem__ = GenericAlias(...) from abc.ABCMeta — Represent a PEP 585 generic type. E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,)./usr/lib/python3/dist-packages/problem_report.py
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 16:12 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format