`org.freedesktop.Problems2`
Prev | Chapter 2. Interfaces | Next

## `org.freedesktop.Problems2`

org.freedesktop.Problems2 — The Problems Service manages all the crashes.

## Synopsis

### Methods

`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`)`;

### Signals

`Crash (` | OUT ObjectPath problem_object,
| OUT Int32 uid`)`;

## Methods

### `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 sys
    import dbus
    from functools import partial
    from dbus.mainloop.glib import DBusGMainLoop
    from gi.repository import GLib

    PROBLEMS_BUS="org.freedesktop.problems"
    PROBLEMS_PATH="/org/freedesktop/Problems2"
    PROBLEMS_IFACE="org.freedesktop.Problems2"
    TASK_IFACE="org.freedesktop.Problems2.Task"

    def on_task_properties_changed(loop, iface, changed_properties, invalidated_properties):
        if changed_properties['status'] in [2, 3, 4, 5]:
            loop.quit()

    DBusGMainLoop(set_as_default=True)
    bus = dbus.SystemBus()

    proxy = bus.get_object(PROBLEMS_BUS, PROBLEMS_PATH)
    problems = dbus.Interface(proxy, dbus_interface=PROBLEMS_IFACE)

    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, 0x1)

    loop = GLib.MainLoop()

    task_proxy = bus.get_object(PROBLEMS_BUS, task_path)
    task = dbus.Interface(task_proxy, dbus_interface=TASK_IFACE)
    task_properties = dbus.Interface(task_proxy, dbus_interface="org.freedesktop.DBus.Properties")
    task_properties.connect_to_signal("PropertiesChanged", partial(on_task_properties_changed, loop))
    task.Start(dict())

    GLib.timeout_add(30000, loop.quit)
    loop.run()

    status = task_properties.Get(TASK_IFACE, "Status")
    if status in [0, 1]:
        print("Timed-out")
        task.Cancel(0)
        sys.exit(1)

    if status < 5:
        print("Unexpected status: {}".format(status))
        sys.exit(1)

    if status == 5:
        results, code = task.Finish()
        if code in [0, 2]:
            print("New problem: {}".format(results["NewProblem.Entry"]))
            sys.exit(0)
        else:
            print(results["Error.Message"])
            sys.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.

  type, analyzer

    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.

  reason

    This field should contain a short human readable text describing the problem.

  time

    This field is filled automaticaly.

  uid

    Only a user with root privileges can pass this field. For all other users the field is filled by caller's uid.

  executable

    This is mandatory field and must contain a valid path to an executable.

  component

    A name of package which a problematic application belongs to. If this field is provided, the executable field becomes optional.

  uuid

    Machine readable identifier of a kind of the problem. ABRT uses this field for local duplicates searching.

  duphash

    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`

  0x1

    the task will be created

  0x2

    the task will be stopped after the temporary directory is created

  0x4

    the task will be automatically started

`task`

  Object path of the task processing the new problem data. The task can finish with one of the following codes:

  0

    ABRT_P2_TASK_NEW_PROBLEM_ACCEPTED - a new problem was created

  1

    ABRT_P2_TASK_NEW_PROBLEM_FAILED - the processing failed

  2

    ABRT_P2_TASK_NEW_PROBLEM_DUPLICATE - the problem data was dropped and a duplicated problem was updated

  3

    ABRT_P2_TASK_NEW_PROBLEM_DROPPED - the problem data couldn't be saved

  4

    ABRT_P2_TASK_NEW_PROBLEM_INVALID_DATA - the problem data contained abandoned values

### `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/python3
    import dbus

    PROBLEMS_BUS="org.freedesktop.problems"
    PROBLEMS_PATH="/org/freedesktop/Problems2"
    PROBLEMS_IFACE="org.freedesktop.Problems2"
    ENTRY_IFACE="org.freedesktop.Problems2.Entry"

    bus = dbus.SystemBus()

    proxy = bus.get_object(PROBLEMS_BUS, PROBLEMS_PATH)
    problems = dbus.Interface(proxy, dbus_interface=PROBLEMS_IFACE)
    prblms = problems.GetProblems(0x0, {})

    for path in prblms:
    prblm_proxy = bus.get_object(PROBLEMS_BUS, path)
    props = dbus.Interface(prblm_proxy, "org.freedesktop.DBus.Properties")

    print("{}: {}".format(props.Get(ENTRY_IFACE, "Executable"),
                          props.Get(ENTRY_IFACE, "Reason")))

Example 2.4. How to get the list of user problems and system problems in Python

    #!/usr/bin/python3
    import sys
    import dbus
    from functools import partial
    from dbus.mainloop.glib import DBusGMainLoop
    from gi.repository import GLib

    PROBLEMS_BUS="org.freedesktop.problems"
    PROBLEMS_PATH="/org/freedesktop/Problems2"
    PROBLEMS_IFACE="org.freedesktop.Problems2"
    ENTRY_IFACE="org.freedesktop.Problems2.Entry"
    SESSION_IFACE="org.freedesktop.Problems2.Session"

    def on_session_authorization_signal(mainloop, status):
        if status == 0:
            mainloop.quit()
        if status == 3:
            print("Authorization failed")
            sys.exit(1)

    DBusGMainLoop(set_as_default=True)
    bus = dbus.SystemBus()

    proxy = bus.get_object(PROBLEMS_BUS, PROBLEMS_PATH)
    problems = dbus.Interface(proxy, dbus_interface=PROBLEMS_IFACE)

    session_path = problems.GetSession()
    session_proxy = bus.get_object(PROBLEMS_BUS, session_path)
    session = dbus.Interface(session_proxy, dbus_interface=SESSION_IFACE)

    mainloop = GLib.MainLoop()
    session_proxy.connect_to_signal("AuthorizationChanged",
                                    partial(on_session_authorization_signal,
                                            mainloop))
    result = session.Authorize({})

    if result < 0:
        print("Cannot authorize")
        sys.exit(1)

    if result > 0:
        mainloop.run()

    prblms = problems.GetProblems(0x1, {})
    for path in prblms:
        prblm_proxy = bus.get_object(PROBLEMS_BUS, path)
        props = dbus.Interface(prblm_proxy, "org.freedesktop.DBus.Properties")

        print("{}: {}".format(props.Get(ENTRY_IFACE, "Executable"),
                              props.Get(ENTRY_IFACE, "Reason")))

`flags`

  Allows to specify what kind of problems to include in the response

  0x0

    Only problems that can be viewed and modified by the caller

  0x1

    Include problems of other users

  0x2

    Include problems being processed

`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:

  1. libreport flags ($INCLUDE_DIR/libreport/problem_data.h)

  2. real file size in Bytes

  3. a representation of the element depending on the libreport flags

     CD_FLAG_TXT

       file contents

     CD_FLAG_BIN

       file path

     CD_FLAG_BIGTXT

       file path

### `org.freedesktop.Problems2.DeleteProblems`

`DeleteProblems (` | IN Array<ObjectPath> problem_objects`)`;

Deletes specified problems. The problems are specified as array of problem objects.

`problem_objects`

  An array of problem objects to deleted.

## Signals

### `org.freedesktop.Problems2.Crash`

`Crash (` | OUT ObjectPath problem_object,
| OUT Int32 uid`)`;

A new system problem has been detected.

`problem_object`

  An identifier of the detected problem.

`uid`

  UID of user who reported this problem.

Prev | Up | Next
Chapter 2. Interfaces | Home | `org.freedesktop.Problems2.Entry`