Example #1
0
    def test_addJob_UserJob1(self):
        recordings = self.conn.getAllRecordings()
        if not recordings:
            log.warn("Cannot run unit tests without program listings in the database")
            return

        job = Job.fromProgram(recordings[-1], JobType.USERJOB & JobType.USERJOB1)
        log.debug(job)

        self.assertIsNone(job.id)
        self.db.addJob(job)
        log.debug(job)
        self.assertIsNotNone(job.id)
Example #2
0
    def test_addJob_UserJob1(self):
        recordings = self.conn.getAllRecordings()
        if not recordings:
            log.warn(
                'Cannot run unit tests without program listings in the database'
            )
            return

        job = Job.fromProgram(recordings[-1],
                              JobType.USERJOB & JobType.USERJOB1)
        log.debug(job)

        self.assertIsNone(job.id)
        self.db.addJob(job)
        log.debug(job)
        self.assertIsNotNone(job.id)
Example #3
0
 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)        
Example #4
0
 def queueJob(self, jobType):
     job = Job.fromProgram(self.program, jobType)
     self.db().addJob(job)
     numJobs = len(self.db().getJobs(jobStatus=JobStatus.QUEUED))
     toolkit.showPopup('Job Queue', 'Queued as job %d of %d ' % (numJobs,numJobs), 5000)
Example #5
0
 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
Example #6
0
 def queueJob(self, jobType):
     job = Job.fromProgram(self.program, jobType)
     self.db().addJob(job)
     numJobs = len(self.db().getJobs(jobStatus=JobStatus.QUEUED))
     toolkit.showPopup('Job Queue',
                       'Queued as job %d of %d ' % (numJobs, numJobs), 5000)