← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~wesley-wiedenmeier/cloud-init:error-output into cloud-init:master

 


Diff comments:

> diff --git a/cloudinit/util.py b/cloudinit/util.py
> index eb3e589..b9c88c9 100644
> --- a/cloudinit/util.py
> +++ b/cloudinit/util.py
> @@ -286,6 +287,20 @@ class ProcessExecutionError(IOError):
>          if not hasattr(self, 'message'):
>              self.message = message
>  
> +    def _indent_text(self, text, indent_level=8):
> +        """
> +        indent text on all but the first line, allowing for easy to read output
> +        """
> +        # if we are running on python3, then we need to make sure that this is
> +        # a str, not bytes. on python2, this is not so important as bytes is
> +        # basically just str
> +        if six.PY3:

seems like it might be better to return what you were passed in.
I'd not expect this function to convert bytes to text.

cr = '\n'
indent = ' ' * indent_level
if isinstance(text, string.binary_type):
    cr = cr.encode()
    indent = indent.encode()

return text.rstrip(cr).replace(cr, cr + indent)

> +            if isinstance(text, bytes):
> +                text = text.decode()
> +        # remove any newlines at end of text first to prevent unneeded blank
> +        # line in output
> +        return text.rstrip('\n').replace('\n', '\n' + ' ' * indent_level)
> +
>  
>  class SeLinuxGuard(object):
>      def __init__(self, path, recursive=False):


-- 
https://code.launchpad.net/~wesley-wiedenmeier/cloud-init/+git/cloud-init/+merge/306731
Your team cloud init development team is requested to review the proposed merge of ~wesley-wiedenmeier/cloud-init:error-output into cloud-init:master.


References