org.freedesktop.Problems2
org.freedesktop.Problems2 — The Problems Service manages all the crashes.
NewProblem
( | IN Dict<String,Variant> problem_data, |
IN Int32 flags, | |
OUT ObjectPath task) ; |
GetSession
( | OUT ObjectPath session) ; |
GetProblems
( | IN Int32 flags, |
IN Dict<String,Variant> options, | |
OUT Array<ObjectPath> response) ; |
GetProblemData
( | IN ObjectPath problem_object, |
OUT Dict<String,Struct<Int32,UInt64,String>> problem_data) ; |
DeleteProblems
( | IN Array<ObjectPath> problem_objects) ; |
org.freedesktop.Problems2.NewProblem
NewProblem
( | IN Dict<String,Variant> problem_data, |
IN Int32 flags, | |
OUT ObjectPath task) ; |
Creates a new problem and returns it's identifier.
Example 2.1. How to create a new problems in Python
#!/usr/bin/python3 import os import dbus from dbus.mainloop.glib import DBusGMainLoop bus = dbus.SystemBus() def on_task_properties_changed(iface, changed_properties, invalidated_properties, tp=None): if changed_properties['status'] == 2: p = bus.get_object("org.freedesktop.problems", tp) t = dbus.Interface(p, dbus_interface("org.freedesktop.Problems2.Task")) results, code = t.Finish() if code == 0: print(results["NewProblem.Entry"]) os.exit(0) else: print(results["Error.Message"]) os.exit(1) proxy = bus.get_object("org.freedesktop.problems", '/org/freedesktop/problems2') problems = dbus.Interface(proxy, dbus_interface='org.freedesktop.Problems2') task_pah = None with open("/etc/services", "r") as services_file: description = {"analyzer" : "libreport", "reason" : "Application has been killed", "backtrace" : "die()", "executable" : "/usr/bin/foo", "services" : dbus.types.UnixFd(services_file)} task_path = problems.NewProblem(description, 1) task_proxy = dbus.get_object("org.freedesktop.problems", task_path) task_properties = dbus.Interface(task_proxy, dbus_interface='org.freedesktop.DBus.Properties') task_properties.connect_to_signal("PropertiesChanged", on_task_properties_changed, path_keyword="tp") DBusGMainLoop(set_as_default=True) loop = GLib.MainLoop() GLib.timeout_add(30000, loop.quit) loop.run() print("Failed") task = dbus.Interface(task_proxy, dbus_interface='org.freedesktop.Problems2.Task') task.Cancel(0) os.exit(1)
Example 2.2. How to create a new problems in Bash
#!/usr/bin/bash dbus-send --system --type=method_call --print-reply \ --dest=org.freedesktop.problems /org/freedesktop/problems2 \ org.freedesktop.Problems2.NewProblem \ dict:string:string:analyzer,libreport,reason,"Application has been killed",backtrace,"die()",executable,"/usr/bin/true"
problem_data
A dictionary describing problem where values are either file descriptors or strings. There are few commonly recognized fields but the dictionary can hold anything you need.
This field should be always present. The field defines a type of problem. If the item is not provided, libreport string is used by default. This element must not be passed as plain String. Some values can passed only by authorized users, check the implementation details to find the real values.
This field should be always present. The field defines a type of problem. If the item is not provided, libreport string is used by default. This element must not be passed as plain String. Some values can passed only by authorized users, check the implementation details to find the real values.
This field should contain a short human readable text describing the problem.
This field is filled automaticaly.
Only a user with root privileges can pass this field. For all other users the field is filled by caller's uid.
This is mandatory field and must contain a valid path to an executable.
A name of package which a problematic application belongs to. If this field is provided, the executable field becomes optional.
Machine readable identifier of a kind of the problem. ABRT uses this field for local duplicates searching.
Machine readable identifier of a kind of the problem. ABRT uses this field for global duplicates searching.
The value can be one of the following types: string (s), binary array (ay) or file handle (h - will be read in non-blocking mode). The task details will contain object path of a temporary Entry under the key "NewProblem.TemporaryEntry". The temporary entry object implements the org.freedesktop.Problems2.Entry interface. The task results will contain object path of the Entry representing the processed problem data under the key "NewProblem.Entry".
flags
if up, the task will be created
if up, the task will be stopped after the temporary directory is created
if up, the task will be automatically started
task
Object path of the task processing the new problem data.
org.freedesktop.Problems2.GetSession
GetSession
( | OUT ObjectPath session) ; |
Returns a session object which implements the org.freedesktop.Problems2.Session interface.
session
An object path
org.freedesktop.Problems2.GetProblems
GetProblems
( | IN Int32 flags, |
IN Dict<String,Variant> options, | |
OUT Array<ObjectPath> response) ; |
Returns a list of problem identifiers for problems visible by the caller. If the session is authorized (GetSession), then the method returns all detected problems (system problems and problems of other users).
Example 2.3. How to get the list of problems in Python
#!/usr/bin/env python import dbus bus = dbus.SystemBus() proxy = bus.get_object("org.freedesktop.problems", '/org/freedesktop/problems2') problems = dbus.Interface(proxy, dbus_interface='org.freedesktop.Problems2') prblms = problems.GetProblems() for path in prblms: prblm_proxy = dbus.get_object("org.freedesktop.problems", path) prblm = dbus.Interface(prblm_proxy, "org.freedesktop.Problems2.Entry") print(prblm.executable) print(prblm.reason) print()
Example 2.4. How to get the list of user problems and system problems in Python
#!/usr/bin/env python import sys import dbus bus = dbus.SystemBus() proxy = bus.get_object("org.freedesktop.problems", '/org/freedesktop/problems2') problems = dbus.Interface(proxy, dbus_interface='org.freedesktop.Problems2') session_path = problems.GetSession() session_proxy = bus.get_object("org.freedesktop.problems", session_path) session = dbus.Interface(session_proxy, dbus_interface='org.freedesktop.Problems2.Session') result = session.Authorize(None, True) if result != 0: print("Cannot authorize") sys.exit(1) prblms = problems.GetProblems() for path in prblms: prblm_proxy = dbus.get_object("org.freedesktop.problems", path) prblm = dbus.Interface(prblm_proxy, "org.freedesktop.Problems2.Entry") print(prblm.executable) print(prblm.reason) print()
flags
Allows to specify what kind of problems to include in the response
options
For future needs
response
List of problem objects paths
org.freedesktop.Problems2.GetProblemData
GetProblemData
( | IN ObjectPath problem_object, |
OUT Dict<String,Struct<Int32,UInt64,String>> problem_data) ; |
Gets an equivalent of libreport's ProblemData for the given problem entry ($INCLUDE_DIR/libreport/problem_data.h).
problem_object
Problem Entry path used to get the problem data.
problem_data
The results is a dictionary where the key is problem element name (e.g. package, maps, coredump) and the value is a structure with three members:
libreport flags ($INCLUDE_DIR/libreport/problem_data.h)
real file size in Bytes
a representation of the element depending on the libreport flags
file contents
file path
file path