Пример #1
0
def lo_exceptor(needle, level=None, suppress=False):
    ''' returns a function which will assert the specified log
        string/level when called; optionally suppresses other
        handlers until asserted '''

    levels = {}
    if suppress:
        for handler in lo.handlers:
            levels[handler] = handler.level
            handler.level = logging.FATAL

    needlehandler = NeedleHandler(needle, level)
    lo.addHandler(needlehandler)

    def lo_assert():
        msg = 'expected log message "%s"' % needle
        if level is not None:
            msg += ' (level %s)' % logging.getLevelName(level)
        assert needlehandler.found, msg

        lo.removeHandler(needlehandler)
        for handler in lo.handlers:
            handler.level = levels[handler]

    return lo_assert
Пример #2
0
    def __init__(self, testsuite_paths):
        ThemedTk.__init__(self)

        self.settings = Settings(default_config)
        self.testsuite_paths = testsuite_paths
        self.testsuites = {}

        frame = tk.Frame(self)

        self.scan = tk.Button(frame, text='scan .fastq files', command=self.do_scan)
        self.scan.pack()

        self.explore = tk.Button(frame, text='explore .json files', command=self.do_explore)
        self.explore.pack()

        dummy = tk.Label(frame)
        dummy.pack()

        self.config = tk.Button(frame, text='settings', command=self.do_config)
        self.config.pack()

        self.help = tk.Button(frame, text='help', command=open_help)
        self.help.pack()

        if logfn:
            self.showlog = tk.Button(frame, text='show log file', command=self.do_showlog)
            self.showlog.pack()

        frame.pack(side='left', padx=10)

        outer = tk.Frame(self, borderwidth=1, relief='ridge')
        outer.pack(side='left', expand=True, fill='both', padx=5, pady=5)
        label = tk.Label(outer, text='kvarq log output')
        label.pack()
        frame = tk.Frame(outer)
        frame.pack(expand=True, fill='both')
        self.text = tk.Text(frame) #, state=tk.DISABLED)
        self.text.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        scroll = tk.Scrollbar(frame, command=self.text.yview)
        scroll.pack(side=tk.RIGHT, fill=tk.Y)
        self.text.config(yscrollcommand=scroll.set)
        self.text.yscrollbar = scroll

        def sys_exit():
            if tkMessageBox.askyesno('quit KvarQ', 'really want to exit KvarQ and close all windows?'):
                sys.exit(0)
        self.protocol("WM_DELETE_WINDOW", sys_exit)

        self.log_handler = GuiLogHandler(self.text, self.scrolldown)
        lo.addHandler(self.log_handler)
        lo.debug('GUI started')