Exemplo n.º 1
0
    def run(self):
        """Runs the corresponding script for every Delivery which has not yet been run."""

        results = {
            AutomaticCorrectionRunner.SUCCESSFULL_RESULTS_KEY: 0,
            AutomaticCorrectionRunner.FAILED_RESULTS_KEY: 0
        }
        pending_automatic_corrections = self.selection_strategy.get_automatic_corrections(
        )
        for pending_automatic_correction in pending_automatic_corrections:

            try:
                self.setup_enviroment.run(pending_automatic_correction,
                                          AutomaticCorrectionRunner.TMP_DIR)
                self.run_script_command.set_script(
                    os.path.join(
                        AutomaticCorrectionRunner.TMP_DIR,
                        os.path.basename(pending_automatic_correction.script)))
                script_result = self.run_script_command.execute()
            except Exception, e:
                script_result = ScriptResult()
                script_result.captured_stdout = "An error has occurred when running the automatic correction process. Error information: " + str(
                    e)
                script_result.exit_value = 2

            script_result.automatic_correction = pending_automatic_correction
            for visitor in self.publish_result_visitors:
                script_result.accept(visitor)
            self.clean_up_tmp_dir()
            if (script_result.exit_value == 0):
                results[AutomaticCorrectionRunner.SUCCESSFULL_RESULTS_KEY] += 1
            else:
                results[AutomaticCorrectionRunner.FAILED_RESULTS_KEY] += 1
Exemplo n.º 2
0
 def run(self):
     """Runs the corresponding script for every Delivery which has not yet been run."""
     
     results = {AutomaticCorrectionRunner.SUCCESSFULL_RESULTS_KEY : 0, AutomaticCorrectionRunner.FAILED_RESULTS_KEY : 0}
     pending_automatic_corrections = self.selection_strategy.get_automatic_corrections()
     for pending_automatic_correction in pending_automatic_corrections:
         
         try:
             self.setup_enviroment.run(pending_automatic_correction, AutomaticCorrectionRunner.TMP_DIR)
             self.run_script_command.set_script(os.path.join(AutomaticCorrectionRunner.TMP_DIR, os.path.basename(pending_automatic_correction.script)))
             script_result = self.run_script_command.execute()
         except Exception, e:
             script_result = ScriptResult()
             script_result.captured_stdout = "An error has occurred when running the automatic correction process. Error information: " + str(e)
             script_result.exit_value = 2
             
         script_result.automatic_correction = pending_automatic_correction
         for visitor in self.publish_result_visitors:
             script_result.accept(visitor)
         self.clean_up_tmp_dir()
         if(script_result.exit_value == 0):
             results[AutomaticCorrectionRunner.SUCCESSFULL_RESULTS_KEY] += 1
         else :
             results[AutomaticCorrectionRunner.FAILED_RESULTS_KEY] += 1