housekeeping.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # nm.debian.org website maintenance
  2. #
  3. # Copyright (C) 2012 Enrico Zini <enrico@debian.org>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU Affero General Public License as
  7. # published by the Free Software Foundation, either version 3 of the
  8. # License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Affero General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. from __future__ import print_function
  18. from __future__ import absolute_import
  19. from __future__ import division
  20. from __future__ import unicode_literals
  21. import django_housekeeping as hk
  22. from backend.maintenance import MakeLink
  23. import backend.models as bmodels
  24. from backend import const
  25. from . import models as pmodels
  26. import logging
  27. log = logging.getLogger(__name__)
  28. class CheckDMList(hk.Task):
  29. """
  30. Show entries that do not match between projectb DM list and out DB
  31. """
  32. DEPENDS = [MakeLink]
  33. def run_main(self):
  34. # Code used to import DMs is at 64a3e35a5c55aa3ee122e6234ad24c74a57dd843
  35. # Now this is just a consistency check
  36. maints = pmodels.Maintainers()
  37. def check_status(p):
  38. if p.status not in (const.STATUS_DM, const.STATUS_DM_GA):
  39. log.info("%s: %s DB status is %s but it appears to projectb to be a DM instead",
  40. self.IDENTIFIER, self.maint.link(p), p.status)
  41. for maint in maints.db.itervalues():
  42. person = bmodels.Person.lookup(maint["fpr"])
  43. if person is not None:
  44. check_status(person)
  45. continue
  46. person = bmodels.Person.lookup(maint["email"])
  47. if person is not None:
  48. log.info("%s: %s matches by email %s with projectb but not by key fingerprint",
  49. self.IDENTIFIER, self.maint.link(person), maint["email"])
  50. check_status(person)
  51. continue
  52. log.info("%s: %s/%s exists in projectb but not in our DB",
  53. self.IDENTIFIER, maint["email"], maint["fpr"])