Ignore:
Timestamp:
11/02/12 17:25:23 (18 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added 'Output' window showing redirected stdout/stderr.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/main.py

    r11147 r11167  
    99import optparse 
    1010import cPickle 
     11from contextlib import nested 
    1112 
    1213import pkg_resources 
     
    2223from Orange.OrangeCanvas.config import open_config, cache_dir 
    2324from Orange.OrangeCanvas import config 
     25from Orange.OrangeCanvas.utils.redirect import redirect_stdout, redirect_stderr 
    2426 
    2527from Orange.OrangeCanvas.registry import qt 
     
    5961                      help="Logging level (0, 1, 2, 3)", 
    6062                      type="int", default=1) 
     63    parser.add_option("--no-redirect", 
     64                      action="store_true", 
     65                      help="Do not redirect stdout/err to canvas output view.") 
    6166    parser.add_option("--style", 
    6267                      help="QStyle to use", 
     
    138143 
    139144    want_splash = \ 
    140         settings.value("startup/show-splash-screen", True).toPyObject() 
     145        settings.value("startup/show-splash-screen", True).toPyObject() and \ 
     146        not options.no_splash 
    141147 
    142148    if want_splash: 
     
    187193        canvas_window.load_scheme(args[0]) 
    188194 
    189     log.info("Entering main event loop.") 
    190     try: 
    191         status = app.exec_() 
    192     except BaseException: 
    193         log.error("Error in main event loop.", exc_info=True) 
     195    disable_redirect = \ 
     196        settings.value("mainwindow/no-stdout-redirect", False).toBool() or \ 
     197        options.no_redirect 
     198 
     199    if not disable_redirect: 
     200        output = canvas_window.output_view() 
     201    else: 
     202        output = None 
     203 
     204    with nested(redirect_stdout(output), redirect_stderr(output)): 
     205        log.info("Entering main event loop.") 
     206        try: 
     207            status = app.exec_() 
     208        except BaseException: 
     209            log.error("Error in main event loop.", exc_info=True) 
    194210 
    195211    canvas_window.deleteLater() 
Note: See TracChangeset for help on using the changeset viewer.