[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, experimental, updated. debian/2.1.1-1_experimental1-51-g95835b7

Garrett Holmstrom gholms at fedoraproject.org
Thu Jan 3 11:06:13 UTC 2013


The following commit has been merged in the experimental branch:
commit 4562d9d640a3cf137eaaa16ed1e8951099779aa3
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date:   Tue Nov 27 16:01:38 2012 -0800

    Escape GetConsoleOutput control codes by default
    
    euca-get-console-output used to print the output it got from the server
    verbatim, including control codes.  This fix escapes them by default.
    Use the --raw switch to get the old behavior back.
    
    Fixes TOOLS-156

diff --git a/euca2ools/commands/euca/getconsoleoutput.py b/euca2ools/commands/euca/getconsoleoutput.py
index 6dbf9a7..a5f235b 100644
--- a/euca2ools/commands/euca/getconsoleoutput.py
+++ b/euca2ools/commands/euca/getconsoleoutput.py
@@ -40,12 +40,25 @@ class GetConsoleOutput(euca2ools.commands.eucacommand.EucaCommand):
     Args = [Param(name='instance_id', ptype='string', optional=False,
                   doc="""unique identifier for instance
                   to show the console output for.""")]
+    Options = [Param(name='raw', long_name='raw', ptype='boolean',
+                     default=False, optional=True,
+                     doc='''Display raw output without escaping control
+                     characters''')]
 
     def display_console_output(self, console_output):
         print console_output.instance_id
         print console_output.timestamp
-        print console_output.output
-        
+        output = console_output.output
+        if not self.raw:
+            # Escape control characters
+            esc_ords = (list(range(0x00, 0x09)) + list(range(0x0e, 0x1f)) +
+                        [0x0b, 0x0c, 0x7f])
+            for esc_ord in esc_ords:
+                # Small assumption:  we aren't translating ' or "
+                output = output.replace(chr(esc_ord),
+                                        repr(chr(esc_ord)).strip('\'"'))
+        print output
+
     def main(self):
         conn = self.make_connection_cli()
         return self.make_request_cli(conn, 'get_console_output',
@@ -54,4 +67,3 @@ class GetConsoleOutput(euca2ools.commands.eucacommand.EucaCommand):
     def main_cli(self):
         co = self.main()
         self.display_console_output(co)
-

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list