From: Nikos Skalkotos Date: Wed, 8 Aug 2012 13:13:57 +0000 (+0300) Subject: Add a new clear method in the Output class X-Git-Tag: v0.1~38 X-Git-Url: https://code.grnet.gr/git/snf-image-creator/commitdiff_plain/4a847a9870e0eebb5efff3012e4eaaf5974735f1 Add a new clear method in the Output class In the cli output classes this method will clear terminal screen if the standard output is a terminal. --- diff --git a/image_creator/dialog_wizard.py b/image_creator/dialog_wizard.py index 8e122a8..e26975e 100644 --- a/image_creator/dialog_wizard.py +++ b/image_creator/dialog_wizard.py @@ -177,7 +177,7 @@ def extract_image(session): device.out = out image_os.out = out - out.output() + out.clear() #Sysprep device.mount(False) diff --git a/image_creator/output/__init__.py b/image_creator/output/__init__.py index 99653d3..3992846 100644 --- a/image_creator/output/__init__.py +++ b/image_creator/output/__init__.py @@ -48,6 +48,9 @@ class Output(object): def cleanup(self): pass + def clear(self): + pass + def _get_progress(self): progress = self._Progress progress.output = self diff --git a/image_creator/output/cli.py b/image_creator/output/cli.py index c7b5a55..37022d5 100644 --- a/image_creator/output/cli.py +++ b/image_creator/output/cli.py @@ -58,6 +58,12 @@ def success(msg, new_line=True, colored=True): output(msg, new_line, color) +def clear(): + #clear the page + if sys.stderr.isatty(): + sys.stderr.write('\033[H\033[2J') + + class SilentOutput(Output): pass @@ -78,6 +84,9 @@ class SimpleOutput(Output): def output(self, msg='', new_line=True): output(msg, new_line) + def clear(self): + clear() + class OutputWthProgress(SimpleOutput): class _Progress(Bar):