Commit ea2528d5 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

snf_django: Handle unicodes in SynnefoCommand

Extend the SynnefoCommand to override the 'run_from_argv' function in
order to decode command line arguments and options, using the user's
preferred encoding.

Some options of snf-manage commands may be list or tuples. Applying
'smart_unicode' to them will convert them to unicode object. Instead
of recursively converting data, we convert the arguments to unicodes
before being parsed.
parent 5d45ac85
......@@ -38,11 +38,9 @@ import datetime
import logging
from optparse import (make_option, OptionParser, OptionGroup,
from synnefo import settings
from import BaseCommand, CommandError
from django.core.exceptions import FieldError
from import utils
from snf_django.lib.astakos import UserCache
from snf_django.utils.line_logging import NewlineStreamHandler
......@@ -107,7 +105,7 @@ class SynnefoCommand(BaseCommand):
stderr = SynnefoOutputWrapper()
def run_from_argv(self, argv):
"""Initialize logger for 'SynnefoOutputWrapper' and call super
"""Initialize loggers and convert arguments to unicode objects
Create a filename based on the timestamp, the running
command and the pid. Then create a new logger that will
......@@ -119,6 +117,9 @@ class SynnefoCommand(BaseCommand):
Commands that match the 'LOGGER_EXCLUE_COMMANDS' pattern will not be
logged (by default all *-list and *-show commands).
Also, convert command line arguments and options to unicode objects
using user's preferred encoding.
curr_time =
curr_time = datetime.datetime.strftime(curr_time, "%y%m%d%H%M%S")
......@@ -188,7 +189,9 @@ class SynnefoCommand(BaseCommand):
% (filename, err)
argv = [utils.smart_locale_unicode(a) for a in argv]
super(SynnefoCommand, self).run_from_argv(argv)
if stream is not None:
fd = None
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