/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
1
'''apport package hook for Breezy'''
4634.128.12 by Martin Pool
Add sample apport integration glue
2
4634.128.13 by Martin Pool
Fix copyright, vim modeline
3
# Copyright (c) 2009, 2010 Canonical Ltd.
4
# Author: Matt Zimmerman <mdz@canonical.com>
5
#         and others
4634.128.12 by Martin Pool
Add sample apport integration glue
6
7
from apport.hookutils import *
8
import os
9
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
10
brz_log = os.path.expanduser('~/.brz.log')
6740.1.1 by Jelmer Vernooij
Rename bazaar.conf to breezy.conf.
11
dot_brz = os.path.expanduser('~/.config/breezy')
4634.128.12 by Martin Pool
Add sample apport integration glue
12
13
def _add_log_tail(report):
14
    # may have already been added in-process
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
15
    if 'BrzLogTail' in report:
4634.128.12 by Martin Pool
Add sample apport integration glue
16
        return
17
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
18
    brz_log_lines = open(brz_log).readlines()
19
    brz_log_lines.reverse()
4634.128.12 by Martin Pool
Add sample apport integration glue
20
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
21
    brz_log_tail = []
4634.128.12 by Martin Pool
Add sample apport integration glue
22
    blanks = 0
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
23
    for line in brz_log_lines:
4634.128.12 by Martin Pool
Add sample apport integration glue
24
        if line == '\n':
25
            blanks += 1
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
26
        brz_log_tail.append(line)
7195.5.1 by Martin
Fix remaining whitespace lint in codebase
27
        if blanks >= 2:
4634.128.12 by Martin Pool
Add sample apport integration glue
28
            break
29
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
30
    brz_log_tail.reverse()
31
    report['BrzLogTail'] = ''.join(brz_log_tail)
4634.128.12 by Martin Pool
Add sample apport integration glue
32
33
34
def add_info(report):
4797.33.14 by Martin Pool
Typo fix in apport package hook
35
    _add_log_tail(report)
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
36
    if 'BrzPlugins' not in report:
4634.128.12 by Martin Pool
Add sample apport integration glue
37
        # may already be present in-process
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
38
        report['BrzPlugins'] = command_output(['brz', 'plugins', '-v'])
7195.5.1 by Martin
Fix remaining whitespace lint in codebase
39
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
40
    # by default assume brz crashes are upstream bugs; this relies on
41
    # having a brz entry under /etc/apport/crashdb.conf.d/
42
    report['CrashDB'] = 'brz'
4634.128.12 by Martin Pool
Add sample apport integration glue
43
44
    # these may contain some sensitive info (smtp_passwords)
45
    # TODO: strip that out and attach the rest
46
47
    #attach_file_if_exists(report,
6740.1.1 by Jelmer Vernooij
Rename bazaar.conf to breezy.conf.
48
    #	os.path.join(dot_brz, 'breezy.conf', 'BrzConfig')
4634.128.12 by Martin Pool
Add sample apport integration glue
49
    #attach_file_if_exists(report,
6622.1.6 by Jelmer Vernooij
s/bzr/brz/ in apport config.
50
    #	os.path.join(dot_brz, 'locations.conf', 'BrzLocations')
4634.128.12 by Martin Pool
Add sample apport integration glue
51
7195.5.1 by Martin
Fix remaining whitespace lint in codebase
52
4634.128.13 by Martin Pool
Fix copyright, vim modeline
53
# vim: expandtab shiftwidth=4