~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/crash.py

  • Committer: Martin Pool
  • Date: 2010-01-31 12:01:47 UTC
  • mto: (4999.3.1 apport)
  • mto: This revision was merged to the branch mainline in revision 5002.
  • Revision ID: mbp@sourcefrog.net-20100131120147-awmv3fd991pbwlmk
Write crash files into /var/crash where apport can see them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
142
142
 
143
143
def _open_crash_file():
144
144
    crash_dir = config.crash_dir()
145
 
    # user-readable only, just in case the contents are sensitive.
146
145
    if not osutils.isdir(crash_dir):
147
 
        os.makedirs(crash_dir, mode=0700)
148
 
    filename = 'bzr-%s-%s.crash' % (
149
 
        osutils.compact_date(time.time()),
150
 
        os.getpid(),)
 
146
        # on unix this should be /var/crash and should already exist; on
 
147
        # Windows or if it's manually configured it might need to be created,
 
148
        # and then it should be private
 
149
        os.makedirs(crash_dir, mode=0600)
 
150
    date_string = time.strftime('%Y-%m-%dT%H:%M', time.gmtime())
 
151
    filename = 'bzr.%d.%s.crash' % (
 
152
        os.getuid(),
 
153
        date_string)
151
154
    return open(osutils.pathjoin(crash_dir, filename), 'wt')
152
155
 
153
156