You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/26 02:27:43 UTC

[GitHub] csantanapr closed pull request #3344: Extract message from callback and add it to pretty printed text.

csantanapr closed pull request #3344: Extract message from callback and add it to pretty printed text.
URL: https://github.com/apache/incubator-openwhisk/pull/3344
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ansible/callbacks/logformatter.py b/ansible/callbacks/logformatter.py
index 754b68ee2f..c2aabb26a2 100644
--- a/ansible/callbacks/logformatter.py
+++ b/ansible/callbacks/logformatter.py
@@ -20,6 +20,7 @@
 from __future__ import (absolute_import, division, print_function)
 import os
 import sys
+import textwrap
 from ansible.plugins.callback import CallbackBase
 __metaclass__ = type
 
@@ -35,14 +36,18 @@ def emit(self, host, category, data):
         """Emit colorized output based upon data contents."""
         if type(data) == dict:
             cmd = data['cmd'] if 'cmd' in data else None
+            msg = data['msg'] if 'msg' in data else None
             stdout = data['stdout'] if 'stdout' in data else None
             stderr = data['stderr'] if 'stderr' in data else None
             reason = data['reason'] if 'reason' in data else None
 
+            print()
             if cmd:
-                print(hilite('[%s]\n> %s' % (category, cmd), category))
+                print(hilite('[%s]\n> %s' % (category, cmd), category, wrap = False))
             if reason:
                 print(hilite(reason, category))
+            if msg:
+                print(hilite(msg, category))
             if stdout:
                 print(hilite(stdout, category))
             if stderr:
@@ -64,7 +69,7 @@ def runner_on_async_failed(self, host, res, jid):
         self.emit(host, 'FAILED', res)
 
 
-def hilite(msg, status):
+def hilite(msg, status, wrap = True):
     """Highlight message."""
     def supports_color():
         if ((sys.platform != 'win32' or 'ANSICON' in os.environ) and
@@ -81,6 +86,7 @@ def supports_color():
         else:
             # bold
             attr.append('1')
-        return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), msg)
+        text = '\x1b[%sm%s\x1b[0m' % (';'.join(attr), msg)
     else:
-        return msg
+        text = msg
+    return textwrap.fill(text, 80) if wrap else text


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services