def _init_logging( parsed_args ): from ilastik.ilastik_logging import default_config, startUpdateInterval if ilastik_config.getboolean('ilastik', 'debug') or parsed_args.headless: default_config.init(output_mode=default_config.OutputMode.BOTH) else: default_config.init(output_mode=default_config.OutputMode.LOGFILE_WITH_CONSOLE_ERRORS) startUpdateInterval(10) # 10 second periodic refresh
def _init_logging( parsed_args ): from ilastik.ilastik_logging import default_config, startUpdateInterval if ilastik_config.getboolean('ilastik', 'debug') or parsed_args.headless: default_config.init(output_mode=default_config.OutputMode.BOTH) else: default_config.init(output_mode=default_config.OutputMode.LOGFILE_WITH_CONSOLE_ERRORS) startUpdateInterval(10) # 10 second periodic refresh if parsed_args.redirect_output: logger.info( "All console output is being redirected to: {}" .format( parsed_args.redirect_output ) )
def _init_logging(parsed_args): from ilastik.ilastik_logging import default_config, startUpdateInterval, DEFAULT_LOGFILE_PATH logfile_path = parsed_args.logfile or DEFAULT_LOGFILE_PATH process_name = "" if parsed_args.process_name: process_name = parsed_args.process_name + " " if ilastik_config.getboolean("ilastik", "debug") or parsed_args.headless: default_config.init(process_name, default_config.OutputMode.BOTH, logfile_path) else: default_config.init(process_name, default_config.OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path) startUpdateInterval(10) # 10 second periodic refresh if parsed_args.redirect_output: logger.info("All console output is being redirected to: {}".format(parsed_args.redirect_output))
def _init_logging( parsed_args ): from ilastik.ilastik_logging import default_config, startUpdateInterval, DEFAULT_LOGFILE_PATH logfile_path = parsed_args.logfile or DEFAULT_LOGFILE_PATH process_name = "" if parsed_args.process_name: process_name = parsed_args.process_name + " " if ilastik_config.getboolean('ilastik', 'debug') or parsed_args.headless: default_config.init(process_name, default_config.OutputMode.BOTH, logfile_path) else: default_config.init(process_name, default_config.OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path) startUpdateInterval(10) # 10 second periodic refresh if parsed_args.redirect_output: logger.info( "All console output is being redirected to: {}" .format( parsed_args.redirect_output ) )
#!/usr/bin/env python # Standard import sys import argparse import threading import logging from functools import partial # Third-party from PyQt4.QtGui import QApplication from ilastik.config import cfg as ilastik_config # Initialize logging before anything else from ilastik.ilastik_logging import default_config default_config.init() # Ilastik from ilastik.utility.pathHelpers import PathComponents from ilastik.utility.gui.eventRecorder import EventPlayer from ilastik.shell.gui.startShellGui import startShellGui logger = logging.getLogger(__name__) def install_thread_excepthook(): # This function was copied from: http://bugs.python.org/issue1230540 # It is necessary because sys.excepthook doesn't work for unhandled exceptions in other threads. """ Workaround for sys.excepthook thread bug (https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1230540&group_id=5470). Call once from __main__ before creating any threads.
def _init_logging(logfile_path, process_name): from ilastik.ilastik_logging import default_config default_config.init(process_name + " ", default_config.OutputMode.BOTH, logfile_path)
import threading import traceback import atexit import platform from functools import partial from PyQt4.QtCore import Qt, QEvent, QPoint, QTimer from PyQt4.QtGui import QMouseEvent, QApplication, QPixmap, qApp import ilastik.config from ilastik.shell.gui.startShellGui import launchShell from ilastik.utility.gui.threadRouter import ThreadRouter from mainThreadHelpers import wait_for_main_func, run_in_main_thread from ilastik.ilastik_logging import default_config default_config.init(output_mode=default_config.OutputMode.CONSOLE) @atexit.register def quitApp(): if qApp is not None: qApp.quit() def run_shell_nosetest(filename): """ Launch nosetests from a separate thread, and pause this thread while the test runs the GUI in it. """ # This only works from the main thread. assert threading.current_thread().getName() == "MainThread" def run_nose(): sys.argv.append("--nocapture") # Don't steal stdout. Show it on the console as usual.
# Examples: # python ilastik.py --headless --project=MyProject.ilp --output_format=hdf5 raw_input.h5/volumes/data # python ilastik.py --playback_speed=2.0 --exit_on_failure --exit_on_success --debug --playback_script=my_recording.py parsed_args, workflow_cmdline_args = parser.parse_known_args() init_funcs = [] # Force debug mode if parsed_args.debug or parsed_args.start_recording or parsed_args.playback_script: ilastik_config.set('ilastik', 'debug', 'true') parsed_args.debug = True # Initialize logging before anything else from ilastik.ilastik_logging import default_config if ilastik_config.getboolean('ilastik', 'debug') or parsed_args.headless: default_config.init(output_mode=default_config.OutputMode.BOTH) else: default_config.init(output_mode=default_config.OutputMode.LOGFILE_WITH_CONSOLE_ERRORS) ilastik.ilastik_logging.startUpdateInterval(10) # 10 second periodic refresh import logging logger = logging.getLogger(__name__) # Monkey-patch thread starts if this special logger is active thread_start_logger = logging.getLogger("thread_start") if thread_start_logger.isEnabledFor(logging.DEBUG): import threading ordinary_start = threading.Thread.start def logged_start(self): ordinary_start(self) thread_start_logger.debug( "Started thread: id={:x}, name={}".format( self.ident, self.name ) ) threading.Thread.start = logged_start
from functools import partial import pytest from PyQt5.QtCore import Qt, QEvent, QPoint, QTimer from PyQt5.QtGui import QPixmap, QMouseEvent from PyQt5.QtWidgets import QApplication, qApp import ilastik.config from ilastik.shell.gui.startShellGui import launchShell from ilastik.utility.gui.threadRouter import ThreadRouter from .mainThreadHelpers import wait_for_main_func, run_in_main_thread from ilastik.ilastik_logging import default_config default_config.init(output_mode=default_config.OutputMode.CONSOLE) @atexit.register def quitApp(): if qApp is not None: qApp.quit() class MainThreadException(Exception): """Raised if GUI tests are run from main thread. Can't start QT app.""" pass def run_shell_test(filename): # This only works from the main thread.
#!/usr/bin/env python # Standard import sys import argparse import threading import logging from functools import partial # Third-party from ilastik.config import cfg as ilastik_config # Initialize logging before anything else from ilastik.ilastik_logging import default_config default_config.init() # Ilastik logger = logging.getLogger(__name__) def install_thread_excepthook(): # This function was copied from: http://bugs.python.org/issue1230540 # It is necessary because sys.excepthook doesn't work for unhandled exceptions in other threads. """ Workaround for sys.excepthook thread bug (https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1230540&group_id=5470). Call once from __main__ before creating any threads. If using psyco, call psycho.cannotcompile(threading.Thread.run) since this replaces a new-style class method. """ run_old = threading.Thread.run def run(*args, **kwargs):