sio2project / oioioi

GNU General Public License v3.0
160 stars 70 forks source link

A few management commands are broken #246

Closed A-dead-pixel closed 11 months ago

A-dead-pixel commented 11 months ago

The find_all_se_submissions and stats_all_submissions management commands are broken, because they still use the deprecated and removed ugettext. Seems like these missed 9521e8f60da0c35c2fb14500c1e2f57c4c50f9f7 by being merged later in a4c9ad87906a03e2c3181c99a1e6f32862dc2358.

Trimmed traceback (most recent call last):

 File "./manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)

...

  File "/sio2/oioioi/oioioi/contests/management/commands/find_all_se_submissions.py", line 8, in <module>
    from django.utils.translation import ugettext as _
ImportError: cannot import name 'ugettext' from 'django.utils.translation' (/home/oioioi/.local/lib/python3.8/site-packages/django/utils/translation/__init__.py)

Additionally, maintenance_mode uses gettext_lazy for translating the help text, which causes this error when it is run with --help:

Traceback (most recent call last):
  File "./manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/home/oioioi/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/oioioi/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/oioioi/.local/lib/python3.8/site-packages/django/core/management/base.py", line 406, in run_from_argv
    options = parser.parse_args(argv[2:])
  File "/home/oioioi/.local/lib/python3.8/site-packages/django/core/management/base.py", line 67, in parse_args
    return super().parse_args(args, namespace)
  File "/usr/local/lib/python3.8/argparse.py", line 1768, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/local/lib/python3.8/argparse.py", line 1800, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/local/lib/python3.8/argparse.py", line 2006, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/local/lib/python3.8/argparse.py", line 1946, in consume_optional
    take_action(action, args, option_string)
  File "/usr/local/lib/python3.8/argparse.py", line 1874, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/local/lib/python3.8/argparse.py", line 1044, in __call__
    parser.print_help()
  File "/usr/local/lib/python3.8/argparse.py", line 2494, in print_help
    self._print_message(self.format_help(), file)
  File "/usr/local/lib/python3.8/argparse.py", line 2478, in format_help
    return formatter.format_help()
  File "/usr/local/lib/python3.8/argparse.py", line 282, in format_help
    help = self._root_section.format_help()
  File "/usr/local/lib/python3.8/argparse.py", line 213, in format_help
    item_help = join([func(*args) for func, args in self.items])
  File "/usr/local/lib/python3.8/argparse.py", line 213, in <listcomp>
    item_help = join([func(*args) for func, args in self.items])
  File "/usr/local/lib/python3.8/argparse.py", line 497, in _format_text
    return self._fill_text(text, text_width, indent) + '\n\n'
  File "/usr/local/lib/python3.8/argparse.py", line 641, in _fill_text
    text = self._whitespace_matcher.sub(' ', text).strip()
TypeError: expected string or bytes-like object

import_users uses it too, but in such a way that doesn't cause errors.