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()
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()
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()
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()