def createTasks(self, job): task = Hydra_rendertask( status = READY, command = repr( self.command ), job_id = job.id, priority = self.priority, project = self.project, createTime = job.createTime) with transaction() as t: task.insert(transaction=t)
def jobCellClickedHandler(self, row, column): # populate the task table widget item = self.jobTable.item(row, 0) job_id = int(item.text()) self.taskTableLabel.setText("Task List (job: " + item.text() + ")") try: tasks = Hydra_rendertask.fetch("where job_id = %d" % job_id) self.taskTable.setRowCount(len(tasks)) for pos, task in enumerate(tasks): # calcuate time difference tdiff = None if task.endTime: tdiff = task.endTime - task.startTime elif task.startTime: tdiff = dt.now().replace(microsecond=0) - task.startTime # populate table self.taskTable.setItem(pos, 0, QTableWidgetItem_int(str(task.id))) self.taskTable.setItem(pos, 1, QTableWidgetItem_int(str(task.priority))) self.taskTable.setItem(pos, 2, QTableWidgetItem(str(task.host))) self.taskTable.setItem(pos, 3, QTableWidgetItem(str(task.status))) self.taskTable.setItem(pos, 4, QTableWidgetItem_dt(task.startTime)) self.taskTable.setItem(pos, 5, QTableWidgetItem_dt(task.endTime)) self.taskTable.setItem(pos, 6, QTableWidgetItem_dt(str(tdiff))) except sqlerror as err: aboutBox(self, "SQL Error", str(err))
def testRenderCommand( self ): """Tests a Render Command, a command that invokes the Maya renderer.""" command = [ r'c:\program files\autodesk\maya2011\bin\render.exe', '-mr:v', '5', r'\\flex2\ProjectHydra\TestMayaFiles\Chair2.ma' ] render_task = Hydra_rendertask() render_task.status = 'R' render_task.command = repr( command ) render_task.insert() logger.debug(render_task) render_question = Questions.RenderQuestion( render_task.id ) render_answer = self.getAnswer( render_question ) logger.debug( render_answer )
def createTasks( self, job ): starts = range( self.startFrame, self.endFrame + 1, self.batchSize ) ends = [min( start + self.batchSize - 1, self.endFrame ) for start in starts ] for start, end in zip( starts, ends ): command = self.renderCommand(start, end) logger.debug( command ) task = Hydra_rendertask( status = READY, command = repr( command ), job_id = job.id, priority = self.priority, project = self.project, createTime = job.createTime, requirements = job.requirements, ) with transaction() as t: task.insert(transaction=t)
def killTask(task_id): """Kills the task with the specified id. If the task has been started, a kill request is sent to the node running it. @return: True if there were no errors killing the task, else False.""" [task] = Hydra_rendertask.fetch("where id = '%d'" % task_id) if task.status == READY: task.status = KILLED with transaction() as t: task.update(t) # if we reach this point: transaction successful, no exception raised return True elif task.status == STARTED: killed = sendKillQuestion(renderhost = task.host, newStatus = KILLED) # if we reach this point: TCPconnection successful, no exception raised return killed return False
def unstick (taskID=None, newTaskStatus=READY, host=None, newHostStatus=IDLE): with transaction () as t: if taskID: [task] = Hydra_rendertask.fetch ("where id = %d" % taskID) # if the task is marked, say, CRASHED, leave the host name alone. # only READY would be confusing with a host named filled in. I think. if newTaskStatus == READY: task.host = None task.status = newTaskStatus task.startTime = None task.endTime = None task.update (t) if host: [host] = Hydra_rendernode.fetch ("where host = '%s'" % host) host.task_id = None host.status = newHostStatus host.update (t)
def resurrectTask(task_id, ignoreStarted = False): """Resurrects the task with the specified id. @return: True if there was an error, such as when the user tries to resurrect a task that is marked as Started, else False.""" [task] = Hydra_rendertask.fetch("where id = '%d'" % task_id) if ( task.status == 'K' or task.status == 'F' or (task.status == 'S' and ignoreStarted == True) ): task.status = 'R' task.host = None task.startTime = None task.endTime = None else: return True with transaction() as t: task.update(t) return False
import re from MySQLSetup import transaction, Hydra_rendertask badTasks = Hydra_rendertask.fetch ("where command like '%-p''%'") print len(badTasks) for task in badTasks: task.command = task.command.replace("'-p'", "'-proj'") task.status = 'R' task.startTime = None task.endTime = None task.exitCode = None #task.command = re.sub (r"PyQt4.QtCore.QString\(u(.*)\)", r'\1', task.command) with transaction () as t: task.update (t)