1PYTHON3-ABRT(5)                  python3-abrt                  PYTHON3-ABRT(5)
2
3
4

NAME

6       python3-abrt - python3-abrt 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 method used with auth=True parameter will try to authenticate
78       via polkit to gain access 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, analyzer=None)
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              chown()
206                     Assures ownership of a problem for the caller
207
208              delete()
209                     Delete this problem
210
211              prefetch_data()
212                     Prefetch possible data fields of this problem
213
214              save() Create this problem or update modified data
215
216                     Create or update the project if some of its  fields  were
217                     modified.
218
219                     Return  None  in  case of modification, identifier if new
220                     problem was created.
221
222       problem.list(auth=False)
223              Return the list of the problems
224
225              Use auth=True if authentication should be attempted.
226
227              If authentication via  polkit  fails,  function  behaves  as  if
228              auth=False was specified (only users problems are returned).
229
230       problem.get(identifier, auth=False)
231              Return problem object matching identifier
232
233              Return  None  in case the problem does not exist.  Use auth=True
234              if authentication should be attempted.
235
236       problem.get_problem_watcher(auth=False)
237              Return ProblemWatcher object which can be used to  attach  call‐
238              backs called when new problem is created
239
240              Use  auth=True  if  authentication  should  be attempted for new
241              problem that doesn't belong to current user. If not set  such  a
242              problem is ignored.
243
244   Specific problem types
245       class problem.Ccpp(reason)
246              C, C++ problem
247
248       class problem.Java(reason)
249              Java problem
250
251       class problem.Kerneloops(reason)
252              Kerneloops problem
253
254       class problem.Python(reason)
255              Python problem
256
257       class problem.Python3(reason)
258              Python3 problem
259
260       class problem.Runtime(reason)
261              Runtime problem
262
263       class problem.Selinux(reason)
264              Selinux problem
265
266       class problem.Unknown(reason)
267              Unknown problem
268
269       class problem.Xorg(reason)
270              Xorg problem
271
272   ProblemWatcher
273       class problem.watch.ProblemWatcher(auth)
274              New problem signal handler attached to DBus signal
275
276              Use  auth=True  if  authentication  should  be attempted for new
277              problem that doesn't belong to current user. If not set  such  a
278              problem is ignored.
279
280              add_callback(fun)
281                     Add callback to be called when new problem occurs.
282
283                     Each callback function receives Problem instance
284
285              quit() Stop event listener loop
286
287              run()  Start event listener loop
288

PROBLEM OBJECT PROPERTIES

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

AUTHOR

458       Richard Marko
459
461       2019, Richard Marko
462
463
464
465
4660.1                              Oct 11, 2019                  PYTHON3-ABRT(5)
Impressum