update_9.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env python3
  2. # Contest Management System - http://cms-dev.github.io/
  3. # Copyright © 2014 Stefano Maggiolo <s.maggiolo@gmail.com>
  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. """A class to update a dump created by CMS.
  18. Used by DumpImporter and DumpUpdater.
  19. This is a fake updater that warns about a change in the way Java
  20. submissions are compiled. This applies only to batch tasks with no
  21. grader (as it was the only task type supporting Java). The difference
  22. is that before the public class submitted by contestant had to be
  23. named "Task", whereas now it must be called with the task short name.
  24. """
  25. import logging
  26. logger = logging.getLogger(__name__)
  27. class Updater:
  28. def __init__(self, data):
  29. assert data["_version"] == 8
  30. self.objs = data
  31. def run(self):
  32. for k, v in self.objs.items():
  33. if k.startswith("_"):
  34. continue
  35. if v["_class"] == "Submission" and v["language"] == "java":
  36. logger.warning(
  37. "The way Java submissions are compiled has changed, and\n"
  38. "previously valid submissions will now fail to compile.\n"
  39. "If you want to obtain again the same results, you have\n"
  40. "to (manually) change the name of the public class, from\n"
  41. "the literal \"Task\" to the short name of the task,\n"
  42. "in each submitted Java file.")
  43. break
  44. return self.objs