summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/frontend.py9
-rw-r--r--ipaserver/advise/base.py7
2 files changed, 13 insertions, 3 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 67ca7767c..cac3e3b39 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -35,6 +35,7 @@ from errors import (ZeroArgumentError, MaxArgumentError, OverlapError,
VersionError, OptionError, InvocationError,
ValidationError, ConversionError)
from ipalib import messages
+from textwrap import wrap
RULE_FLAG = 'validation_rule'
@@ -1454,8 +1455,12 @@ class _AdviceOutput(object):
self.prefix = '# '
self.options = None
- def comment(self, line):
- self.content.append(self.prefix + line)
+ def comment(self, line, wrapped=True):
+ if wrapped:
+ for wrapped_line in wrap(line, 70):
+ self.content.append(self.prefix + wrapped_line)
+ else:
+ self.content.append(self.prefix + line)
def debug(self, line):
if self.options.verbose:
diff --git a/ipaserver/advise/base.py b/ipaserver/advise/base.py
index 4b6ee96f8..b26bbc6b3 100644
--- a/ipaserver/advise/base.py
+++ b/ipaserver/advise/base.py
@@ -46,7 +46,7 @@ Optionally, you can require root privileges for your plugin:
The following method should be implemented in your plugin:
->>>.....def get_info():
+>>> def get_info():
>>> self.log.debug('Entering execute() method')
>>> self.log.comment('Providing useful advice just for you')
>>> self.log.command('yum update sssd -y')
@@ -55,6 +55,11 @@ As you can see, Advice's log has 3 different levels. Debug lines are printed
out with '# DEBUG:' prefix if --verbose had been used. Comment lines utilize
'# ' prefix and command lines are printed raw.
+Please note that comments are automatically wrapped after 70 characters.
+Use wrapped=False option to force the unwrapped line in the comment.
+
+>>> self.log.comment("This line should not be wrapped", wrapped=False)
+
As a result, you can redirect the advice's output directly to a script file.
# ipa-advise sample-advice > script.sh