Exemplo n.º 1
0
def _open_crash_file():
    crash_dir = config.crash_dir()
    if not osutils.isdir(crash_dir):
        # on unix this should be /var/crash and should already exist; on
        # Windows or if it's manually configured it might need to be created,
        # and then it should be private
        os.makedirs(crash_dir, mode=0600)
    date_string = time.strftime('%Y-%m-%dT%H:%M', time.gmtime())
    # XXX: getuid doesn't work on win32, but the crash directory is per-user
    if sys.platform == 'win32':
        user_part = ''
    else:
        user_part = '.%d' % os.getuid()
    filename = osutils.pathjoin(
        crash_dir,
        'bzr%s.%s.crash' % (
            user_part,
            date_string))
    # be careful here that people can't play tmp-type symlink mischief in the
    # world-writable directory
    return filename, os.fdopen(
        os.open(filename, 
            os.O_WRONLY|os.O_CREAT|os.O_EXCL,
            0600),
        'wb')
Exemplo n.º 2
0
    def test_apport_report(self):
        crash_dir = osutils.joinpath((self.test_base_dir, 'crash'))
        os.mkdir(crash_dir)
        self.overrideEnv('APPORT_CRASH_DIR', crash_dir)
        self.assertEqual(crash_dir, config.crash_dir())

        self.overrideAttr(
            plugin,
            'plugin_warnings',
            {'example': ['Failed to load plugin foo']})

        stderr = StringIO()

        try:
            raise AssertionError("my error")
        except AssertionError, e:
            pass
Exemplo n.º 3
0
    def test_apport_report(self):
        crash_dir = osutils.joinpath((self.test_base_dir, 'crash'))
        os.mkdir(crash_dir)
        self.overrideEnv('APPORT_CRASH_DIR', crash_dir)
        self.assertEquals(crash_dir, config.crash_dir())

        self.overrideAttr(
            plugin,
            'plugin_warnings',
            {'example': ['Failed to load plugin foo']})

        stderr = StringIO()

        try:
            raise AssertionError("my error")
        except AssertionError, e:
            pass
Exemplo n.º 4
0
def _open_crash_file():
    crash_dir = config.crash_dir()
    if not osutils.isdir(crash_dir):
        # on unix this should be /var/crash and should already exist; on
        # Windows or if it's manually configured it might need to be created,
        # and then it should be private
        os.makedirs(crash_dir, mode=0600)
    date_string = time.strftime('%Y-%m-%dT%H:%M', time.gmtime())
    # XXX: getuid doesn't work on win32, but the crash directory is per-user
    if sys.platform == 'win32':
        user_part = ''
    else:
        user_part = '.%d' % os.getuid()
    filename = osutils.pathjoin(crash_dir,
                                'bzr%s.%s.crash' % (user_part, date_string))
    # be careful here that people can't play tmp-type symlink mischief in the
    # world-writable directory
    return filename, os.fdopen(
        os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0600), 'wb')