Esempio n. 1
0
 def get(self,request,job_id):
     """
     approve job
     """
     job_state = request.GET['job_state']
     JobStatemachine.send_user_action(job_id,job_state,JobStateOutcome.approved_by_custodian)
     return redirect("/harvest/runningjob")
Esempio n. 2
0
 def get(self,request,job_id):
     """
     cancel job
     """
     #import ipdb;ipdb.set_trace()
     job_state = request.GET['job_state']
     JobStatemachine.send_user_action(job_id,job_state,JobStateOutcome.cancelled_by_custodian)
     return redirect("/harvest/runningjob")
Esempio n. 3
0
 def get(self, request, job_id):
     """
     approve job
     """
     job_state = request.GET['job_state']
     JobStatemachine.send_user_action(job_id, job_state,
                                      JobStateOutcome.approved_by_custodian)
     return redirect("/harvest/runningjob")
Esempio n. 4
0
 def get(self, request, job_id):
     """
     cancel job
     """
     #import ipdb;ipdb.set_trace()
     job_state = request.GET['job_state']
     JobStatemachine.send_user_action(
         job_id, job_state, JobStateOutcome.cancelled_by_custodian)
     return redirect("/harvest/runningjob")
Esempio n. 5
0
    def handle(self, *args, **options):
        check = options["check_datasource"]
        check_interval = 0
        if check:
            try:
                check_interval = int(options["check_interval"]) * 60
                if check_interval < 0:
                    check_interval = 0
            except:
                check_interval = 0

        # Parse the days argument as an integer.
        if options['job_id']:
            try:
                options['job_id'] = int(options['job_id'])
            except:
                raise Exception("job id should be integer")

            if options['user_action']:
                if options['job_state']:
                    JobStatemachine.send_user_action(options['job_id'],
                                                     options['job_state'],
                                                     options['user_action'])
                else:
                    JobStatemachine.send_user_action(options['job_id'], None,
                                                     options['user_action'])
            elif options['job_state']:
                raise Exception("missing action parameter")
            else:
                JobStatemachine.run_job(options['job_id'])
        elif options['run_interval']:
            try:
                options['run_interval'] = int(options['run_interval'])
            except:
                raise Exception("job id should be a positive integer.")

            if options['run_interval'] <= 0:
                raise Exception("job id should be a positive integer.")

            HarvestModifyTime(check, check_interval, True).harvest()
            JobStatemachine.running(options['run_interval'])
        elif check:
            HarvestModifyTime(check, check_interval).harvest()
        else:
            JobStatemachine.run_all_jobs()

        return 0
Esempio n. 6
0
    def handle(self, *args, **options):
        check = options["check_datasource"]
        check_interval = 0
        if check:
            try:
                check_interval = int(options["check_interval"]) * 60
                if check_interval < 0:
                    check_interval = 0
            except:
                check_interval = 0

        # Parse the days argument as an integer.
        if options["job_id"]:
            try:
                options["job_id"] = int(options["job_id"])
            except:
                raise Exception("job id should be integer")

            if options["user_action"]:
                if options["job_state"]:
                    JobStatemachine.send_user_action(options["job_id"], options["job_state"], options["user_action"])
                else:
                    JobStatemachine.send_user_action(options["job_id"], None, options["user_action"])
            elif options["job_state"]:
                raise Exception("missing action parameter")
            else:
                JobStatemachine.run_job(options["job_id"])
        elif options["run_interval"]:
            try:
                options["run_interval"] = int(options["run_interval"])
            except:
                raise Exception("job id should be a positive integer.")

            if options["run_interval"] <= 0:
                raise Exception("job id should be a positive integer.")

            HarvestModifyTime(check, check_interval, True).harvest()
            JobStatemachine.running(options["run_interval"])
        elif check:
            HarvestModifyTime(check, check_interval).harvest()
        else:
            JobStatemachine.run_all_jobs()

        return 0