[server] fix --help output when redirected through pipes, fix bug 4049

This commit is contained in:
Fabio Erculiani
2013-03-08 12:55:59 +01:00
parent 113f9d74b7
commit a1e59c352f
35 changed files with 85 additions and 35 deletions
+17 -1
View File
@@ -10,7 +10,7 @@
"""
from entropy.i18n import _
from entropy.output import darkgreen, print_error
from entropy.output import darkgreen, print_error, print_generic
from entropy.exceptions import PermissionDenied
from entropy.server.interfaces import Server
from entropy.core.settings.base import SystemSettings
@@ -48,6 +48,22 @@ class EitCommand(object):
"""
raise NotImplementedError()
def print_help(self, parser):
"""
ArgumentParser.print_help wrapper that properly handles
UTF-8 encoding in a fault-tolerant way. Also see bug #4049.
@param parser: an ArgumentParser object
@type parser: argparse.ArgumentParser
"""
class _Printer(object):
@classmethod
def write(self, string):
print_generic(string)
parser.print_help(file=_Printer)
def parse(self):
"""
Parse the actual arguments and return