~brian-murray/ubuntu/natty/apport/rr-if-idontknow

« back to all changes in this revision

Viewing changes to apport/crashdb.py

  • Committer: Martin Pitt
  • Date: 2011-02-04 14:41:46 UTC
  • mfrom: (1369.34.52 trunk)
  • Revision ID: martin.pitt@canonical.com-20110204144146-o0fq0kh4shzsutr3
new upstream release 1.17.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
        cur.execute('PRAGMA integrity_check')
84
84
        result = cur.fetchall() 
85
85
        if result != [('ok',)]:
86
 
            raise SystemError, 'Corrupt duplicate db:' + str(result)
 
86
            raise SystemError('Corrupt duplicate db:' + str(result))
87
87
 
88
88
    def check_duplicate(self, id, report=None):
89
89
        '''Check whether a crash is already known.
225
225
            # crash got fixed/rejected
226
226
            fixed_ver = self.get_fixed_version(id)
227
227
            if fixed_ver == 'invalid':
228
 
                print 'DEBUG: bug %i was invalidated, removing from database' % id
 
228
                print('DEBUG: bug %i was invalidated, removing from database' % id)
229
229
                cur2.execute('DELETE FROM crashes WHERE crash_id = ?', [id])
230
230
            elif not fixed_ver:
231
 
                print 'WARNING: inconsistency detected: bug #%i does not appear in get_unfixed(), but is not fixed yet' % id
 
231
                print('WARNING: inconsistency detected: bug #%i does not appear in get_unfixed(), but is not fixed yet' % id)
232
232
            else:
233
233
                cur2.execute('UPDATE crashes SET fixed_version = ?, last_change = CURRENT_TIMESTAMP WHERE crash_id = ?',
234
234
                    (fixed_ver, id))
328
328
 
329
329
        This method can raise a NeedsCredentials exception in case of failure.
330
330
        '''
331
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
331
        raise NotImplementedError('this method must be implemented by a concrete subclass')
332
332
 
333
333
    def get_comment_url(self, report, handle):
334
334
        '''Return an URL that should be opened after report has been uploaded
338
338
        user comments); in that case this function should do whichever
339
339
        interactive steps it wants to perform.
340
340
        '''
341
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
341
        raise NotImplementedError('this method must be implemented by a concrete subclass')
342
342
 
343
343
    def download(self, id):
344
344
        '''Download the problem report from given ID and return a Report.'''
345
345
 
346
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
346
        raise NotImplementedError('this method must be implemented by a concrete subclass')
347
347
 
348
348
    def update(self, id, report, comment, change_description=False,
349
349
            attachment_comment=None, key_filter=None):
362
362
 
363
363
        If key_filter is a list or set, then only those keys will be added.
364
364
        '''
365
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
365
        raise NotImplementedError('this method must be implemented by a concrete subclass')
366
366
 
367
367
    def update_traces(self, id, report, comment=''):
368
368
        '''Update the given report ID for retracing results.
376
376
    def set_credentials(self, username, password):
377
377
        '''Set username and password.'''
378
378
 
379
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
379
        raise NotImplementedError('this method must be implemented by a concrete subclass')
380
380
 
381
381
    def get_distro_release(self, id):
382
382
        '''Get 'DistroRelease: <release>' from the report ID.'''
383
383
 
384
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
384
        raise NotImplementedError('this method must be implemented by a concrete subclass')
385
385
 
386
386
    def get_unretraced(self):
387
387
        '''Return set of crash IDs which have not been retraced yet.
389
389
        This should only include crashes which match the current host
390
390
        architecture.
391
391
        '''
392
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
392
        raise NotImplementedError('this method must be implemented by a concrete subclass')
393
393
 
394
394
    def get_dup_unchecked(self):
395
395
        '''Return set of crash IDs which need duplicate checking.
398
398
        Python, since they do not need to be retraced. It should not return
399
399
        bugs that are covered by get_unretraced().
400
400
        '''
401
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
401
        raise NotImplementedError('this method must be implemented by a concrete subclass')
402
402
 
403
403
    def get_unfixed(self):
404
404
        '''Return an ID set of all crashes which are not yet fixed.
409
409
        there are any errors with connecting to the crash database, it should
410
410
        raise an exception (preferably IOError).
411
411
        '''
412
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
412
        raise NotImplementedError('this method must be implemented by a concrete subclass')
413
413
 
414
414
    def get_fixed_version(self, id):
415
415
        '''Return the package version that fixes a given crash.
423
423
        there are any errors with connecting to the crash database, it should
424
424
        raise an exception (preferably IOError).
425
425
        '''
426
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
426
        raise NotImplementedError('this method must be implemented by a concrete subclass')
427
427
 
428
428
    def get_affected_packages(self, id):
429
429
        '''Return list of affected source packages for given ID.'''
430
430
 
431
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
431
        raise NotImplementedError('this method must be implemented by a concrete subclass')
432
432
 
433
433
    def is_reporter(self, id):
434
434
        '''Check whether the user is the reporter of given ID.'''
435
435
 
436
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
436
        raise NotImplementedError('this method must be implemented by a concrete subclass')
437
437
 
438
438
    def can_update(self, id):
439
439
        '''Check whether the user is eligible to update a report.
443
443
        exact policy and checks should be done according to  the particular
444
444
        implementation.
445
445
        '''
446
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
446
        raise NotImplementedError('this method must be implemented by a concrete subclass')
447
447
 
448
448
    def duplicate_of(self, id):
449
449
        '''Return master ID for a duplicate bug.
450
450
 
451
451
        If the bug is not a duplicate, return None.
452
452
        '''
453
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
453
        raise NotImplementedError('this method must be implemented by a concrete subclass')
454
454
 
455
455
    def close_duplicate(self, id, master):
456
456
        '''Mark a crash id as duplicate of given master ID.
457
457
        
458
458
        If master is None, id gets un-duplicated.
459
459
        '''
460
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
460
        raise NotImplementedError('this method must be implemented by a concrete subclass')
461
461
 
462
462
    def mark_regression(self, id, master):
463
463
        '''Mark a crash id as reintroducing an earlier crash which is
464
464
        already marked as fixed (having ID 'master').'''
465
465
        
466
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
466
        raise NotImplementedError('this method must be implemented by a concrete subclass')
467
467
 
468
468
    def mark_retraced(self, id):
469
469
        '''Mark crash id as retraced.'''
470
470
 
471
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
471
        raise NotImplementedError('this method must be implemented by a concrete subclass')
472
472
 
473
473
    def mark_retrace_failed(self, id, invalid_msg=None):
474
474
        '''Mark crash id as 'failed to retrace'.
478
478
        
479
479
        This can be a no-op if you are not interested in this.
480
480
        '''
481
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
481
        raise NotImplementedError('this method must be implemented by a concrete subclass')
482
482
 
483
483
    def _mark_dup_checked(self, id, report):
484
484
        '''Mark crash id as checked for being a duplicate
485
485
        
486
486
        This is an internal method that should not be called from outside.
487
487
        '''
488
 
        raise NotImplementedError, 'this method must be implemented by a concrete subclass'
 
488
        raise NotImplementedError('this method must be implemented by a concrete subclass')
489
489
 
490
490
#
491
491
# factory 
525
525
            if os.path.isfile(cfpath) and cf.endswith('.conf'):
526
526
                try:
527
527
                    execfile(cfpath, settings['databases'])
528
 
                except Exception, e:
 
528
                except Exception as e:
529
529
                    # ignore broken files
530
 
                    print >> sys.stderr, 'Invalid file %s: %s' % (cfpath, str(e))
 
530
                    sys.stderr.write('Invalid file %s: %s\n' % (cfpath, str(e)))
531
531
                    pass
532
532
 
533
533
    if not name: