def run(self): while 1: #刷新数据 ret = webS.getAllExe() print 'running' print ret self.__table.setRowCount(len(ret)) row = 0 for line in ret: self.__table.setItem(row, 0, QtGui.QTableWidgetItem(unicode(line['id']))) self.__table.setItem(row, 1, QtGui.QTableWidgetItem(unicode(line['name']))) self.__table.setItem(row, 2, QtGui.QTableWidgetItem(unicode(line['cmd']))) self.__table.setItem(row, 3, QtGui.QTableWidgetItem(unicode(line['time']))) self.__table.setItem(row, 4, QtGui.QTableWidgetItem(unicode(line['enabled']))) row += 1 for row in range(self.__table.rowCount()): name = getTextFromCell(self.__table, row, 1) cmd = getTextFromCell(self.__table, row, 2) t = getTextFromCell(self.__table, row, 3) enabled = getTextFromCell(self.__table, row, 4) if cmd != '' and enabled == 'y' and not name in self.startedNames: if t == '': self.starter.start(name, cmd) else: self.starter.start(name, cmd, t) self.startedNames.append(name) if enabled == 'n' and name in self.startedNames: ps = self.starter.getPS() print name for p in ps: if p['name'] == name: ctypes.windll.kernel32.TerminateProcess(int(p['process']._handle), -1) self.startedNames.remove(name) time.sleep(8)
def refreshData(self): #self.db.execute("create table if not exists exes(id integer primary key autoincrement, name text, cmd text, time text, enabled text)") #ret = self.db.select("select * from exes") ret = webS.getAllExe() self.table.setRowCount(len(ret)) row = 0 for line in ret: self.table.setItem(row, 0, QtGui.QTableWidgetItem(unicode(line['id']))) self.table.setItem(row, 1, QtGui.QTableWidgetItem(unicode(line['name']))) self.table.setItem(row, 2, QtGui.QTableWidgetItem(unicode(line['cmd']))) self.table.setItem(row, 3, QtGui.QTableWidgetItem(unicode(line['time']))) self.table.setItem(row, 4, QtGui.QTableWidgetItem(unicode(line['enabled']))) row += 1