예제 #1
0
    def _run(self):
        if os.path.exists(self._output_file_path):
            self._set_completion_state(TaskState.SUCCESS)
            return TaskState.SUCCESS

        status = super(LocalFSPersistentTask, self)._run()
        assert self.completed
        if status == TaskState.SUCCESS:
            base.touch(self._output_file_path)
        return status
예제 #2
0
 def test_touch(self):
     path = base.random_alpha_num_word(16)
     try:
         self.assertFalse(os.path.exists(path))
         base.touch(path)
         self.assertTrue(os.path.exists(path))
         base.touch(path)
         self.assertTrue(os.path.exists(path))
     finally:
         base.remove(path)
예제 #3
0
파일: test_base.py 프로젝트: rajeshmr/kiji
 def test_touch(self):
     path = base.random_alpha_num_word(16)
     try:
         self.assertFalse(os.path.exists(path))
         base.touch(path)
         self.assertTrue(os.path.exists(path))
         base.touch(path)
         self.assertTrue(os.path.exists(path))
     finally:
         base.remove(path)
예제 #4
0
    def testPersistentTaskNoRunIfFile(self):
        """Persistent task does not run if output file already exists."""

        class PTask(workflow.LocalFSPersistentTask):
            def run(self):
                return self.FAILURE

        flow = workflow.Workflow()
        file_path = base.random_alpha_num_word(16)
        base.touch(file_path)
        try:
            task = PTask(output_file_path=file_path, task_id="task", workflow=flow)
            flow.build()
            self.assertTrue(os.path.exists(file_path))
            self.assertTrue(flow.process())
            self.assertTrue(os.path.exists(file_path))
        finally:
            base.remove(file_path)
예제 #5
0
    def testPersistentTaskNoRunIfFile(self):
        """Persistent task does not run if output file already exists."""
        class PTask(workflow.LocalFSPersistentTask):
            def run(self):
                return self.FAILURE

        flow = workflow.Workflow()
        file_path = base.random_alpha_num_word(16)
        base.touch(file_path)
        try:
            task = PTask(
                output_file_path=file_path,
                task_id='task',
                workflow=flow,
            )
            flow.build()
            self.assertTrue(os.path.exists(file_path))
            self.assertTrue(flow.process())
            self.assertTrue(os.path.exists(file_path))
        finally:
            base.remove(file_path)