1ABRT-PYTHON(5)                    abrt-python                   ABRT-PYTHON(5)
2
3
4

NAME

6       abrt-python - abrt-python Documentation
7
8       High-level API for querying, creating and manipulating problems handled
9       by ABRT in Python.
10
11       It works on top of low-level DBus  or  socket  API  provided  by  ABRT.
12       Socket  API  serves  only  as a fallback option for systems without new
13       DBus problem API as it can only handle the creation of new problems.
14
15       This project lives in the abrt  repository  and  is  distributed  under
16       GPLv2 license.
17
18       Contents:
19

USAGE EXAMPLES

21   Creating new problem
22          import problem
23
24          prob = problem.Runtime(
25                  reason='egg_error_message: assertion "error" failed',
26              )
27
28          prob.add_current_process_data()
29          prob.add_current_environment()
30          prob.save()
31
32
33   Creating problem for different executable
34          import problem
35
36          prob = problem.Selinux(reason='Front fell off')
37
38          prob.executable = '/usr/bin/time'
39
40          prob.save()
41
42
43   Adding custom data
44          import problem
45
46          prob = problem.Runtime(
47                  reason='Error getting devices:'
48                  'GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: '
49                  'No such interface `org.gnome.SettingsDaemon.Power` on object at path '
50                  '/org/gnome/SettingsDaemon/Power'
51              )
52
53          prob.add_current_process_data()
54          prob.custom_data = 'any'
55          prob['dict_access_example'] = 'works'
56
57          print(prob)
58          print('')
59
60          for key, value in prob.items():
61              print('{0}={1}'.format(key, value))
62
63          print 'Identifier:', prob.save()
64
65
66   Querying problems
67          import problem
68
69          for prob in problem.list():
70              print(prob)
71              print(repr(prob.time))
72              if hasattr(prob, 'pid'):
73                  print(prob.pid)
74
75
76   Querying all problems
77       The  list_all method will try to authenticate via polkit to gain access
78       to all problems on the system.
79
80       If there is no authentication agent running or authentication is unsuc‐
81       cessful,  the list of problems which belong to current user is returned
82       (same as returned by the list method).
83
84          import problem
85
86          for prob in problem.list(auth=True):
87              print(prob)
88              if hasattr(prob, 'username'):
89                  print('Problem belongs to {0}'.format(prob.username))
90
91
92   Editing existing problems
93          import problem
94
95          for prob in problem.list():
96              if prob.type == problem.JAVA:
97                  prob.delete()
98
99              if prob.type == problem.CCPP:
100                  if 'password' in prob.backtrace:
101                      del prob.backtrace
102                      prob.save()
103
104              if prob.type == problem.KERNELOOPS:
105                  prob.backtrace = prob.backtrace.replace(' ?', '')
106                  prob.save()
107
108
109   Watching for new problems
110          import problem
111          import logging
112
113          logging.basicConfig(level=logging.DEBUG)
114
115          def monitor(prob):
116              print(prob)
117              prob.delete()
118
119          pwatch = problem.get_problem_watcher()
120          pwatch.add_callback(monitor)
121
122          try:
123              pwatch.run()
124          except KeyboardInterrupt:
125              pwatch.quit()
126
127
128   Watching for new problems in a thread
129          from __future__ import print_function
130
131          import sys
132          import time
133          import problem
134          import threading
135
136          class ProblemWatchThread(threading.Thread):
137              def __init__(self):
138                  super(ProblemWatchThread, self).__init__()
139                  self.pwatch = problem.get_problem_watcher()
140                  self.pwatch.add_callback(self.handle)
141                  self.probcount = 0
142
143              def handle(self, prob):
144                  self.probcount += 1
145                  print('{0}: {1}'.format(self.probcount, prob))
146                  # prob.delete()
147
148              def run(self):
149                  self.pwatch.run()
150
151              def stop(self):
152                  self.pwatch.quit()
153
154          pwt = ProblemWatchThread()
155          pwt.start()
156
157          i = 0
158          print('Waiting for new problem to appear')
159          spinner = ['\\', '|', '/', '-']
160
161          try:
162              while True:
163                  time.sleep(0.1)
164                  print('{0}\r'.format(spinner[i]), end='')
165                  i += 1
166                  i = i % len(spinner)
167                  sys.stdout.flush()
168          except KeyboardInterrupt:
169              pwt.stop()
170
171          pwt.stop()
172
173
174   Getting bug numbers of problems reported to bugzilla
175          import problem
176
177          bugs = set()
178
179          for prob in problem.list():
180              if not hasattr(prob, 'reported_to'):
181                  continue
182
183              for line in prob.reported_to.splitlines():
184                  if line.startswith('Bugzilla:'):
185                      bug_num = int(line.split('=')[-1])
186                      bugs.add(bug_num)
187
188          print(bugs)
189
190

STABLE API DOCUMENTATION

192       class problem.Problem(typ, reason)
193              Base class for the other problem types.
194
195              No need to use this class directly,  use  one  of  the  specific
196              problem classes.
197
198              add_current_environment()
199                     Add environment of current process to this problem object
200
201              add_current_process_data()
202                     Add  pid,  gid  and executable of current process to this
203                     problem object
204
205              delete()
206                     Delete this problem
207
208              save() Create this problem or update modified data
209
210                     Create or update the project if some of its  fields  were
211                     modified.
212
213                     Return  None  in  case of modification, identifier if new
214                     problem was created.
215
216       problem.list(auth=False)
217              Return the list of the problems
218
219              Use auth=True if authentication should be attempted.
220
221              If authentication via  polkit  fails,  function  behaves  as  if
222              auth=False was specified (only users problems are returned).
223
224       problem.get(identifier, auth=False)
225              Return problem object matching identifier
226
227              Return None in case the problem does not exist.
228
229              Use auth=True if authentication should be attempted.
230
231       problem.get_problem_watcher(auth=False)
232              Return  ProblemWatcher  object which can be used to attach call‐
233              backs called when new problem is created
234
235              Use auth=True if authentication  should  be  attempted  for  new
236              problem  that  doesn't belong to current user. If not set such a
237              problem is ignored.
238
239   Specific problem types
240       class problem.Ccpp(reason)
241              C, C++ problem
242
243       class problem.Java(reason)
244              Java problem
245
246       class problem.Kerneloops(reason)
247              Kerneloops problem
248
249       class problem.Python(reason)
250              Python problem
251
252       class problem.Runtime(reason)
253              Runtime problem
254
255       class problem.Selinux(reason)
256              Selinux problem
257
258       class problem.Unknown(reason)
259              Unknown problem
260
261       class problem.Xorg(reason)
262              Xorg problem
263
264   ProblemWatcher
265       class problem.watch.ProblemWatcher(auth)
266              New problem signal handler attached to DBus signal
267
268              Use auth=True if authentication  should  be  attempted  for  new
269              problem  that  doesn't belong to current user. If not set such a
270              problem is ignored.
271
272              add_callback(fun)
273                     Add callback to be called when new problem occurs.
274
275                     Each callback function receives Problem instance
276
277              quit() Stop event listener loop
278
279              run()  Start event listener loop
280

PROBLEM OBJECT PROPERTIES

282       Currently, there is no strict specification of problem  properties  and
283       you  are  free  to add your own data as you see fit (log files, process
284       data) provided you are planning to use them for reporting.
285
286       Mandatory properties required prior saving:
287
288                ┌───────────┬─────────────────────┬─────────────────┐
289                │Property   │ Meaning             │ Example         │
290                ├───────────┼─────────────────────┼─────────────────┤
291executable │ Executable path  of │ '/usr/bin/time' 
292                │           │ the component which │                 │
293                │           │ caused the problem. │                 │
294                │           │ Used  by the server │                 │
295                │           │ to determine compo‐ │                 │
296                │           │ nent   and  package │                 │
297                │           │ data.               │                 │
298                └───────────┴─────────────────────┴─────────────────┘
299
300       Following properties are added by the server when new problem  is  cre‐
301       ated:
302
303          ┌─────────────┬─────────────────────┬───────────────────────────┐
304          │Property     │ Meaning             │ Example                   │
305          ├─────────────┼─────────────────────┼───────────────────────────┤
306component    │ Component     which │ 'time'                    
307          │             │ caused  this  prob‐ │                           │
308          │             │ lem.                │                           │
309          ├─────────────┼─────────────────────┼───────────────────────────┤
310hostname     │ Hostname   of   the │ 'fiasco'                  
311          │             │ affected machine.   │                           │
312          ├─────────────┼─────────────────────┼───────────────────────────┤
313os_release   │ Operating    system │ 'Fedora  release 17       
314          │             │ release string.     │ (Beefy Miracle)'          
315          ├─────────────┼─────────────────────┼───────────────────────────┤
316uid          │ User ID             │ 1000                      
317          ├─────────────┼─────────────────────┼───────────────────────────┤
318username     │                     │ 'jeff'                    
319          ├─────────────┼─────────────────────┼───────────────────────────┤
320architecture │ Machine   architec‐ │ 'x86_64'                  
321          │             │ ture string         │                           │
322          ├─────────────┼─────────────────────┼───────────────────────────┤
323kernel       │ Kernel      version │ '3.6.6-1.fc17.x86_64'     
324          │             │ string              │                           │
325          ├─────────────┼─────────────────────┼───────────────────────────┤
326package      │ Package string      │ 'time-1.7-40.fc17.x86_64' 
327          ├─────────────┼─────────────────────┼───────────────────────────┤
328time         │ Time     of     the │ datetime.datetime(2012,   
329          │             │ occurence    (unix‐ │ 12, 2, 16, 18, 41)        
330          │             │ time)               │                           │
331          ├─────────────┼─────────────────────┼───────────────────────────┤
332count        │ Number   of   times │ 1                         
333          │             │ this        problem │                           │
334          │             │ occured             │                           │
335          └─────────────┴─────────────────────┴───────────────────────────┘
336
337       Parsed package data is also available:
338
339                   ┌────────────┬─────────────────────┬───────────┐
340                   │Property    │ Meaning             │ Example   │
341                   ├────────────┼─────────────────────┼───────────┤
342pkg_name    │ Package name        │ 'time'    
343                   └────────────┴─────────────────────┴───────────┘
344
345pkg_epoch   │ Package epoch       │ 0         
346                   ├────────────┼─────────────────────┼───────────┤
347pkg_version │ Package version     │ '1.7'     
348                   ├────────────┼─────────────────────┼───────────┤
349pkg_release │ Package release     │ '40.fc17' 
350                   ├────────────┼─────────────────────┼───────────┤
351pkg_arch    │ Package   architec‐ │ 'x86_64'  
352                   │            │ ture                │           │
353                   └────────────┴─────────────────────┴───────────┘
354
355       Other common properties (presence differs based on problem type):
356
357┌─────────────────┬──────────────────┬──────────────────────────────────┬──────────────────┐
358│Property         │ Meaning          │ Example                          │ Applicable       │
359├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
360abrt_version     │ ABRT     version │ '2.0.18.84.g211c'                │ Crashes   caught │
361│                 │ string           │                                  │ by ABRT          │
362├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
363cgroup           │ cgroup  (control │ '9:perf_event:/\n8:blkio:/\n...' │ C/C++            │
364│                 │ group)  informa‐ │                                  │                  │
365│                 │ tion for crashed │                                  │                  │
366│                 │ process          │                                  │                  │
367├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
368core_backtrace   │ Machine readable │                                  │ C/C++,   Python, │
369│                 │ backtrace   with │                                  │ Ruby, Kerneloops │
370│                 │ no private data  │                                  │                  │
371├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
372backtrace        │ Original   back‐ │                                  │ C/C++     (after │
373│                 │ trace  or  back‐ │                                  │ retracing),      │
374│                 │ trace   produced │                                  │ Python,    Ruby, │
375│                 │ by     retracing │                                  │ Xorg, Kerneloops │
376│                 │ process          │                                  │                  │
377├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
378dso_list         │ List  of dynamic │                                  │ C/C++, Python    │
379│                 │ libraries loaded │                                  │                  │
380│                 │ at  the  time of │                                  │                  │
381│                 │ crash            │                                  │                  │
382├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
383maps             │ Copy          of │                                  │ C/C++            │
384│                 │ /proc/<pid>/maps │                                  │                  │
385│                 │ file   of    the │                                  │                  │
386│                 │ problem     exe‐ │                                  │                  │
387│                 │ cutable          │                                  │                  │
388├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
389cmdline          │ Copy          of │ '/usr/bin/gtk-builder-convert'   │ C/C++,   Python, │
390│                 │ /proc/<pid>/cmd‐ │                                  │ Ruby, Kerneloops │
391│                 │ line file        │                                  │                  │
392├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
393coredump         │ Coredump  of the │                                  │ C/C++            │
394│                 │ crashing process │                                  │                  │
395├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
396environ          │ Runtime environ‐ │                                  │ C/C++, Python    │
397│                 │ ment    of   the │                                  │                  │
398│                 │ process          │                                  │                  │
399├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
400open_fds         │ List   of   file │                                  │ C/C++            │
401│                 │ descriptors open │                                  │                  │
402│                 │ at the  time  of │                                  │                  │
403│                 │ crash            │                                  │                  │
404├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
405pid              │ Process ID       │ '42'                             │ C/C++,   Python, │
406│                 │                  │                                  │ Ruby             │
407├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
408proc_pid_status  │ Copy          of │                                  │ C/C++            │
409│                 │ /proc/<pid>/sta‐ │                                  │                  │
410│                 │ tus file         │                                  │                  │
411└─────────────────┴──────────────────┴──────────────────────────────────┴──────────────────┘
412
413
414
415limits           │ Copy          of │                                  │ C/C++            │
416│                 │ /proc/<pid>/lim‐ │                                  │                  │
417│                 │ its file         │                                  │                  │
418├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
419var_log_messages │ Part   of    the │                                  │ C/C++            │
420│                 │ /var/log/mes‐    │                                  │                  │
421│                 │ sages file which │                                  │                  │
422│                 │ contains   crash │                                  │                  │
423│                 │ information      │                                  │                  │
424├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
425suspend_stats    │ Copy          of │                                  │ Kerneloops       │
426│                 │ /sys/ker‐        │                                  │                  │
427│                 │ nel/debug/sus‐   │                                  │                  │
428│                 │ pend_stats       │                                  │                  │
429├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
430reported_to      │ If  the  problem │                                  │ Reported   prob‐ │
431│                 │ was      already │                                  │ lems             │
432│                 │ reported,   this │                                  │                  │
433│                 │ item    contains │                                  │                  │
434│                 │ URLs of the ser‐ │                                  │                  │
435│                 │ vices  where  it │                                  │                  │
436│                 │ was reported     │                                  │                  │
437├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
438event_log        │ ABRT event log   │                                  │ Reported   prob‐ │
439│                 │                  │                                  │ lems             │
440├─────────────────┼──────────────────┼──────────────────────────────────┼──────────────────┤
441dmesg            │ Copy of dmesg    │                                  │ Kerneloops       │
442└─────────────────┴──────────────────┴──────────────────────────────────┴──────────────────┘
443
444       · genindex
445
446       · modindex
447
448       · search
449

AUTHOR

451       Richard Marko
452
454       2012, Richard Marko
455
456
457
458
4590.1                            November 13, 2018                ABRT-PYTHON(5)
Impressum