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

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
......@@ -36,7 +36,7 @@ import uuid
from django.core.validators import validate_email
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.core.management import CommandError
from snf_django.management.commands import CommandError
from synnefo.util import units
from astakos.im.models import AstakosUser
......
......@@ -32,7 +32,7 @@
# or implied, of GRNET S.A.
from synnefo.util import units
from django.core.management import CommandError
from snf_django.management.commands import CommandError
from django.db.models import Q
......
......@@ -35,10 +35,9 @@ import string
from optparse import make_option
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from astakos.im.models import AuthProviderPolicyProfile as Profile
from snf_django.management.commands import SynnefoCommand
option_list = list(SynnefoCommand.option_list) + [
make_option('--update',
......
......@@ -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 astakos.im.models import AuthProviderPolicyProfile as Profile
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -34,9 +34,7 @@
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.im.models import AuthProviderPolicyProfile as Profile
from astakos.im.models import AstakosUser, Group
......
......@@ -31,11 +31,9 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import CommandError
from astakos.im.models import AuthProviderPolicyProfile as Profile
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
......
......@@ -32,10 +32,8 @@
# or implied, of GRNET S.A.
from optparse import make_option
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from astakos.im.models import Component
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -32,11 +32,8 @@
# or implied, of GRNET S.A.
from optparse import make_option
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from astakos.im.models import Component
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -31,11 +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 astakos.im.models import Component
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -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 astakos.im.models import Component
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
......
......@@ -32,10 +32,9 @@
# or implied, of GRNET S.A.
from django.db import transaction
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from astakos.im.auth import fix_superusers
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -31,10 +31,8 @@
# 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.models import Group
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 import utils
from snf_django.management.commands import SynnefoCommand, CommandError
from astakos.im.functions import (terminate, suspend, unsuspend,
reinstate, check_expiration,
approve_application, deny_application)
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -34,7 +34,7 @@
from optparse import make_option
from django.db.models import Q
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from django.db import transaction
from synnefo.util import units
from astakos.im import functions
......@@ -43,7 +43,6 @@ import astakos.api.projects as api
import synnefo.util.date as date_util
from snf_django.management import utils
from astakos.im.management.commands import _common
from snf_django.management.commands import SynnefoCommand
def make_policies(limits):
......
......@@ -32,10 +32,9 @@
# or implied, of GRNET S.A.
from optparse import make_option
from django.core.management.base import CommandError
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 astakos.im.models import ProjectApplication, Project
from astakos.im import quotas
......
......@@ -34,9 +34,8 @@
from optparse import make_option
from datetime import datetime
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from django.db import transaction
from snf_django.utils import reconcile
from snf_django.management.utils import pprint_table
from astakos.im.models import Component, AstakosUser
......@@ -44,7 +43,6 @@ from astakos.im import quotas
from astakos.im.functions import count_pending_app
import astakos.quotaholder_app.callpoint as qh
import astakos.quotaholder_app.exception as qh_exception
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -32,13 +32,12 @@
# or implied, of GRNET S.A.
from optparse import make_option
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from snf_django.management import utils
from astakos.im.models import Resource
from astakos.im import register
from ._common import style_options, check_style, units
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -34,11 +34,10 @@
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.utils import simplejson as json
from astakos.im.register import add_service, add_resource, RegisterException
from snf_django.management.commands import SynnefoCommand
from astakos.im.models import Component
from ._common import read_from_file
......
......@@ -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 astakos.im.models import Service, EndpointData
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
......
......@@ -32,12 +32,9 @@
# or implied, of GRNET S.A.
from os.path import abspath
from django.core.management.base import CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from django.db import transaction
from astakos.im.models import ApprovalTerms, AstakosUser
from snf_django.management.commands import SynnefoCommand
class Command(SynnefoCommand):
......
......@@ -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