예제 #1
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
예제 #2
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
예제 #3
0
 def execute(self, time):
     try:
         return JobStatemachine.run_all_jobs(self._first_run)
     finally:
         self._first_run = False
 def execute(self,time):
     try:
         return JobStatemachine.run_all_jobs(self._first_run)
     finally:
         self._first_run = False