#coding:utf-8

from PyQt4.QtCore import QThread,SIGNAL
import time
import commands


class ReadLogFileThread(QThread):
    def __init__(self,parent = None):
        super(ReadLogFileThread,self).__init__(parent)
        self.auto = True
        
    def run(self):
        while self.auto:
            output = ""
            statusOutput = commands.getstatusoutput("cat /usr/massclouds/vdi/client/log/record.log")
            if statusOutput[0] == 0:
                output = statusOutput[1]                
                self.emit(SIGNAL("getoutput"), output)
                time.sleep(1.5)
            else:
                self.emit(SIGNAL("getoutput"), "output")
                time.sleep(1.5)
                
    def stop(self):
        self.auto = False
        
#     def startUp(self):
#         self.auto = True
        