Пример #1
0
 def __init__(self,parent):
     QWidget.__init__(self,parent)
     self.parent = parent
     self.cmd = ""
     self.cmdThread = WorkThread()
     self.connect(self.cmdThread, SIGNAL("update"),self.update)
     self.connect(self.cmdThread, SIGNAL("fini"),self.finished)
Пример #2
0
 def __init__(self,parent):
     QWidget.__init__(self,parent)
     self.parent = parent 
     self.setAntList()
     self.ant_thread = WorkThread()
     self.timer = QTimer()
     #self.ant_thread = antThread()
     self.connect(self.ant_thread, SIGNAL("update"),self.update)
     self.connect(self.ant_thread, SIGNAL("fini"),self.newstart)
     self.connect(self.timer , SIGNAL('timeout()') , self.onTimeout)
Пример #3
0
 def __init__(self,parent):
     QWidget.__init__(self,parent)
     self.parent = parent
     self.adb_thread = WorkThread()
     self.adblist = config.adb()
     self.device = ""
     self.setDevice()
     #self.adb_thread = AdbThread()
     self.connect(self.adb_thread, SIGNAL("update"),self.update)
     self.connect(self.adb_thread, SIGNAL("fini"),self.newstart)
Пример #4
0
 def __init__(self,parent):
     QWidget.__init__(self,parent)
     self.parent = parent
     self.adb_process = None
     self.isRunning = False
     self.adb_thread = WorkThread()
     self.timer = QTimer()
     #self.adb_thread = AdbThread()
     self.connect(self.adb_thread, SIGNAL("update"),self.update)
     #self.connect(self.adb_thread, SIGNAL("fini"),self.newstart)
     self.connect(self.adb_thread, SIGNAL("fini"),self.newstart)
Пример #5
0
class Command(QWidget):
    def __init__(self,parent):
        QWidget.__init__(self,parent)
        self.parent = parent
        self.cmd = ""
        self.running = False
        self.cmdThread = WorkThread()
        self.connect(self.cmdThread, SIGNAL("update"),self.update)
        self.connect(self.cmdThread, SIGNAL("fini"),self.finished)
        
    def setCmd(self):
        text, ok = QInputDialog.getText(self, 'Run Command', 'Command:')
        self.cmd = str(text)
        if ok and self.cmd != "":
            self.parent.textEdit.clear()
            self.run()
            
    def setCmdLine(self):
        com = self.parent.combo.itemText(self.parent.combo.currentIndex())
        self.cmd = str(com+" "+self.parent.combo2.itemText(self.parent.combo2.currentIndex()))
        self.parent.textEdit.clear()
        self.run()
        
    def setCmdText(self,text):
        self.cmd = text
        if self.cmd != "":
            self.parent.textEdit.clear()
            self.run()
        
    def finished(self,no,cmd):
        self.parent.progressStop()
        self.parent.statusWriting()
        if(no == 0):
            self.parent.textEdit.append("Finished: "+cmd)
        else:
            self.parent.textEdit.append("Error: "+cmd)
        
    def update(self,line):
        self.parent.textEdit.append(line)
        self.parent.popOutput()


    def run(self):
        self.cmdThread.setCmd(self.cmd)
        self.parent.progressStart()
        self.parent.statusCommand()
        self.cmdThread.run()
        
    def close(self):
        self.cmdThread.quit()
Пример #6
0
class Command(QWidget):
    def __init__(self,parent):
        QWidget.__init__(self,parent)
        self.parent = parent
        self.cmd = ""
        self.cmdThread = WorkThread()
        self.connect(self.cmdThread, SIGNAL("update"),self.update)
        self.connect(self.cmdThread, SIGNAL("fini"),self.finished)
        
    def setCmd(self):
        text, ok = QInputDialog.getText(self, 'Run Command', 'Command:')
        self.cmd = str(text)
        if ok and self.cmd != "":
            self.parent.textEdit.clear()
            self.run()
            
    def setCmdLine(self):
        self.cmd = str(self.parent.lineeEdit.text())
        if self.cmd != "":
            self.parent.textEdit.clear()
            self.run()
        
    def finished(self,no,cmd):
        if(no == 0):
            self.parent.textEdit.append("Finshed")
            self.parent.textEdit.append(cmd)
        else:
            self.parent.textEdit.append("Error Canceled")
            self.parent.textEdit.append(cmd) 
        
    def update(self,line):
        self.parent.textEdit.append(line)
        if(self.parent.tabWidget_3.isHidden()):
            self.parent.tabWidget_3.show()
        self.parent.tabWidget_3.setCurrentIndex(1)


    def run(self):
        self.cmdThread.setCmd(self.cmd)
        self.cmdThread.run()
        
    def close(self):
        self.cmdThread.quit()
Пример #7
0
 def __init__(self,parent):
     QWidget.__init__(self,parent)
     self.parent = parent
     self.par_thread = WorkThread()
     self.connect(self.par_thread, SIGNAL("update"),self.error)
     self.connect(self.par_thread, SIGNAL("fini"),self.stop)
Пример #8
0
class Parser(QWidget):
    def __init__(self,parent):
        QWidget.__init__(self,parent)
        self.parent = parent
        self.par_thread = WorkThread()
        self.connect(self.par_thread, SIGNAL("update"),self.error)
        self.connect(self.par_thread, SIGNAL("fini"),self.stop)
        
    def error(self,text):
        '''Solved problem by adding Success to sqc file'''
        self.parent.errorTree.reset() 
        if(text != "" and text != "Success"):
            self.parent.popError()
            errorlist = text.split(',')
            fileName = self.parent.files[self.parent.tabWidget.currentIndex()]
            self.parent.errorTree.addError(fileName,errorlist)
            self.parent.tabWidget.currentWidget().reset()
            self.parent.tabWidget.currentWidget().addError(int(errorlist[0]))
        else:
            self.parent.tabWidget.currentWidget().reset()
            self.parent.errorTree.reset()
                
                
    def run(self,nfile):
        if(nfile.endswith(".nut")):
            self.par_thread.setCmd(sqc+" "+nfile)
            self.parent.statusParsing()
            self.parent.progressStart()
            self.par_thread.run()
            
    def stop(self):
        self.par_thread.close_process()
        self.parent.statusWriting()
        self.parent.progressStop()
        
    def close(self):
        self.par_thread.kill_process()
        self.par_thread.close_process()
        self.par_thread.quit()
Пример #9
0
class Ui_MainWindow(object):
    ## global varibales
    vowelButton_Times = 0
    timer = QTimer()
    workThread = WorkThread()
    c = []
    generatedWord = []
    number_answers = 0

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(624, 680)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(134, 20, 361, 51))
        self.label.setMinimumSize(QtCore.QSize(361, 0))
        font = QtGui.QFont()
        font.setFamily("Monotype Corsiva")
        font.setPointSize(20)
        font.setBold(False)
        font.setItalic(True)
        font.setWeight(9)
        self.label.setFont(font)
        self.label.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
        self.label.setAutoFillBackground(False)
        self.label.setStyleSheet("font: 75 italic 20pt \"Monotype Corsiva\";")
        self.label.setScaledContents(False)
        self.label.setObjectName("label")
        self.groupBox = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox.setGeometry(QtCore.QRect(30, 90, 551, 141))
        self.groupBox.setObjectName("groupBox")
        self.horizontalLayoutWidget = QtWidgets.QWidget(self.groupBox)
        self.horizontalLayoutWidget.setGeometry(QtCore.QRect(0, 60, 551, 89))
        self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
        self.horizontalLayout = QtWidgets.QHBoxLayout(
            self.horizontalLayoutWidget)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.textBrowser_4 = QtWidgets.QTextBrowser(
            self.horizontalLayoutWidget)
        self.textBrowser_4.setObjectName("textBrowser_4")
        self.horizontalLayout.addWidget(self.textBrowser_4)
        self.textBrowser_8 = QtWidgets.QTextBrowser(
            self.horizontalLayoutWidget)
        self.textBrowser_8.setObjectName("textBrowser_8")
        self.horizontalLayout.addWidget(self.textBrowser_8)
        self.textBrowser_9 = QtWidgets.QTextBrowser(
            self.horizontalLayoutWidget)
        self.textBrowser_9.setObjectName("textBrowser_9")
        self.horizontalLayout.addWidget(self.textBrowser_9)
        self.textBrowser_6 = QtWidgets.QTextBrowser(
            self.horizontalLayoutWidget)
        self.textBrowser_6.setObjectName("textBrowser_6")
        self.horizontalLayout.addWidget(self.textBrowser_6)
        self.textBrowser_7 = QtWidgets.QTextBrowser(
            self.horizontalLayoutWidget)
        self.textBrowser_7.setObjectName("textBrowser_7")
        self.horizontalLayout.addWidget(self.textBrowser_7)
        self.textBrowser_5 = QtWidgets.QTextBrowser(
            self.horizontalLayoutWidget)
        self.textBrowser_5.setObjectName("textBrowser_5")
        self.horizontalLayout.addWidget(self.textBrowser_5)
        self.textBrowser_3 = QtWidgets.QTextBrowser(
            self.horizontalLayoutWidget)
        self.textBrowser_3.setObjectName("textBrowser_3")
        self.horizontalLayout.addWidget(self.textBrowser_3)
        self.textBrowser_2 = QtWidgets.QTextBrowser(
            self.horizontalLayoutWidget)
        self.textBrowser_2.setObjectName("textBrowser_2")
        self.horizontalLayout.addWidget(self.textBrowser_2)
        self.textBrowser = QtWidgets.QTextBrowser(self.horizontalLayoutWidget)
        self.textBrowser.setObjectName("textBrowser")
        self.horizontalLayout.addWidget(self.textBrowser)
        self.label_2 = QtWidgets.QLabel(self.horizontalLayoutWidget)
        self.label_2.setText("")
        self.label_2.setObjectName("label_2")
        self.horizontalLayout.addWidget(self.label_2)
        self.label_11 = QtWidgets.QLabel(self.groupBox)
        self.label_11.setGeometry(QtCore.QRect(10, 9, 491, 51))
        font = QtGui.QFont()
        font.setFamily("MS Shell Dlg 2")
        font.setPointSize(10)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_11.setFont(font)
        self.label_11.setStyleSheet("")
        self.label_11.setObjectName("label_11")
        self.frame = QtWidgets.QFrame(self.centralwidget)
        self.frame.setGeometry(QtCore.QRect(20, 80, 581, 541))
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")

        ## click button to input vowels
        self.pushButton = QtWidgets.QPushButton(self.frame)
        self.pushButton.setGeometry(QtCore.QRect(10, 170, 161, 28))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setObjectName("pushButton")
        self.pushButton.clicked.connect(self.input)

        ##
        ## click button to input consonants
        self.pushButton_2 = QtWidgets.QPushButton(self.frame)
        self.pushButton_2.setGeometry(QtCore.QRect(200, 170, 161, 28))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_2.setFont(font)
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_2.clicked.connect(self.input1)

        ##Countdown function
        ## click start
        self.lcdNumber = QtWidgets.QLCDNumber(self.frame)
        self.lcdNumber.setGeometry(QtCore.QRect(400, 160, 101, 51))
        self.lcdNumber.setSmallDecimalPoint(True)
        self.lcdNumber.setDigitCount(5)
        self.lcdNumber.setMode(QtWidgets.QLCDNumber.Dec)
        self.lcdNumber.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.lcdNumber.setObjectName("lcdNumber")
        self.timer.timeout.connect(self.countTime)

        ## groupBox _2
        self.groupBox_2 = QtWidgets.QGroupBox(self.frame)
        self.groupBox_2.setGeometry(QtCore.QRect(10, 210, 561, 321))
        self.groupBox_2.setObjectName("groupBox_2")
        self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self.groupBox_2)
        self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(
            0, 60, 551, 171))
        self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(
            self.horizontalLayoutWidget_2)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.label_12 = QtWidgets.QLabel(self.groupBox_2)
        self.label_12.setGeometry(QtCore.QRect(4, 10, 541, 41))
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_12.setFont(font)
        self.label_12.setObjectName("label_12")

        ##Submit button in the bottle of frame

        self.pushButton_3 = QtWidgets.QPushButton(self.groupBox_2)
        self.pushButton_3.setGeometry(QtCore.QRect(170, 260, 171, 51))
        font = QtGui.QFont()
        font.setPointSize(16)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_3.setFont(font)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_3.clicked.connect(self.Answer_Game)

        ## show answers
        self.textBrowser_10 = QtWidgets.QTextBrowser(self.groupBox_2)
        self.textBrowser_10.setGeometry(QtCore.QRect(0, 60, 561, 171))
        self.textBrowser_10.setObjectName("textBrowser_10")

        self.textEdit = QtWidgets.QTextEdit(self.groupBox_2)
        self.textEdit.setGeometry(QtCore.QRect(493, 20, 61, 31))
        self.textEdit.setObjectName("textEdit")
        self.label_4 = QtWidgets.QLabel(self.groupBox_2)
        self.label_4.setGeometry(QtCore.QRect(380, 20, 111, 31))
        self.label_4.setObjectName("label_4")
        self.textEdit_2 = QtWidgets.QTextEdit(self.groupBox_2)
        self.textEdit_2.setGeometry(QtCore.QRect(240, 20, 111, 31))
        self.textEdit_2.setObjectName("textEdit_2")
        self.label_3 = QtWidgets.QLabel(self.groupBox_2)
        self.label_3.setGeometry(QtCore.QRect(140, 25, 91, 21))
        self.label_3.setObjectName("label_3")

        ## pushbutton_4 is a button to control countdown function
        self.pushButton_4 = QtWidgets.QPushButton(self.frame)
        self.pushButton_4.setGeometry(QtCore.QRect(520, 160, 51, 51))
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_4.clicked.connect(self.work)

        ## reset
        self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_5.setGeometry(QtCore.QRect(490, 20, 93, 51))
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_5.clicked.connect(self.reset)
        self.frame.raise_()
        self.label.raise_()
        self.groupBox.raise_()
        self.pushButton_5.raise_()
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 624, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label.setText(_translate("MainWindow", "Countdown Word Game"))
        self.groupBox.setTitle(_translate("MainWindow", "GroupBox"))
        self.label_11.setText(
            _translate("MainWindow", "Please press Button to input letter :"))
        self.pushButton.setText(_translate("MainWindow", "Vowels"))
        self.pushButton_2.setText(_translate("MainWindow", "Consonants"))
        self.groupBox_2.setTitle(
            _translate(
                "MainWindow",
                "-------------------------------------------------------------------------------------------------------------"
            ))
        self.label_12.setText(_translate("MainWindow", "Answers"))
        self.pushButton_3.setText(_translate("MainWindow", "Submit"))
        self.label_3.setText(_translate("MainWindow", "input answer : "))
        self.label_4.setText(_translate("MainWindow", "length of answer :"))
        self.pushButton_4.setText(_translate("MainWindow", "Start"))
        self.pushButton_5.setText(_translate("MainWindow", "Reset"))

##Function to Generate Vowels

    def input(self):
        if self.vowelButton_Times == 0:

            number = inputLetter.vowel()
            self.generatedWord.append(number)
            self.textBrowser_4.setText(number)
    #     print(self.generatedWord)
        elif self.vowelButton_Times == 1:
            number = inputLetter.vowel()
            self.generatedWord.append(number)
            self.textBrowser_8.setText(number)
        #    print(self.generatedWord)
        elif self.vowelButton_Times == 2:
            number = inputLetter.vowel()
            self.generatedWord.append(number)
            self.textBrowser_9.setText(number)
        elif self.vowelButton_Times == 3:
            number = inputLetter.vowel()
            self.generatedWord.append(number)
            self.textBrowser_6.setText(number)
        elif self.vowelButton_Times == 4:
            number = inputLetter.vowel()
            self.generatedWord.append(number)
            self.textBrowser_7.setText(number)
        elif self.vowelButton_Times == 5:
            number = inputLetter.vowel()
            self.generatedWord.append(number)
            self.textBrowser_5.setText(number)
        elif self.vowelButton_Times == 6:
            number = inputLetter.vowel()
            self.generatedWord.append(number)
            self.textBrowser_3.setText(number)
        elif self.vowelButton_Times == 7:
            number = inputLetter.vowel()
            self.generatedWord.append(number)
            self.textBrowser_2.setText(number)
        elif self.vowelButton_Times == 8:
            number = inputLetter.vowel()
            self.generatedWord.append(number)
            self.textBrowser.setText(number)
            self.work()
        else:
            self.pushButton.clicked.connect(self.msg)
        self.vowelButton_Times = self.vowelButton_Times + 1

    #  print(self.vowelButton_Times)

## Function to Generate  Consonants

    def input1(self):
        # print(self.vowelButton_Times)
        # print("-----------")
        if self.vowelButton_Times == 0:
            #  self.work()
            number = inputLetter.con()
            print(number)
            self.generatedWord.append(number)
            self.textBrowser_4.setText(number)
        elif self.vowelButton_Times == 1:
            number = inputLetter.con()
            self.generatedWord.append(number)
            self.textBrowser_8.setText(number)
        elif self.vowelButton_Times == 2:
            number = inputLetter.con()
            self.generatedWord.append(number)
            self.textBrowser_9.setText(number)
        elif self.vowelButton_Times == 3:
            number = inputLetter.con()
            self.generatedWord.append(number)
            self.textBrowser_6.setText(number)
        elif self.vowelButton_Times == 4:
            number = inputLetter.con()
            self.generatedWord.append(number)
            self.textBrowser_7.setText(number)
        elif self.vowelButton_Times == 5:
            number = inputLetter.con()
            self.generatedWord.append(number)
            self.textBrowser_5.setText(number)
        elif self.vowelButton_Times == 6:
            number = inputLetter.con()
            self.generatedWord.append(number)
            self.textBrowser_3.setText(number)
        elif self.vowelButton_Times == 7:
            number = inputLetter.con()
            self.generatedWord.append(number)
            self.textBrowser_2.setText(number)
        elif self.vowelButton_Times == 8:
            number = inputLetter.con()
            self.generatedWord.append(number)
            self.textBrowser.setText(number)
            self.work()
        else:
            self.pushButton_2.clicked.connect(self.msg)
        self.vowelButton_Times = self.vowelButton_Times + 1

    #  print(self.vowelButton_Times)

    def msg(self):
        reply = QMessageBox.information(QtWidgets.QWidget(), "Warning",
                                        "out of range",
                                        QMessageBox.Yes | QMessageBox.No)

##Generate Answer in a other window

    def getGeneratedWord(self):
        self.generatedWord = self.generatedWord
        print(self.generatedWord)

    def Answer_Game(self):
        print(self.generatedWord)
        print("!!!!!!!")
        findWordFromDic.set_input_word(self.generatedWord)
        print(self.generatedWord)
        print('------')

        ## get content(wordlength  and input word ) from textEdit and textEdit_2
        wordlen = self.textEdit.toPlainText()
        input = self.textEdit_2.toPlainText()

        ##get infor[] from findWordFromDic
        c = findWordFromDic.infor
        number_answers = 0

        ##set cc
        cc = []

        if wordlen == '':
            wordlen = 5
        if input == '':
            self.input = ''

        for i in c:
            if len(i) >= int(wordlen):
                cc.append(i)
                self.textBrowser_10.append(i)
                number_answers = number_answers + 1
        if number_answers == 0:
            self.textBrowser_10.append('No answer')

        if str(input) in cc:
            reply = QMessageBox.information(
                QtWidgets.QWidget(), "Congraulation",
                "Time : spend " + str(sec) + "seconds to get answer",
                QMessageBox.Yes | QMessageBox.No)
        else:
            reply = QMessageBox.information(
                QtWidgets.QWidget(), "Sorry",
                "Time : spend " + str(sec) + "seconds ",
                QMessageBox.Yes | QMessageBox.No)

## Function of Countdown

    def countTime(self):
        global sec
        sec += 1
        self.lcdNumber.display(sec)  #LED显示数字+1

    def work(self):
        self.timer.start(1000)  #计时器每秒计数
        self.workThread.start()  #计时开始
        self.workThread.trigger.connect(self.timeStop)  #当获得循环完毕的信号时,停止计数

    def timeStop(self):
        self.timer.stop()
        print("END", self.lcdNumber.value())
        global sec
        sec = 0

    def reset(self):
        # self.textBrowser.de(1.0, END)
        #  self.textBrowser.clear()
        #  self.textBrowser.setText('')
        global generatedWord
        self.generatedWord = None
        self.generatedWord = []
        global sec
        sec = 0
        self.vowelButton_Times = 0
        global c
        self.c = []
        self.timeStop()
        self.number_answers = 0
        self.textBrowser.clear()
        self.textBrowser_2.clear()
        self.textBrowser_3.clear()
        self.textBrowser_4.clear()
        self.textBrowser_5.clear()
        self.textBrowser_6.clear()
        self.textBrowser_7.clear()
        self.textBrowser_8.clear()
        self.textBrowser_9.clear()
        self.textBrowser_10.clear()
Пример #10
0
class Adb(QWidget):
    def __init__(self,parent):
        QWidget.__init__(self,parent)
        self.parent = parent
        self.adb_process = None
        self.isRunning = False
        self.adb_thread = WorkThread()
        self.timer = QTimer()
        #self.adb_thread = AdbThread()
        self.connect(self.adb_thread, SIGNAL("update"),self.update)
        #self.connect(self.adb_thread, SIGNAL("fini"),self.newstart)
        self.connect(self.adb_thread, SIGNAL("fini"),self.newstart)
        #self.connect(self.timer , SIGNAL('timeout()') , self.onTimeout)
        #self.connect(self.adb_thread , SIGNAL('started()') , self.onThreadStarted)
        #self.connect(self.adb_thread , SIGNAL('finished()'), self.onThreadFinished) 
        
    def onTimeout(self):
        print "timeout"
        """
        # Update the progress bar
        value = self.pbar.value()
        # Going forward or backwards?
        if self.pbar.invertedAppearance():
            if value-2 < self.pbar.minimum():
                self.pbar.setValue(self.pbar.minimum())
                self.pbar.setInvertedAppearance(False)
            else:
                self.pbar.setValue(value-2)
        else:
            if value+2 > self.pbar.maximum():
                self.pbar.setValue(self.pbar.maximum())
                self.pbar.setInvertedAppearance(True)
            else:
                self.pbar.setValue(value+2)
        """
        
    def onThreadStarted(self):
        print "Thread has been started"
        self.timer.start(10)
        #self.enableButtons(False)
 
    def onThreadFinished(self):
        print "Thread has finished"
        self.timer.stop()
        #self.enableButtons(True)
        #self.pbar.setValue(0)
        
    def update(self,line):
        self.parent.textEdit.append(line)
        
    def newstart(self,no,cmd):
        if(cmd == "adb -d push "+adblist[0]):
            if(no == 0):
                self.parent.textEdit.append("Finshed")
                self.parent.textEdit.append(cmd)
            else:
                self.parent.textEdit.append("Error Canceled")
                self.parent.textEdit.append(cmd) 
            self.adb_thread.setCmd("adb -d shell am start -a android.intent.action.MAIN -n "+adblist[1])
            self.adb_thread.run()
        elif(cmd == "adb -d shell am start -a android.intent.action.MAIN -n "+adblist[1]):
            self.parent.textEdit.append(str(no))
            self.parent.textEdit.append(cmd)
            self.parent.textEdit.append("Finshed")
            self.adb_thread.setCmd("adb -d logcat -s "+adblist[2])
            self.adb_thread.run2()
        #self.adb_thread.kill_process()
        #self.parent.textEdit.append("Starting Activity...\n")
        #self.adb_thread.setCmd(adblist[1])
        #self.adb_thread.run()
        
    def run(self):
        if self.isRunning == False:
            self.isRunning = True
            self.parent.action_Run.setDisabled(True)
            self.parent.action_Stop.setEnabled(True)        
            if(self.parent.tabWidget_3.isHidden()):
                self.parent.tabWidget_3.show()
                self.parent.tabWidget_3.setCurrentIndex(1)
            self.parent.textEdit.clear()
        self.parent.textEdit.append("Pushing main.nut...\n")
        self.adb_thread.setCmd("adb -d push "+adblist[0])
        self.adb_thread.run()
        
        """
        self.adb_thread.setCmd(adblist[0])
        self.adb_thread.run()
        self.adb_thread.join()
        self.adb_thread.adb_process.kill()
        self.parent.textEdit.append("Starting Activity\n")
        self.adb_thread.setCmd(adblist[1])
        self.adb_thread.run()
        self.adb_thread.join()
        self.adb_thread.adb_process.kill()
        self.parent.textEdit.append("Logging")
        self.adb_thread.setCmd(adblist[2])
        self.adb_thread.run()
        self.adb_thread.join()
        #self.adb_thread.adb_process.kill()
        """
        

    def stop(self):
        if self.isRunning == True:
            self.isRunning = False
            self.adb_thread.setCmd(adblist[3])
            self.adb_thread.run()
            self.adb_thread.kill_process()
            self.parent.action_Stop.setDisabled(True)
            self.parent.textEdit.append("Stopped.")
            if not(self.parent.tabWidget_3.isHidden()):
                self.parent.tabWidget_3.hide()
            self.parent.action_Run.setEnabled(True)
              
    def close(self):
        if self.adb_process != None and self.adb_process.poll() == None:
            #self.adb_thread.kill_process()
            self.adb_thread.quit()
Пример #11
0
class Ant(QWidget):
    isRunning = False
    def __init__(self,parent):
        QWidget.__init__(self,parent)
        self.parent = parent 
        self.setAntList()
        self.ant_thread = WorkThread()
        self.timer = QTimer()
        #self.ant_thread = antThread()
        self.connect(self.ant_thread, SIGNAL("update"),self.update)
        self.connect(self.ant_thread, SIGNAL("fini"),self.newstart)
        self.connect(self.timer , SIGNAL('timeout()') , self.onTimeout)
        #self.connect(self.ant_thread , SIGNAL('started()') , self.onThreadStarted)
        #self.connect(self.ant_thread , SIGNAL('finished()'), self.onThreadFinished) 
        
    def onTimeout(self):
        print "timeout"
        
    def update(self,line):
        self.parent.textEdit.append(line)
        
    def setAntList(self):
        self.antlist = config.ant()
        self.cmd1 = self.antlist[0]
        self.cmd2 = self.antlist[1]
        self.cmd3 = self.antlist[2]
        self.cmd4 = self.antlist[3]
        self.cmd5 = self.antlist[4]
        
    def checkFinished(self,no,cmd):
        if(no == 0):
            #QMessageBox.about(self,"Error","Finished: "+cmd)
            self.parent.textEdit.append("Finished: "+cmd)
        else:
            self.parent.textEdit.append("Error: "+cmd)
        
    def newstart(self,no,cmd):
        self.checkFinished(no, cmd)
        self.parent.progressStop()
        self.parent.statusWriting()
           
    def showOutput(self):
        self.parent.popOutput()
        
    def create(self,prj):
        if self.isRunning == False:
            self.isRunning = True
        self.showOutput()
        self.parent.textEdit.clear()
        self.parent.textEdit.append("Creating... "+prj.getPath())
        self.ant_thread.setCmd(self.cmd1+" "+prj.getPath())
        self.parent.progressStart()
        self.parent.statusCreating()
        self.ant_thread.run()
        
    def build(self,prj):
        if self.isRunning == False:
            self.isRunning = True
        self.showOutput()
        self.parent.textEdit.clear()
        self.parent.textEdit.append("Ant Building Debug... "+ospathjoin(prj.getPath(),"build.xml"))
        self.ant_thread.setCmd(self.cmd2+" "+ospathjoin(prj.getPath(),"build.xml"))
        self.parent.progressStart()
        self.parent.statusBuilding()
        self.ant_thread.run()
        
    def clean(self,prj):
        if self.isRunning == False:
            self.isRunning = True
        self.showOutput()
        self.parent.textEdit.clear()
        self.parent.textEdit.append("Ant Cleaning... "+prj.getPath())
        self.ant_thread.setCmd(self.cmd5+" "+ospathjoin(prj.getPath(),"build.xml"))
        self.parent.progressStart()
        self.parent.statusCleaning()
        self.ant_thread.run()
        
    def buildRun(self,prj):
        if self.isRunning == False:
            self.isRunning = True
        self.showOutput()
        self.parent.textEdit.clear()
        self.parent.textEdit.append("Ant Building and Installing... "+ospathjoin(prj.getPath(),"build.xml"))
        self.ant_thread.setCmd(self.cmd4+" "+ospathjoin(prj.getPath(),"build.xml"))
        self.parent.progressStart()
        self.ant_thread.run()
        
    def run(self,prj):
        if self.isRunning == False:
            self.isRunning = True
        self.showOutput()
        self.parent.textEdit.clear()
        self.parent.textEdit.append("Installing... "+prj.getPath())
        self.ant_thread.setCmd(self.cmd3+" "+ospathjoin(prj.getPath(),"build.xml"))
        self.parent.progressStart()
        self.parent.statusInstalling()
        self.ant_thread.run()
        
    def kill(self):
        self.ant_thread.kill_process()
        self.ant_thread.close_process()
        
    def close(self):
        self.ant_thread.kill_process()
        self.ant_thread.close_process()
        self.ant_thread.quit()
Пример #12
0
class Adb(QWidget):
    isRunning = False
    def __init__(self,parent):
        QWidget.__init__(self,parent)
        self.parent = parent
        self.adb_thread = WorkThread()
        self.adblist = config.adb()
        self.device = ""
        self.setDevice()
        #self.adb_thread = AdbThread()
        self.connect(self.adb_thread, SIGNAL("update"),self.update)
        self.connect(self.adb_thread, SIGNAL("fini"),self.newstart)
        #self.connect(self.timer , SIGNAL('timeout()') , self.onTimeout)
        
    def setDevice(self):
        if(config.device() == 1):
            self.device = " -d "
        else:
            self.device = " -e "
        self.cmd1 = "adb"+self.device+"push "+self.adblist[0]
        self.cmd2 = "adb"+self.device+"shell am start -a android.intent.action.MAIN -n "+self.adblist[1]
        self.cmd3 = "adb"+self.device+"logcat -s "+self.adblist[2]
        self.cmd4 = "adb"+self.device+"shell pm disable com.emo_framework.examples"
        self.cmd5 = "adb"+self.device+"shell pm enable com.emo_framework.examples"
    
    def setAdbList(self):
        self.adblist = config.adb()
        self.cmd1 = "adb"+self.device+"push "+self.adblist[0]
        self.cmd2 = "adb"+self.device+"shell am start -a android.intent.action.MAIN -n "+self.adblist[1]
        self.cmd3 = "adb"+self.device+"logcat -s "+self.adblist[2]
        self.cmd4 = "adb"+self.device+"shell pm disable com.emo_framework.examples"
        self.cmd5 = "adb"+self.device+"shell pm enable com.emo_framework.examples"
        
    def update(self,line):
        self.parent.textEdit.append(line)
        self.parent.popOutput()
        
    def checkFinished(self,no,cmd):
        self.parent.progressStop()
        if(no == 0):
            self.parent.textEdit.append("Finished: "+cmd)
        else:
            self.parent.textEdit.append("Error: "+cmd)
        
    def newstart(self,no,cmd):
        self.checkFinished(no, cmd)
        self.parent.progressStart()
        if(cmd == self.cmd1): 
            self.adb_thread.setCmd(self.cmd2) #start
            self.adb_thread.run()
        elif(cmd == self.cmd2): 
            self.adb_thread.setCmd(self.cmd3) #log
            self.parent.progressStop()
            self.adb_thread.run2()
        elif(cmd == self.cmd3): 
            self.adb_thread.setCmd(self.cmd4) #enable app
            self.adb_thread.run()
        elif(cmd == self.cmd4):  
            self.adb_thread.setCmd(self.cmd5)  #disable app
            self.adb_thread.run()
        elif(cmd == self.cmd5): 
            if not(self.parent.outputTabWidget.isHidden()):
                self.parent.outputTabWidget.hide()
            self.parent.toolBar.action_Run.setEnabled(True)
            self.parent.statusWriting()
            #self.stop()
        
    def run(self):
        if self.isRunning == False:
            self.isRunning = True
            self.parent.toolBar.action_Run.setDisabled(True)
            self.parent.toolBar.action_Stop.setEnabled(True)        
            self.parent.popOutput()
            self.parent.textEdit.clear()
            self.parent.textEdit.append("Pushing main.nut...\n")
            self.adb_thread.setCmd(self.cmd1)
            self.parent.statusRunning()
            self.parent.progressStart()
            self.adb_thread.run()      

    def stop(self):
        if self.isRunning == True:
            self.isRunning = False
            self.parent.toolBar.action_Stop.setDisabled(True)
            self.parent.textEdit.append("Stopped.")
            self.parent.statusStopping()
            self.adb_thread.close_process()
            #"adb -d shell ps | grep "+adblist[3]+" | awk '{print $2}' | xargs adbshell kill")
            #adb -d shell ps | grep com.emo_framework.examples | awk '{print $2}' | xargs adb shell kill
            #adb -d shell kill adb shell ps | grep com.emo_framework.examples | awk '{print $2}'

              
    def close(self):
        self.adb_thread.kill_process()
        self.adb_thread.close_process()
        self.adb_thread.quit()