Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
6fc912de
Commit
6fc912de
authored
Mar 12, 2012
by
Enrico Zini
Browse files
Implemented crosschecks with keyring
parent
7e5e0fe9
Changes
1
Hide whitespace changes
Inline
Side-by-side
maintenance/management/commands/maintenance.py
View file @
6fc912de
...
...
@@ -31,6 +31,18 @@ import keyring.models as kmodels
log
=
logging
.
getLogger
(
__name__
)
class
Checker
(
object
):
def
__init__
(
self
):
log
.
info
(
"Importing dm keyring..."
)
self
.
dm
=
frozenset
(
kmodels
.
list_dm
())
log
.
info
(
"Importing dd_u keyring..."
)
self
.
dd_u
=
frozenset
(
kmodels
.
list_dd_u
())
log
.
info
(
"Importing dd_nu keyring..."
)
self
.
dd_nu
=
frozenset
(
kmodels
.
list_dd_nu
())
log
.
info
(
"Importing emeritus_dd keyring..."
)
self
.
emeritus_dd
=
frozenset
(
kmodels
.
list_emeritus_dd
())
log
.
info
(
"Importing removed_dd keyring..."
)
self
.
removed_dd
=
frozenset
(
kmodels
.
list_removed_dd
())
@
transaction
.
commit_on_success
def
compute_am_ctte
(
self
,
**
kw
):
from
django.db.models
import
Max
...
...
@@ -137,6 +149,40 @@ class Checker(object):
if
c
>
0
:
log
.
warning
(
"%d entries still have a NULL status_changed date"
,
c
)
def
check_keyring_consistency
(
self
,
**
kw
):
# Prefetch people and index them by fingerprint
people_by_fpr
=
dict
()
for
p
in
bmodels
.
Person
.
objects
.
all
():
if
p
.
fpr
is
None
:
continue
people_by_fpr
[
p
.
fpr
]
=
p
# TODO: not quite sure how to handle the removed_dd keyring, until I
# know what exactly is in there
# self.removed_dd = frozenset(kmodels.list_removed_dd())
for
status
,
keys
in
(
((
const
.
STATUS_DM
,
const
.
STATUS_DM_GA
),
"dm"
),
((
const
.
STATUS_DD_U
,),
"dd_u"
),
((
const
.
STATUS_DD_NU
,),
"dd_nu"
),
((
const
.
STATUS_EMERITUS_DD
,),
"emeritus_dd"
)):
keyring
=
getattr
(
self
,
keys
)
# Show people that have a status in our DB which does not match
# keyring
for
fpr
,
p
in
people_by_fpr
.
iteritems
():
if
p
.
status
not
in
status
:
continue
if
fpr
not
in
keyring
:
log
.
warning
(
"%s has status %s but is not in %s keyring"
,
repr
(
p
),
p
.
status
,
keys
)
# Show keys that are in the keyring but do not match our db
for
fpr
in
keyring
:
p
=
people_by_fpr
.
get
(
fpr
,
None
)
if
p
is
None
:
log
.
warning
(
"Fingerprint %s is in %s keyring but not in our db"
,
fpr
,
keys
)
elif
p
.
status
not
in
status
:
log
.
warning
(
"Fingerprint %s is in %s keyring its corresponding person %s has status %s"
,
fpr
,
keys
,
repr
(
p
),
p
.
status
)
def
run
(
self
,
**
opts
):
"""
Run all checker functions
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment