/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/crash.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
from __future__ import absolute_import
40
40
 
41
 
# for interactive testing, try the 'brz assert-fail' command 
 
41
# for interactive testing, try the 'brz assert-fail' command
42
42
# or see http://code.launchpad.net/~mbp/bzr/bzr-fail
43
43
#
44
44
# to test with apport it's useful to set
65
65
 
66
66
def report_bug(exc_info, stderr):
67
67
    if ('no_apport' in debug.debug_flags) or \
68
 
        os.environ.get('APPORT_DISABLE', None):
 
68
            os.environ.get('APPORT_DISABLE', None):
69
69
        return report_bug_legacy(exc_info, stderr)
70
70
    try:
71
71
        if report_bug_to_apport(exc_info, stderr):
86
86
    trace.print_exception(exc_info, err_file)
87
87
    err_file.write('\n')
88
88
    import textwrap
 
89
 
89
90
    def print_wrapped(l):
90
91
        err_file.write(textwrap.fill(l,
91
 
            width=78, subsequent_indent='    ') + '\n')
92
 
    print_wrapped('brz %s on python %s (%s)\n' % \
93
 
        (breezy.__version__,
94
 
        breezy._format_version_tuple(sys.version_info),
95
 
        platform.platform(aliased=1)))
 
92
                                     width=78, subsequent_indent='    ') + '\n')
 
93
    print_wrapped('brz %s on python %s (%s)\n' %
 
94
                  (breezy.__version__,
 
95
                   breezy._format_version_tuple(sys.version_info),
 
96
                   platform.platform(aliased=1)))
96
97
    print_wrapped('arguments: %r\n' % sys.argv)
97
98
    print_wrapped(textwrap.fill(
98
99
        'plugins: ' + plugin.format_concise_plugin_list(),
130
131
 
131
132
    if crash_filename is None:
132
133
        stderr.write("\n"
133
 
            "apport is set to ignore crashes in this version of brz.\n"
134
 
            )
 
134
                     "apport is set to ignore crashes in this version of brz.\n"
 
135
                     )
135
136
    else:
136
137
        trace.print_exception(exc_info, stderr)
137
138
        stderr.write("\n"
138
 
            "You can report this problem to Bazaar's developers by running\n"
139
 
            "    apport-bug %s\n"
140
 
            "if a bug-reporting window does not automatically appear.\n"
141
 
            % (crash_filename))
 
139
                     "You can report this problem to Bazaar's developers by running\n"
 
140
                     "    apport-bug %s\n"
 
141
                     "if a bug-reporting window does not automatically appear.\n"
 
142
                     % (crash_filename))
142
143
        # XXX: on Windows, Mac, and other platforms where we might have the
143
144
        # apport libraries but not have an apport always running, we could
144
145
        # synchronously file now
183
184
    pr['SourcePackage'] = 'brz'
184
185
    pr['Package'] = 'brz'
185
186
 
186
 
    # tell apport to file directly against the brz package using 
 
187
    # tell apport to file directly against the brz package using
187
188
    # <https://bugs.launchpad.net/bzr/+bug/391015>
188
189
    #
189
190
    # XXX: unfortunately apport may crash later if the crashdb definition
206
207
    # these may contain some sensitive info (smtp_passwords)
207
208
    # TODO: strip that out and attach the rest
208
209
    #
209
 
    #attach_file_if_exists(report,
 
210
    # attach_file_if_exists(report,
210
211
    #   os.path.join(dot_brz, 'breezy.conf', 'BrzConfig')
211
 
    #attach_file_if_exists(report,
 
212
    # attach_file_if_exists(report,
212
213
    #   os.path.join(dot_brz, 'locations.conf', 'BrzLocations')
213
214
 
214
215
    # strip username, hostname, etc
258
259
    # be careful here that people can't play tmp-type symlink mischief in the
259
260
    # world-writable directory
260
261
    return filename, os.fdopen(
261
 
        os.open(filename, 
262
 
            os.O_WRONLY|os.O_CREAT|os.O_EXCL,
263
 
            0o600),
 
262
        os.open(filename,
 
263
                os.O_WRONLY | os.O_CREAT | os.O_EXCL,
 
264
                0o600),
264
265
        'wb')
265
266
 
266
267