Commit 7c0ef84e authored by Giorgos Korfiatis's avatar Giorgos Korfiatis Committed by Christos Stavrakakis
Browse files

snf_django: Handle unicode in CommandError

Define a custom CommandError, which applies smart_locale_str() in its
__str__ method. Use this custom CommandError in Astakos management
commands.
parent 794f7588
......@@ -31,13 +31,11 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from astakos.im import activation_backends
activation_backend = activation_backends.get_backend()
from ._common import get_user
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -34,12 +34,11 @@
from optparse import make_option
from django.db import transaction
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from django.core.validators import validate_email
from django.core.exceptions import ValidationError
from astakos.im.models import AstakosUser, get_latest_terms
from snf_django.management.commands import SynnefoCommand
from astakos.im.auth import make_local_user
......
......@@ -38,14 +38,13 @@ from optparse import make_option
from django.core import management
from django.db import transaction
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from django.contrib.auth.models import Group
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from astakos.im.models import AstakosUser
from astakos.im import activation_backends
from snf_django.management.commands import SynnefoCommand
from ._common import (remove_user_permission, add_user_permission, is_uuid)
activation_backend = activation_backends.get_backend()
......
......@@ -31,7 +31,6 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import CommandError
from optparse import make_option
from django.db.models import Q
......@@ -39,7 +38,7 @@ from astakos.im.models import AstakosUser, get_latest_terms, Project
from astakos.im.quotas import get_user_quotas
from synnefo.lib.ordereddict import OrderedDict
from snf_django.management.commands import SynnefoCommand
from snf_django.management.commands import SynnefoCommand, CommandError
from snf_django.management import utils
from ._common import show_user_quotas, style_options, check_style
......
......@@ -34,9 +34,8 @@
from optparse import make_option
from django.db import transaction
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand
from snf_django.management.commands import SynnefoCommand, CommandError
from astakos.oa2.models import Client, RedirectUrl
from astakos.oa2 import settings
......
......@@ -31,10 +31,9 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from django.db import transaction
from snf_django.management.commands import SynnefoCommand
from astakos.oa2.models import Client
......
......@@ -31,8 +31,7 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import CommandError
from snf_django.management.commands import ListCommand
from snf_django.management.commands import ListCommand, CommandError
from optparse import make_option
from astakos.quotaholder_app.models import Commission
......
......@@ -31,8 +31,7 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand
from snf_django.management.commands import SynnefoCommand, CommandError
from snf_django.management import utils
from astakos.quotaholder_app.models import Commission, Provision
......
......@@ -39,7 +39,8 @@ import logging
from optparse import (make_option, OptionParser, OptionGroup,
TitledHelpFormatter)
from synnefo import settings
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import (BaseCommand,
CommandError as DjangoCommandError)
from django.core.exceptions import FieldError
from snf_django.management import utils
from snf_django.lib.astakos import UserCache
......@@ -82,6 +83,11 @@ class SynnefoOutputWrapper(object):
self.django_wrapper.write(msg, *args, **kwargs)
class CommandError(DjangoCommandError):
def __str__(self):
return utils.smart_locale_str(self.message, errors='replace')
class SynnefoCommandFormatter(TitledHelpFormatter):
def format_heading(self, heading):
if heading == "Options":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment