예제 #1
0
파일: tests.py 프로젝트: bdelliott/butler
    def test_sync_in_progress(self):
        self.assertFalse(sync.latest_job())

        job = models.SyncJob()
        job.save()

        self.assertFalse(sync.latest_job().end)

        now = datetime.datetime.now()
        job.end = now
        job.save()

        self.assertTrue(sync.latest_job().end)
예제 #2
0
파일: syncjob.py 프로젝트: bdelliott/butler
    def job(self):
        """Confirm no sync job is running, otherwise kick off a new one"""

        job = sync.latest_job()
        if job and not job.end:
            # unfinished
            msg = "Previous job %d started at %s, but not yet finished." % (job.id,
                            job.start)
            #logger.info(msg)
            #raise CommandError(msg)

        else:
            job = models.SyncJob()
            job.save()
            try:
                self.new_job(job)
            finally:
                # tag job as complete
                logger.info("Finishing job %d" % job.id)
                job.end = datetime.datetime.now()
                job.save()