96
143
self.acceptable_keys.append(pattern)
145
@deprecated_method(deprecated_in((2, 6, 0)))
98
146
def do_verifications(self, revisions, repository):
99
count = {SIGNATURE_VALID: 0,
100
SIGNATURE_KEY_MISSING: 0,
101
SIGNATURE_NOT_VALID: 0,
102
SIGNATURE_NOT_SIGNED: 0,
103
SIGNATURE_EXPIRED: 0}
105
all_verifiable = True
106
for rev_id in revisions:
107
verification_result, uid =\
108
repository.verify_revision(rev_id,self)
109
result.append([rev_id, verification_result, uid])
110
count[verification_result] += 1
111
if verification_result != SIGNATURE_VALID:
112
all_verifiable = False
113
return (count, result, all_verifiable)
147
return bulk_verify_signatures(repository, revisions, self)
149
@deprecated_method(deprecated_in((2, 6, 0)))
115
150
def valid_commits_message(self, count):
116
return gettext(u"{0} commits with valid signatures").format(
117
count[SIGNATURE_VALID])
151
return valid_commits_message(count)
153
@deprecated_method(deprecated_in((2, 6, 0)))
119
154
def unknown_key_message(self, count):
120
return ngettext(u"{0} commit with unknown key",
121
u"{0} commits with unknown keys",
122
count[SIGNATURE_KEY_MISSING]).format(
123
count[SIGNATURE_KEY_MISSING])
155
return unknown_key_message(count)
157
@deprecated_method(deprecated_in((2, 6, 0)))
125
158
def commit_not_valid_message(self, count):
126
return ngettext(u"{0} commit not valid",
127
u"{0} commits not valid",
128
count[SIGNATURE_NOT_VALID]).format(
129
count[SIGNATURE_NOT_VALID])
159
return commit_not_valid_message(count)
161
@deprecated_method(deprecated_in((2, 6, 0)))
131
162
def commit_not_signed_message(self, count):
132
return ngettext(u"{0} commit not signed",
133
u"{0} commits not signed",
134
count[SIGNATURE_NOT_SIGNED]).format(
135
count[SIGNATURE_NOT_SIGNED])
163
return commit_not_signed_message(count)
165
@deprecated_method(deprecated_in((2, 6, 0)))
137
166
def expired_commit_message(self, count):
138
return ngettext(u"{0} commit with key now expired",
139
u"{0} commits with key now expired",
140
count[SIGNATURE_EXPIRED]).format(
141
count[SIGNATURE_EXPIRED])
167
return expired_commit_message(count)
144
170
def _set_gpg_tty():
336
358
"No GnuPG key results for pattern: {0}"
337
359
).format(pattern))
361
@deprecated_method(deprecated_in((2, 6, 0)))
339
362
def do_verifications(self, revisions, repository,
340
363
process_events_callback=None):
341
364
"""do verifications on a set of revisions
343
366
:param revisions: list of revision ids to verify
344
367
:param repository: repository object
345
368
:param process_events_callback: method to call for GUI frontends that
346
want to keep their UI refreshed
369
want to keep their UI refreshed
348
371
:return: count dictionary of results of each type,
349
372
result list for each revision,
350
373
boolean True if all results are verified successfully
352
count = {SIGNATURE_VALID: 0,
353
SIGNATURE_KEY_MISSING: 0,
354
SIGNATURE_NOT_VALID: 0,
355
SIGNATURE_NOT_SIGNED: 0,
356
SIGNATURE_EXPIRED: 0}
358
all_verifiable = True
359
for rev_id in revisions:
360
verification_result, uid =\
361
repository.verify_revision(rev_id,self)
362
result.append([rev_id, verification_result, uid])
363
count[verification_result] += 1
364
if verification_result != SIGNATURE_VALID:
365
all_verifiable = False
366
if process_events_callback is not None:
367
process_events_callback()
368
return (count, result, all_verifiable)
375
return bulk_verify_signatures(repository, revisions, self,
376
process_events_callback)
378
@deprecated_method(deprecated_in((2, 6, 0)))
370
379
def verbose_valid_message(self, result):
371
380
"""takes a verify result and returns list of signed commits strings"""
373
for rev_id, validity, uid in result:
374
if validity == SIGNATURE_VALID:
375
signers.setdefault(uid, 0)
378
for uid, number in signers.items():
379
result.append( ngettext(u"{0} signed {1} commit",
380
u"{0} signed {1} commits",
381
number).format(uid, number) )
381
return verbose_valid_message(result)
383
@deprecated_method(deprecated_in((2, 6, 0)))
385
384
def verbose_not_valid_message(self, result, repo):
386
385
"""takes a verify result and returns list of not valid commit info"""
388
for rev_id, validity, empty in result:
389
if validity == SIGNATURE_NOT_VALID:
390
revision = repo.get_revision(rev_id)
391
authors = ', '.join(revision.get_apparent_authors())
392
signers.setdefault(authors, 0)
393
signers[authors] += 1
395
for authors, number in signers.items():
396
result.append( ngettext(u"{0} commit by author {1}",
397
u"{0} commits by author {1}",
398
number).format(number, authors) )
386
return verbose_not_valid_message(result, repo)
388
@deprecated_method(deprecated_in((2, 6, 0)))
401
389
def verbose_not_signed_message(self, result, repo):
402
390
"""takes a verify result and returns list of not signed commit info"""
404
for rev_id, validity, empty in result:
405
if validity == SIGNATURE_NOT_SIGNED:
406
revision = repo.get_revision(rev_id)
407
authors = ', '.join(revision.get_apparent_authors())
408
signers.setdefault(authors, 0)
409
signers[authors] += 1
411
for authors, number in signers.items():
412
result.append( ngettext(u"{0} commit by author {1}",
413
u"{0} commits by author {1}",
414
number).format(number, authors) )
391
return verbose_not_valid_message(result, repo)
393
@deprecated_method(deprecated_in((2, 6, 0)))
417
394
def verbose_missing_key_message(self, result):
418
395
"""takes a verify result and returns list of missing key info"""
420
for rev_id, validity, fingerprint in result:
421
if validity == SIGNATURE_KEY_MISSING:
422
signers.setdefault(fingerprint, 0)
423
signers[fingerprint] += 1
425
for fingerprint, number in signers.items():
426
result.append( ngettext(u"Unknown key {0} signed {1} commit",
427
u"Unknown key {0} signed {1} commits",
428
number).format(fingerprint, number) )
396
return verbose_missing_key_message(result)
398
@deprecated_method(deprecated_in((2, 6, 0)))
431
399
def verbose_expired_key_message(self, result, repo):
432
400
"""takes a verify result and returns list of expired key info"""
434
fingerprint_to_authors = {}
435
for rev_id, validity, fingerprint in result:
436
if validity == SIGNATURE_EXPIRED:
437
revision = repo.get_revision(rev_id)
438
authors = ', '.join(revision.get_apparent_authors())
439
signers.setdefault(fingerprint, 0)
440
signers[fingerprint] += 1
441
fingerprint_to_authors[fingerprint] = authors
443
for fingerprint, number in signers.items():
444
result.append(ngettext(u"{0} commit by author {1} with "\
445
"key {2} now expired",
446
u"{0} commits by author {1} with key {2} now "\
448
number).format(number,
449
fingerprint_to_authors[fingerprint], fingerprint) )
401
return verbose_expired_key_message(result, repo)
403
@deprecated_method(deprecated_in((2, 6, 0)))
452
404
def valid_commits_message(self, count):
453
405
"""returns message for number of commits"""
454
return gettext(u"{0} commits with valid signatures").format(
455
count[SIGNATURE_VALID])
406
return valid_commits_message(count)
408
@deprecated_method(deprecated_in((2, 6, 0)))
457
409
def unknown_key_message(self, count):
458
410
"""returns message for number of commits"""
459
return ngettext(u"{0} commit with unknown key",
460
u"{0} commits with unknown keys",
461
count[SIGNATURE_KEY_MISSING]).format(
462
count[SIGNATURE_KEY_MISSING])
411
return unknown_key_message(count)
413
@deprecated_method(deprecated_in((2, 6, 0)))
464
414
def commit_not_valid_message(self, count):
465
415
"""returns message for number of commits"""
466
return ngettext(u"{0} commit not valid",
467
u"{0} commits not valid",
468
count[SIGNATURE_NOT_VALID]).format(
469
count[SIGNATURE_NOT_VALID])
416
return commit_not_valid_message(count)
418
@deprecated_method(deprecated_in((2, 6, 0)))
471
419
def commit_not_signed_message(self, count):
472
420
"""returns message for number of commits"""
473
return ngettext(u"{0} commit not signed",
474
u"{0} commits not signed",
475
count[SIGNATURE_NOT_SIGNED]).format(
476
count[SIGNATURE_NOT_SIGNED])
421
return commit_not_signed_message(count)
423
@deprecated_method(deprecated_in((2, 6, 0)))
478
424
def expired_commit_message(self, count):
479
425
"""returns message for number of commits"""
480
return ngettext(u"{0} commit with key now expired",
481
u"{0} commits with key now expired",
482
count[SIGNATURE_EXPIRED]).format(
483
count[SIGNATURE_EXPIRED])
426
return expired_commit_message(count)
429
def valid_commits_message(count):
430
"""returns message for number of commits"""
431
return gettext(u"{0} commits with valid signatures").format(
432
count[SIGNATURE_VALID])
435
def unknown_key_message(count):
436
"""returns message for number of commits"""
437
return ngettext(u"{0} commit with unknown key",
438
u"{0} commits with unknown keys",
439
count[SIGNATURE_KEY_MISSING]).format(
440
count[SIGNATURE_KEY_MISSING])
443
def commit_not_valid_message(count):
444
"""returns message for number of commits"""
445
return ngettext(u"{0} commit not valid",
446
u"{0} commits not valid",
447
count[SIGNATURE_NOT_VALID]).format(
448
count[SIGNATURE_NOT_VALID])
451
def commit_not_signed_message(count):
452
"""returns message for number of commits"""
453
return ngettext(u"{0} commit not signed",
454
u"{0} commits not signed",
455
count[SIGNATURE_NOT_SIGNED]).format(
456
count[SIGNATURE_NOT_SIGNED])
459
def expired_commit_message(count):
460
"""returns message for number of commits"""
461
return ngettext(u"{0} commit with key now expired",
462
u"{0} commits with key now expired",
463
count[SIGNATURE_EXPIRED]).format(
464
count[SIGNATURE_EXPIRED])
467
def verbose_expired_key_message(result, repo):
468
"""takes a verify result and returns list of expired key info"""
470
fingerprint_to_authors = {}
471
for rev_id, validity, fingerprint in result:
472
if validity == SIGNATURE_EXPIRED:
473
revision = repo.get_revision(rev_id)
474
authors = ', '.join(revision.get_apparent_authors())
475
signers.setdefault(fingerprint, 0)
476
signers[fingerprint] += 1
477
fingerprint_to_authors[fingerprint] = authors
479
for fingerprint, number in signers.items():
481
ngettext(u"{0} commit by author {1} with key {2} now expired",
482
u"{0} commits by author {1} with key {2} now expired",
484
number, fingerprint_to_authors[fingerprint], fingerprint))
488
def verbose_valid_message(result):
489
"""takes a verify result and returns list of signed commits strings"""
491
for rev_id, validity, uid in result:
492
if validity == SIGNATURE_VALID:
493
signers.setdefault(uid, 0)
496
for uid, number in signers.items():
497
result.append(ngettext(u"{0} signed {1} commit",
498
u"{0} signed {1} commits",
499
number).format(uid, number))
503
def verbose_not_valid_message(result, repo):
504
"""takes a verify result and returns list of not valid commit info"""
506
for rev_id, validity, empty in result:
507
if validity == SIGNATURE_NOT_VALID:
508
revision = repo.get_revision(rev_id)
509
authors = ', '.join(revision.get_apparent_authors())
510
signers.setdefault(authors, 0)
511
signers[authors] += 1
513
for authors, number in signers.items():
514
result.append(ngettext(u"{0} commit by author {1}",
515
u"{0} commits by author {1}",
516
number).format(number, authors))
520
def verbose_not_signed_message(result, repo):
521
"""takes a verify result and returns list of not signed commit info"""
523
for rev_id, validity, empty in result:
524
if validity == SIGNATURE_NOT_SIGNED:
525
revision = repo.get_revision(rev_id)
526
authors = ', '.join(revision.get_apparent_authors())
527
signers.setdefault(authors, 0)
528
signers[authors] += 1
530
for authors, number in signers.items():
531
result.append(ngettext(u"{0} commit by author {1}",
532
u"{0} commits by author {1}",
533
number).format(number, authors))
537
def verbose_missing_key_message(result):
538
"""takes a verify result and returns list of missing key info"""
540
for rev_id, validity, fingerprint in result:
541
if validity == SIGNATURE_KEY_MISSING:
542
signers.setdefault(fingerprint, 0)
543
signers[fingerprint] += 1
545
for fingerprint, number in signers.items():
546
result.append(ngettext(u"Unknown key {0} signed {1} commit",
547
u"Unknown key {0} signed {1} commits",
548
number).format(fingerprint, number))