Esempio n. 1
0
class LogWidget(QtGui.QWidget):  #, QtCore.QThread):
    '''
    The left panel of the GUI, which holds a logDisplay and a filterWidget
    '''
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.dbWrapper = dbWrapper(self)
        self.dbWrapper.start()

        self.logInterface = LoggerInterface(self)
        self.logInterface.start()

        self.filterWidget = FilterWidget(self)
        self.logDisplay = LogDisplay(self)

        vbox = QtGui.QVBoxLayout()

        vbox.addWidget(self.logDisplay)
        vbox.addWidget(self.filterWidget)

        self.setLayout(vbox)
        self.resize(300, 150)

        def __del__(self):
            self.wait()
            #self.logInterface.stop()

    def clear_log_DB(self):
        '''
        Clears the log database
        '''
        self.dbWrapper.q.exec_("DELETE FROM messages")
Esempio n. 2
0
class LogWidget(QtGui.QWidget):#, QtCore.QThread):
    '''
    The left panel of the GUI, which holds a logDisplay and a filterWidget
    '''    
    
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)  
          
        self.dbWrapper = dbWrapper(self)
        self.dbWrapper.start()
        
        self.logInterface = LoggerInterface(self)
        self.logInterface.start()
        
        
        self.filterWidget = FilterWidget(self)
        self.logDisplay = LogDisplay(self)
        
        vbox = QtGui.QVBoxLayout()
        
        vbox.addWidget(self.logDisplay)
        vbox.addWidget(self.filterWidget)

        self.setLayout(vbox)
        self.resize(300, 150)
        
	def __del__(self):
	    self.wait()
	    #self.logInterface.stop()
	    
    def clear_log_DB(self):
        '''
        Clears the log database
        '''
        self.dbWrapper.q.exec_("DELETE FROM messages")
Esempio n. 3
0
File: log.py Progetto: homework/hwdb
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
                
        #self.parent = parent
        
        # Configure log message DB
        self.conn = connect('log.db')
        self.curs = self.conn.cursor()        
        # Delete previous messages table
        self.curs.execute('''DROP TABLE IF EXISTS messages''')
        # Create messages table
        self.curs.execute('''CREATE TABLE messages
          (timestamp TEXT PRIMARY KEY, component TEXT,
                verbosity TEXT, message TEXT)''')     
                
        self.logDisplay = LogDisplay(self)
        self.filterWidget = FilterWidget(self)
  
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.logDisplay)
        vbox.addWidget(self.filterWidget)

        self.setLayout(vbox)
        self.resize(300, 150)
               
        self.logInterface = LoggerInterface(self)
        self.logInterface.start()
        
        # Connect the trigger signal to a slot.
        self.trigger[str].connect(self.handle_trigger)
        
        # if set, new logs are not appended (used to give 
        # display access to other entities
        self.freezeLog = False
Esempio n. 4
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.dbWrapper = dbWrapper(self)
        self.dbWrapper.start()

        self.logInterface = LoggerInterface(self)
        self.logInterface.start()

        self.filterWidget = FilterWidget(self)
        self.logDisplay = LogDisplay(self)

        vbox = QtGui.QVBoxLayout()

        vbox.addWidget(self.logDisplay)
        vbox.addWidget(self.filterWidget)

        self.setLayout(vbox)
        self.resize(300, 150)

        def __del__(self):
            self.wait()
Esempio n. 5
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)  
          
        self.dbWrapper = dbWrapper(self)
        self.dbWrapper.start()
        
        self.logInterface = LoggerInterface(self)
        self.logInterface.start()
        
        
        self.filterWidget = FilterWidget(self)
        self.logDisplay = LogDisplay(self)
        
        vbox = QtGui.QVBoxLayout()
        
        vbox.addWidget(self.logDisplay)
        vbox.addWidget(self.filterWidget)

        self.setLayout(vbox)
        self.resize(300, 150)
        
	def __del__(self):
	    self.wait()
Esempio n. 6
0
File: log.py Progetto: homework/hwdb
class LogWidget(QtGui.QWidget):
    '''
    The left panel of the GUI, which holds a logDisplay and a filterWidget
    '''    
    trigger = QtCore.pyqtSignal(str)
    
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
                
        #self.parent = parent
        
        # Configure log message DB
        self.conn = connect('log.db')
        self.curs = self.conn.cursor()        
        # Delete previous messages table
        self.curs.execute('''DROP TABLE IF EXISTS messages''')
        # Create messages table
        self.curs.execute('''CREATE TABLE messages
          (timestamp TEXT PRIMARY KEY, component TEXT,
                verbosity TEXT, message TEXT)''')     
                
        self.logDisplay = LogDisplay(self)
        self.filterWidget = FilterWidget(self)
  
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.logDisplay)
        vbox.addWidget(self.filterWidget)

        self.setLayout(vbox)
        self.resize(300, 150)
               
        self.logInterface = LoggerInterface(self)
        self.logInterface.start()
        
        # Connect the trigger signal to a slot.
        self.trigger[str].connect(self.handle_trigger)
        
        # if set, new logs are not appended (used to give 
        # display access to other entities
        self.freezeLog = False
                
    def handle_trigger(self, msg):
        # Insert message to log db
        self.insert_message(msg)
        
	def __del__(self):
	    print "out"
	    self.wait()
	    #self.logInterface.stop()
                
    def insert_message(self, message):
        '''
        Inserts a new log message into the log message database. Called when
        new log message is received from nox's vlogger
        '''
        ts, verb, comp, msg = self.parse_logmsg(message)
        insert = "INSERT INTO messages VALUES (\'"+ts+"\', \'"+comp+"\', \'"+verb+"\', \'"+msg+"\')"
        self.curs.execute(insert)
        
        # Update DB
        #self.conn.commit()
        
        # Also if new message matches current filter, append to log display
        if not self.freezeLog:
            if (comp in self.filterWidget.compFilt       \
                    or not self.filterWidget.compFilt ) \
                and (verb in self.filterWidget.verbFilt   \
                    or not self.filterWidget.verbFilt ):
                self.logDisplay.append_message(ts+" | "+comp+" | "+verb+" | "+msg)      

    def parse_logmsg(self, m):
        '''
        Parses a log message string. Expected in standard format
        (timestamp|component|verbosity:message)
        '''
        msg = str(m)
        # msg = msg.replace("\"", "\\\"").replace("\'", "\\\'")
        # Strip 's and "s.
        msg = msg.replace("\"", "").replace("\'", "")
        split = msg.rsplit("|")
        timestamp = split[0]
        component = split[1]
        ver_mes = split[2]
        delim = ver_mes.index(':')
        verbosity = ver_mes[0:delim]
        message = ver_mes[delim+1:len(ver_mes)]
        
        return timestamp, verbosity, component, message

    def show_filtered(self, logfilter):
        ''' 
        Displayes log message output filtered by given filter
        '''
        # unfreeze logDisplay, if freezed
        self.freezeLog = False
        
        # Form SELECT
        select = "select * from messages WHERE 1=1 "  #stupid.change.
        if logfilter.timestamps:
            select = select + "AND ("
            select = select + "timestamp > \'"+logfilter.timestamps[0]+"\' AND "
            select = select + "timestamp < \'"+logfilter.timestamps[1]+"\'"
            select = select + ") "
            self.freezeLog = True
        if logfilter.components:
            select = select + "AND ("
            for comp in logfilter.components:
                select = select + "component=\'"+comp+"\' OR "
            select = select[0:len(select)-3]
            select = select + ")"
        if logfilter.verbosities:
            select = select + "AND ("
            for verb in logfilter.verbosities:
                select = select + "verbosity=\'"+verb+"\' OR "
            select = select[0:len(select)-3]
            select = select + ")"
        
        # Execute DB select
        self.curs.execute(select)
        
        # Display selection
        self.logDisplay.clear()
        for row in self.curs:
            self.logDisplay.append_message(row[0]+" | "+row[1]+" | "+row[2]+" | "+row[3])