Commits

Anonymous committed d25a660

[ui] avoid displaying long and wide subprocess output

Comments (0)

Files changed (4)

ui/console/console_ui.py

         elif isinstance(element, TextBox):
             text_box_display(element.title, element.text)
         elif isinstance(element, SubprocessBox):
-            text_box_display(element.title, element.output)
+            # avoid long subprocess logs, limit the number of lines
+            # and the width
+            text_box_display(element.title, element.output, n_tail=40,
+                             max_width=120)
         elif isinstance(element, PathBox):
             text_input_display(element.title, element.path)
         else:
     def _execute_element(self, element):
         
         if isinstance(element, SubprocessBox):
+            if element.cmd is None:
+                raise ValueError("Command not defined")
             execution = subprocess_execute(element.cmd)
             return execution
         else:

ui/console/console_widgets.py

 def text_input_display(title, text):
     print ' %s: %s' % (title, text)
 
-def text_box_display(header, text, n_head=None, n_tail=None):
+def text_box_display(header, text, n_head=None, n_tail=None,
+                     max_width=None):
 
     if text: # text may be None
         lines = text.split('\n')
             lines = lines[-n_tail:]
             lines.insert(0, "*** last %d lines ***" % n_tail)
     lines.insert(0, header)
-    max_length = max([len(l) for l in lines])
-    separator = '-' * max_length
+    width = max([len(l) for l in lines])
+    if max_width is not None and width > max_width:
+        width = max_width
+    separator = '-' * (width + 1)
     if text:
         lines.insert(1, separator)  # after the header
     print(' /%s\\' % separator)
     for line in lines:
-        print(' |%s%s|' % (line, ' ' * (max_length - len(line))))
+        if len(line) > width:
+            line = line[:width]
+            star = '*'
+        else:
+            star = ' ' 
+        print(' |%s%s%s|' % (line, ' ' * (width - len(line)), star))
     print(' \\%s/' % separator)
 
 def text_box_edit(prompt):

ui/console/menu.py

-from limma.config.logger import get_module_logger
+from limma.util.logger import get_module_logger
 
 class Option(object):
     # pylint: disable=R0903

ui/gui/qt/qt_ui.py

+class QtUI(object):
+    pass