def createJob(self, conn=Mock(), db=Mock(), domainCache=Mock(), id=1, jobType=JobType.COMMFLAG, jobStatus=JobStatus.FINISHED): return Job( id=id, channelId=2, startTime=None, insertTime=None, jobType=jobType, cmds=None, flags=None, jobStatus=jobStatus, statusTime=None, hostname='localhost', comment=None, scheduledRunTime=None, translator=self.translator, conn=conn, db=db, domainCache=domainCache)
def getJobs(self, program=None, jobType=None, jobStatus=None): """ Get jobs from the MythTV job queue matching a program, job type, and/or job status in order of scheduled run time. @type program: RecordedProgram @type jobType: int from enums.JobType @type jobStatus: int from enums.JobStatus @rtype: Job[] """ sql = """ select id, chanid, starttime, inserttime, type, cmds, flags, status, statustime, hostname, comment, schedruntime from jobqueue """ where = '' if program is not None: where += "chanid = %s " % program.getChannelId() where += "and " where += "starttime = '%s' " % program.starttimeAsTime() if jobType is not None: if program is not None: where += " and " where += "type = %d " % jobType if jobStatus is not None: if program is not None or jobType is not None: where += " and " where += "status = %d " % jobStatus if where != '': sql += " where " + where sql += " order by schedruntime, id" log.debug('%s' % sql) jobs = [] self.cursor.execute(sql) from mythbox.mythtv.domain import Job for row in self.cursor.fetchall(): row = self.toDict(self.cursor, row) jobs.append(Job( id=int(row['id']), channelId=int(row['chanid']), startTime=row['starttime'], insertTime=row['inserttime'], jobType=row['type'], cmds=row['cmds'], flags=row['flags'], jobStatus=row['status'], statusTime=row['statustime'], hostname=row['hostname'], comment=row['comment'], scheduledRunTime=row['schedruntime'], translator=self.translator, domainCache=self.domainCache)) return jobs