[pkg-eucalyptus-commits] [euca2ools] 16/41: Always decode console output with stdout.encoding
Charles Plessy
plessy at alioth.debian.org
Sat Oct 12 03:24:14 UTC 2013
This is an automated email from the git hooks/post-receive script.
plessy pushed a commit to branch master
in repository euca2ools.
commit d39fd3a92fe8a1ed9d69946cd50851e097484305
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date: Thu Jul 18 16:17:55 2013 -0700
Always decode console output with stdout.encoding
Previously, euca-get-console-output always decoded console output as
UTF-8 unless instructed otherwise, which broke the final print statement
if sys.stdout.encoding happens to be ascii. Instead, we now always
attempt to decode using sys.stdout.encoding and replace non-decodable
characters with ? characters. To change this encoding, set LC_CTYPE in
the environment.
This also drops the recently-added --encoding option.
Fixes TOOLS-349
---
euca2ools/commands/euca/getconsoleoutput.py | 8 ++++----
man/euca-get-console-output.1 | 13 ++++++-------
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/euca2ools/commands/euca/getconsoleoutput.py b/euca2ools/commands/euca/getconsoleoutput.py
index eb5398f..80d4cda 100644
--- a/euca2ools/commands/euca/getconsoleoutput.py
+++ b/euca2ools/commands/euca/getconsoleoutput.py
@@ -26,6 +26,7 @@
import base64
from euca2ools.commands.euca import EucalyptusRequest
from requestbuilder import Arg
+import sys
CHAR_ESCAPES = {
@@ -48,15 +49,14 @@ class GetConsoleOutput(EucalyptusRequest):
obtain console output from (required)'''),
Arg('-r', '--raw-console-output', action='store_true',
route_to=None,
- help='display raw output without escaping control characters'),
- Arg('--encoding', route_to=None, default='utf-8', help='''character
- encoding of the console output (default: utf-8)''')]
+ help='display raw output without escaping control characters')]
def print_result(self, result):
print result.get('instanceId', '')
print result.get('timestamp', '')
output = base64.b64decode(result.get('output', ''))
- output = output.decode(self.args.get('encoding', 'utf-8'), 'replace')
+ output = output.decode(sys.stdout.encoding, 'replace')
+ output = output.replace(u'\ufffd', u'?')
if not self.args['raw_console_output']:
# Escape control characters
for char, escape in CHAR_ESCAPES.iteritems():
diff --git a/man/euca-get-console-output.1 b/man/euca-get-console-output.1
index 6d08ef6..2d802cd 100644
--- a/man/euca-get-console-output.1
+++ b/man/euca-get-console-output.1
@@ -1,10 +1,9 @@
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.12.
+.\" THIS FILE IS MAINTAINED MANUALLY. DO NOT AUTOMATICALLY OVERWRITE IT.
.TH EUCA-GET-CONSOLE-OUTPUT "1" "July 2013" "euca2ools 3.0.0" "User Commands"
.SH NAME
euca-get-console-output \- Retrieve console output for the specified instance
.SH SYNOPSIS
-euca\-get\-console\-output [\-r] [\-\-encoding ENCODING]
-[\-\-show\-empty\-fields]
+euca\-get\-console\-output [\-r] [\-\-show\-empty\-fields]
[\-\-region USER at REGION | \fB\-U\fR URL] [\-I KEY_ID]
[\-S KEY] [\-\-debug] [\-\-debugger] [\-\-version]
[\-h]
@@ -21,10 +20,6 @@ ID of the instance to obtain console output from
\fB\-r\fR, \fB\-\-raw\-console\-output\fR
display raw output without escaping control characters
.TP
-\fB\-\-encoding\fR ENCODING
-character encoding of the console output (default:
-utf\-8)
-.TP
\fB\-\-show\-empty\-fields\fR
show empty values as "(nil)"
.TP
@@ -50,3 +45,7 @@ show the program's version and exit
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
+.SH ENVIRONMENT VARIABLES
+.TP
+\fBLC_CTYPE\fR
+determines the interpretation of characters in the retrieved console output
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-eucalyptus/euca2ools.git
More information about the pkg-eucalyptus-commits
mailing list