{
    "mode": "pydoc",
    "parameter": "apport",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/apport/json",
    "generated": "2026-12-01T18:03:17Z",
    "sections": {
        "NAME": {
            "content": "apport - Apport Python module.\n",
            "subsections": []
        },
        "PACKAGE CONTENTS": {
            "content": "REThread\ncrashdb\ncrashdbimpl (package)\nfileutils\nhookutils\nlogging\npackaging\npackagingimpl (package)\nreport\nsandboxutils\nui\nusergroup\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "problemreport.ProblemReport(collections.UserDict)\napport.report.Report\n",
            "subsections": [
                {
                    "name": "class Report",
                    "content": "|  Report(problemtype: str = 'Crash', date: str | None = None) -> None\n|\n|  A problem report specific to apport (crash or bug).\n|\n|  This class wraps a standard ProblemReport and adds methods for collecting\n|  standard debugging data.\n|\n|  Method resolution order:\n|      Report\n|      problemreport.ProblemReport\n|      collections.UserDict\n|      collections.abc.MutableMapping\n|      collections.abc.Mapping\n|      collections.abc.Collection\n|      collections.abc.Sized\n|      collections.abc.Iterable\n|      collections.abc.Container\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  init(self, problemtype: str = 'Crash', date: str | None = None) -> None\n|      Initialize a fresh problem report.\n|\n|      date is the desired date/time string; if None (default), the current\n|      local time is used.\n|\n|      If the report is attached to a process ID, this should be set in\n|      self.pid, so that e. g. hooks can use it to collect additional data.\n|\n|  addgdbinfo(self, rootdir: str | None = None, gdbsandbox: str | None = None) -> None\n|      Add information from gdb.\n|\n|      This requires that the report has a CoreDump and an\n|      ExecutablePath. This adds the following fields:\n|      - Registers: Output of gdb's 'info registers' command\n|      - Disassembly: Output of gdb's 'x/16i $pc' command\n|      - Stacktrace: Output of gdb's 'bt full' command\n|      - ThreadStacktrace: Output of gdb's 'thread apply all bt full' command\n|      - StacktraceTop: simplified stacktrace (topmost 5 functions) for inline\n|        inclusion into bug reports and easier processing\n|      - AssertionMessage: Value of abortmsg, glibassertmsg, or\n|        nihabortmsg if present\n|\n|      The optional rootdir can specify a root directory which has the\n|      executable, libraries, and debug symbols. This does not require\n|      chroot() or root privileges, it just instructs gdb to search for the\n|      files there.\n|\n|      Raises a OSError if the core dump is invalid/truncated, or OSError if\n|      calling gdb fails, or FileNotFoundError if gdb or the crashing\n|      executable cannot be found.\n|\n|  addhooksinfo(self, ui: apport.ui.HookUI | None = None, package: str | None = None, srcpackage: str | None = None) -> bool\n|      Run hook script for collecting package specific data.\n|\n|      A hook script needs to be in PACKAGEHOOKDIR/<Package>.py or in\n|      GENERALHOOKDIR/*.py and has to contain a function 'addinfo(report,\n|      ui)' that takes and modifies a Report, and gets an UserInterface\n|      reference for interactivity.\n|\n|      return True if the hook requested to stop the report filing process,\n|      False otherwise.\n|\n|  addkernelcrashinfo(self) -> bool\n|      Add information from kernel crash.\n|\n|      This needs a VmCore in the Report.\n|\n|  addosinfo(self) -> None\n|      Add operating system information.\n|\n|      This adds:\n|      - DistroRelease: NAME and VERSION from /etc/os-release, or\n|        'lsbrelease -sir' output\n|      - Architecture: system architecture in distro specific notation\n|      - Uname: uname -srm output\n|\n|  addpackage(self, package: str) -> str | None\n|      Add Package: field.\n|\n|      Determine the version of the given package (uses \"(not installed\") for\n|      uninstalled packages) and add Package: field to report.\n|      This also checks for any modified files.\n|\n|      Return determined package version (None for uninstalled).\n|\n|  addpackageinfo(self, package: str | None = None) -> None\n|      Add packaging information.\n|\n|      If package is not given, the report must have ExecutablePath.\n|      This adds:\n|      - Package: package name and installed version\n|      - SourcePackage: source package name (if possible to determine)\n|      - PackageArchitecture: processor architecture this package was built\n|        for\n|      - Dependencies: package names and versions of all dependencies and\n|        pre-dependencies; this also checks if the files are unmodified and\n|        appends a list of all modified files\n|\n|  addprocenviron(self, pid: int | None = None, extraenv: collections.abc.Iterable[str] | None = None, procpidfd: int | None = None) -> None\n|      Add environment information.\n|\n|      If pid is not given, it defaults to the process' current pid.\n|\n|      This adds the following fields:\n|      - ProcEnviron: A subset of the process' environment (only some standard\n|        variables that do not disclose potentially sensitive information,\n|        plus the ones mentioned in extraenv)\n|      - CurrentDesktop: Value of $XDGCURRENTDESKTOP, if present\n|\n|  addprocinfo(self, pid: int | str | None = None, procpidfd: int | None = None, extraenv: collections.abc.Iterable[str] | None = None) -> None\n|      Add /proc/pid information.\n|\n|      If neither pid nor self.pid are given, it defaults to the process'\n|      current pid and sets self.pid.\n|\n|      This adds the following fields:\n|      - ExecutablePath: /proc/pid/exe contents; if the crashed process is\n|        interpreted, this contains the script path instead\n|      - InterpreterPath: /proc/pid/exe contents if the crashed process is\n|        interpreted; otherwise this key does not exist\n|      - ExecutableTimestamp: time stamp of ExecutablePath, for comparing at\n|        report time\n|      - ProcEnviron: A subset of the process' environment (only some standard\n|        variables that do not disclose potentially sensitive information,\n|        plus the ones mentioned in extraenv)\n|      - ProcCmdline: /proc/pid/cmdline contents\n|      - ProcStatus: /proc/pid/status contents\n|      - ProcMaps: /proc/pid/maps contents\n|      - ProcAttrCurrent: /proc/pid/attr/current contents, if not \"unconfined\"\n|      - CurrentDesktop: Value of $XDGCURRENTDESKTOP, if present\n|\n|  addsnapcontactinfo(self, snapcontact: str) -> None\n|      Load report with information about where it should be filed.\n|\n|      Parse project (e.g. 'subiquity') or source package string\n|      (e.g. 'ubuntu/+source/gnome-calculator') from snap 'contact'.\n|      Additionally, extract any tag/tags defined in the contact URL.\n|\n|  addsnapinfo(self, snap)\n|      Add info about an installed Snap.\n|\n|      This adds a Snap: field, containing name, version and channel.\n|      It adds a SnapSource: field, if the snap has a Launchpad contact\n|      defined.\n|\n|  adduserinfo(self) -> None\n|      Add information about the user.\n|\n|      This adds:\n|      - UserGroups: system groups the user is in\n|\n|  anonymize(self) -> None\n|      Remove user identifying strings from the report.\n|\n|      This particularly removes the user name, host name, and IPs\n|      from attributes which contain data read from the environment, and\n|      removes the ProcCwd attribute completely.\n|\n|  checkignored(self) -> bool\n|      Check if current report should not be presented.\n|\n|      Reports can be suppressed by per-user denylisting in\n|      ~/.apport-ignore.xml (in the real UID's home) and\n|      /etc/apport/report-ignore/. For environments where you are only\n|      interested in crashes of some programs, you can also create an\n|      allowlist in /etc/apport/report-only/, everything which does not\n|      match gets ignored then.\n|\n|      This requires the ExecutablePath attribute. Throws a ValueError if the\n|      file has an invalid format.\n|\n|      Privileges may need to be dropped before calling this.\n|\n|  crashsignature(self) -> str | None\n|      Get a signature string for a crash.\n|\n|      This is suitable for identifying duplicates.\n|\n|      For signal crashes this the concatenation of ExecutablePath, Signal\n|      number, and StacktraceTop function names, separated by a colon. If\n|      StacktraceTop has unknown functions or the report lacks any of those\n|      fields, return None. In this case, you can use\n|      crashsignatureaddresses() to get a less precise duplicate signature\n|      based on addresses instead of symbol names.\n|\n|      For assertion failures, it is the concatenation of ExecutablePath\n|      and assertion message, separated by colons.\n|\n|      For Python crashes, this concatenates the ExecutablePath, exception\n|      name, and Traceback function names, again separated by a colon.\n|\n|      For suspend/resume failures, this concatenates whether it was a suspend\n|      or resume failure with the hardware identifier and the BIOS version, if\n|      it exists.\n|\n|  crashsignatureaddresses(self) -> str | None\n|      Compute heuristic duplicate signature for a signal crash.\n|\n|      This should be used if crashsignature() fails, i. e. Stacktrace does\n|      not have enough symbols.\n|\n|      This approach only uses addresses in the stack trace and does not rely\n|      on symbol resolution. As we can't unwind these stack traces, we cannot\n|      limit them to the top five frames and thus will end up with several or\n|      many different signatures for a particular crash. But these can be\n|      computed and synchronously checked with a crash database at the client\n|      side, which avoids having to upload and process the full report. So on\n|      the server-side crash database we will only have to deal with all the\n|      equivalence classes (i. e. same crash producing a number of possible\n|      signatures) instead of every single report.\n|\n|      Return None when signature cannot be determined.\n|\n|  gdbcommand(self, sandbox: str | None, gdbsandbox: str | None = None) -> tuple[list[str], dict[str, str]]\n|      Build gdb command for this report.\n|\n|      This builds a gdb command for processing the given report, by setting\n|      the file to the ExecutablePath/InterpreterPath, unpacking the core dump\n|      and pointing \"core-file\" to it (if the report has a core dump), and\n|      setting up the paths when calling gdb in a package sandbox.\n|\n|      When available, this calls \"gdb-multiarch\" instead of \"gdb\", for\n|      processing crash reports from foreign architectures.\n|\n|      Return argv list for gdb and any environment variables.\n|\n|  hasusefulstacktrace(self) -> bool\n|      Check whether StackTrace can be considered 'useful'.\n|\n|      The current heuristic is to consider it useless if it either is shorter\n|      than three lines and has any unknown function, or for longer traces, a\n|      minority of known functions.\n|\n|  markignore(self) -> None\n|      Ignore future crashes of this executable.\n|\n|      Add a ignore list entry for this report to ~/.apport-ignore.xml, so\n|      that future reports for this ExecutablePath are not presented to the\n|      user any more.\n|\n|      Throws a ValueError if the file already exists and has an invalid\n|      format.\n|\n|      Privileges may need to be dropped before calling this.\n|\n|  obsoletepackages(self) -> list[str]\n|      Return list of obsolete packages in Package and Dependencies.\n|\n|  searchbugpatterns(self, url: str | None) -> str | None\n|      Check bug patterns loaded from the specified url.\n|\n|      Return bug URL on match, or None otherwise.\n|\n|      The url must refer to a valid XML document with the following syntax:\n|      root element := <patterns>\n|      patterns := <pattern url=\"http://bug.url\"> *\n|      pattern := <re key=\"reportkey\">regular expression*</re> +\n|\n|      For example:\n|      <?xml version=\"1.0\"?>\n|      <patterns>\n|          <pattern url=\"http://bugtracker.net/bugs/1\">\n|              <re key=\"Foo\">ba.*r</re>\n|          </pattern>\n|          <pattern url=\"http://bugtracker.net/bugs/2\">\n|              <re key=\"Package\">^\\\\S* 1-2$</re>\n|              <!-- test for a particular version -->\n|              <re key=\"Foo\">write(hello|goodbye)</re>\n|          </pattern>\n|      </patterns>\n|\n|  stacktracetopfunction(self) -> str | None\n|      Return topmost function in StacktraceTop.\n|\n|  standardtitle(self) -> str | None\n|      Create an appropriate title for a crash database entry.\n|\n|      This contains the topmost function name from the stack trace and the\n|      signal (for signal crashes) or the Python exception (for unhandled\n|      Python exceptions).\n|\n|      Return None if the report is not a crash or a default title could not\n|      be generated.\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  fromsystemdcoredump(coredump)\n|      Convert the givin systemd coredump into a problem report.\n|\n|      The following keys are not used:\n|       * COREDUMPCGROUP (str)\n|       * COREDUMPCOMM (str)\n|       * COREDUMPCONTAINERCMDLINE (str)\n|       * COREDUMPGID (int)\n|       * COREDUMPHOSTNAME (str)\n|       * COREDUMPOPENFDS (str)\n|       * COREDUMPOWNERUID (str)\n|       * COREDUMPPACKAGEJSON (str)\n|       * COREDUMPPACKAGENAME\n|       * COREDUMPPACKAGEVERSION\n|       * COREDUMPPROCAUXV (bytes)\n|       * COREDUMPPROCCGROUP (str)\n|       * COREDUMPPROCLIMITS (str)\n|       * COREDUMPPROCMOUNTINFO (str)\n|       * COREDUMPRLIMIT (str)\n|       * COREDUMPROOT (str)\n|       * COREDUMPSESSION\n|       * COREDUMPSLICE (str)\n|       * COREDUMPUID (int)\n|       * COREDUMPUNIT (str)\n|       * COREDUMPUSERUNIT (str)\n|       * MESSAGE (str)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset()\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from problemreport.ProblemReport:\n|\n|  setitem(self, k: str, v: bytes | problemreport.CompressedFile | problemreport.CompressedValue | str | tuple) -> None\n|\n|  addtags(self, tags: collections.abc.Iterable[str]) -> None\n|      Add tags to the report. Duplicates are dropped.\n|\n|  addtoexisting(self, reportfile: str, keeptimes: bool = False) -> None\n|      Add this report's data to an already existing report file.\n|\n|      The file will be temporarily chmod'ed to 000 to prevent frontends\n|      from picking up a hal-updated report file. If keeptimes\n|      is True, then the file's atime and mtime restored after updating.\n|\n|  extractkeys(self, file: gzip.GzipFile | typing.BinaryIO, binkeys: collections.abc.Iterable[str] | str, directory: str) -> None\n|      Extract only given binary elements from the problem report.\n|\n|      Binary elements like kernel crash dumps can be very big. This method\n|      extracts directly files without loading the report into memory.\n|\n|  gettags(self) -> set[str]\n|      Return the set of tags.\n|\n|  gettimestamp(self) -> int | None\n|      Get timestamp (seconds since epoch) from Date field.\n|\n|      Return None if it is not present.\n|\n|  hasremovedfields(self) -> bool\n|      Check if the report has any keys which were not loaded.\n|\n|      This could happen when using binary=False in load().\n|\n|  load(self, file: gzip.GzipFile | typing.BinaryIO, binary: Union[bool, Literal['compressed']] = True, keyfilter: collections.abc.Iterable[str] | None = None) -> None\n|      Initialize problem report from a file-like object.\n|\n|      If binary is False, binary data is not loaded; the dictionary key is\n|      created, but its value will be an empty string. If it is True, it is\n|      transparently uncompressed and available as dictionary byte array\n|      values. If binary is 'compressed', the compressed value is retained,\n|      and the dictionary value will be a CompressedValue object. This is\n|      useful if the compressed value is still useful (to avoid recompression\n|      if the file needs to be written back).\n|\n|      file needs to be opened in binary mode.\n|\n|      If keyfilter is given, only those keys will be loaded.\n|\n|      Files are in RFC822 format, but with case sensitive keys.\n|\n|  newkeys(self) -> set[str]\n|      Return newly added keys.\n|\n|      Return the set of keys which have been added to the report since it\n|      was constructed or loaded.\n|\n|  sorteditems(self, keys: collections.abc.Iterable[str] | None = None) -> collections.abc.Iterator[tuple[str, bytes | problemreport.CompressedValue | str | tuple]]\n|      Iterate over all non-internal items sorted.\n|\n|      The most interesting fields will be returned first. The remaining\n|      items will be returned in alphabetical order. Keys starting with\n|      an underscore are considered internal and are skipped. Also values\n|      that are None will be skipped.\n|\n|      If keys is provided, only those keys will be iterated over.\n|\n|  write(self, file: <class 'BinaryIO'>, onlynew: bool = False) -> None\n|      Write information into the given file-like object.\n|\n|      If onlynew is True, only keys which have been added since the last\n|      load() are written (i. e. those returned by newkeys()).\n|\n|      If a value is a string, it is written directly. Otherwise it must be a\n|      tuple of the form (file, encode=True, limit=None, failonempty=False).\n|      The first argument can be a file name or a file-like object,\n|      which will be read and its content will become the value of this key.\n|      'encode' specifies whether the contents will be\n|      gzip compressed and base64-encoded (this defaults to True). If limit is\n|      set to a positive integer, the file is not attached if it's larger\n|      than the given limit, and the entire key will be removed. If\n|      failonempty is True, reading zero bytes will cause an OSError.\n|\n|      file needs to be opened in binary mode.\n|\n|      Files are written in RFC822 format.\n|\n|  writemime(self, file, attachtreshold=5, extraheaders=None, skipkeys=None, priorityfields=None)\n|      Write MIME/Multipart RFC 2822 formatted data into file.\n|\n|      file must be a file-like object, not a path.  It needs to be opened in\n|      binary mode.\n|\n|      If a value is a string or a CompressedValue, it is written directly.\n|      Otherwise it must be a tuple containing the source file and an optional\n|      boolean value (in that order); the first argument can be a file name or\n|      a file-like object, which will be read and its content will become the\n|      value of this key.  The file will be gzip compressed, unless the key\n|      already ends in .gz.\n|\n|      attachtreshold specifies the maximum number of lines for a value to be\n|      included into the first inline text part. All bigger values (as well as\n|      all non-ASCII ones) will become an attachment, as well as text\n|      values bigger than 1 kB.\n|\n|      Extra MIME preamble headers can be specified, too, as a dictionary.\n|\n|      skipkeys is a set/list specifying keys which are filtered out and not\n|      written to the destination file.\n|\n|      priorityfields is a set/list specifying the order in which keys should\n|      appear in the destination file.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from problemreport.ProblemReport:\n|\n|  isbinary(string: bytes | str) -> bool\n|      Check if the given strings contains binary data.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from collections.UserDict:\n|\n|  contains(self, key)\n|      # Modify contains and get() to work like dict\n|      # does when missing is present.\n|\n|  copy(self)\n|\n|  delitem(self, key)\n|\n|  getitem(self, key)\n|\n|  ior(self, other)\n|\n|  iter(self)\n|\n|  len(self)\n|\n|  or(self, other)\n|      Return self|value.\n|\n|  repr(self)\n|      Return repr(self).\n|\n|  ror(self, other)\n|      Return value|self.\n|\n|  copy(self)\n|\n|  get(self, key, default=None)\n|      D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.\n|\n|  ----------------------------------------------------------------------\n|  Class methods inherited from collections.UserDict:\n|\n|  fromkeys(iterable, value=None)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from collections.UserDict:\n|\n|  dict\n|      dictionary for instance variables\n|\n|  weakref\n|      list of weak references to the object\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from collections.abc.MutableMapping:\n|\n|  clear(self)\n|      D.clear() -> None.  Remove all items from D.\n|\n|  pop(self, key, default=<object object at 0x7f749b7501d0>)\n|      D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n|      If key is not found, d is returned if given, otherwise KeyError is raised.\n|\n|  popitem(self)\n|      D.popitem() -> (k, v), remove and return some (key, value) pair\n|      as a 2-tuple; but raise KeyError if D is empty.\n|\n|  setdefault(self, key, default=None)\n|      D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D\n|\n|  update(self, other=(), /, kwds)\n|      D.update([E, ]F) -> None.  Update D from mapping/iterable E and F.\n|      If E present and has a .keys() method, does:     for k in E: D[k] = E[k]\n|      If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v\n|      In either case, this is followed by: for k, v in F.items(): D[k] = v\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from collections.abc.Mapping:\n|\n|  eq(self, other)\n|      Return self==value.\n|\n|  items(self)\n|      D.items() -> a set-like object providing a view on D's items\n|\n|  keys(self)\n|      D.keys() -> a set-like object providing a view on D's keys\n|\n|  values(self)\n|      D.values() -> an object providing a view on D's values\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from collections.abc.Mapping:\n|\n|  hash = None\n|\n|  reversed = None\n|\n|  ----------------------------------------------------------------------\n|  Class methods inherited from collections.abc.Collection:\n|\n|  subclasshook(C)\n|      Abstract classes can override this to customize issubclass().\n|\n|      This is invoked early on by abc.ABCMeta.subclasscheck().\n|      It should return True, False or NotImplemented.  If it returns\n|      NotImplemented, the normal algorithm is used.  Otherwise, it\n|      overrides the normal algorithm (and the outcome is cached).\n|\n|  ----------------------------------------------------------------------\n|  Class methods inherited from collections.abc.Iterable:\n|\n|  classgetitem = GenericAlias(...)\n|      Represent a PEP 585 generic type\n|\n|      E.g. for t = list[int], t.origin is list and t.args is (int,).\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "error",
                    "content": "Print out an error message.\n"
                },
                {
                    "name": "fatal",
                    "content": "Print out an error message and exit the program.\n"
                },
                {
                    "name": "log",
                    "content": "Log the given string to stdout. Prepend timestamp if requested.\n"
                },
                {
                    "name": "memdbg",
                    "content": "Print current memory usage.\n\nThis is only done if $APPORTMEMDEBUG is set.\n"
                },
                {
                    "name": "unicode_gettext",
                    "content": "Return the localized translation of message.\n"
                },
                {
                    "name": "warning",
                    "content": "Print out an warning message.\n"
                }
            ]
        },
        "DATA": {
            "content": "all = ['Report', 'error', 'fatal', 'log', 'memdbg', 'packaging', '...\npackaging = <apport.packagingimpl.aptdpkg.AptDpkgPackageInfo objec...\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3/dist-packages/apport/init.py\n\n",
            "subsections": []
        }
    },
    "summary": "apport - Apport Python module.",
    "flags": [],
    "examples": [],
    "see_also": []
}