示例#1
0
class TaskSchedulerForm(Form):
    _translate_names = lambda variant: (variant[0], lazy_gettext(variant[1]))
    _choices = map(_translate_names, sched_variants())
    sched = SelectField(lazy_gettext('Task Scheduler'), choices=_choices)
    customized_columns = Select2Field(lazy_gettext('Customized columns'),
                                      choices=[],
                                      default="")
    rand_within_priority = BooleanField(
        lazy_gettext('Randomize Within Priority'))
    gold_task_probability_validator = validators.NumberRange(
        min=0,
        max=1,
        message=lazy_gettext(
            'Gold task probability must be a value between 0.0 and 1.0'))
    gold_task_probability = DecimalField(
        label=lazy_gettext('Gold Probability'),
        validators=[gold_task_probability_validator],
        description=lazy_gettext('Probability value between 0 and 1'))

    def set_customized_columns_options(self, new_options):
        self.customized_columns.choices = new_options

    @classmethod
    def update_sched_options(cls, new_options):
        _translate_names = lambda variant: (variant[0], lazy_gettext(variant[1]
                                                                     ))
        _choices = map(_translate_names, new_options)
        cls.sched.kwargs['choices'] = _choices
示例#2
0
class TaskSchedulerForm(Form):
    _translate_names = lambda variant: (variant[0], lazy_gettext(variant[1]))
    _choices = map(_translate_names, sched_variants())
    sched = SelectField(lazy_gettext('Task Scheduler'), choices=_choices)

    @classmethod
    def update_sched_options(cls, new_options):
        _translate_names = lambda variant: (variant[0], lazy_gettext(variant[1]))
        _choices = map(_translate_names, new_options)
        cls.sched.kwargs['choices'] = _choices
示例#3
0
class TaskSchedulerForm(Form):
    _translate_names = lambda variant: (variant[0], lazy_gettext(variant[1]))
    _choices = map(_translate_names, sched_variants())
    sched = SelectField(lazy_gettext('Task Scheduler'), choices=_choices)
    rand_within_priority = BooleanField(
        lazy_gettext('Randomize Within Priority'))

    @classmethod
    def update_sched_options(cls, new_options):
        _translate_names = lambda variant: (variant[0], lazy_gettext(variant[1]
                                                                     ))
        _choices = map(_translate_names, new_options)
        cls.sched.kwargs['choices'] = _choices
示例#4
0
 def setup(self):
     sched.new_task = with_random_scheduler(sched.new_task)
     sched.sched_variants = variants_with_random_scheduler(sched.sched_variants)
     TaskSchedulerForm.update_sched_options(sched.sched_variants())
示例#5
0
 def setup(self):
     sched.new_task = with_random_scheduler(sched.new_task)
     sched.sched_variants = variants_with_random_scheduler(sched.sched_variants)
     TaskSchedulerForm.update_sched_options(sched.sched_variants())
def with_frg_scheduler(f):
    @wraps(f)
    def wrapper(project_id, sched, user_id=None, user_ip=None, offset=0):
        if sched == SCHEDULER_NAME:
            return get_task(project_id, user_id, user_ip, offset=offset)
        return f(project_id,
                 sched,
                 user_id=user_id,
                 user_ip=user_ip,
                 offset=offset)

    return wrapper


def variants_with_frg_scheduler(f):
    @wraps(f)
    def wrapper():
        return f() + [(SCHEDULER_NAME, SCHEDULER_DISPLAY_NAME)]

    return wrapper


class FRGScheduler(Plugin):
    def setup(self):
        sched.new_task = with_frg_scheduler(sched.new_task)
        sched.sched_variants = variants_with_frg_scheduler(
            sched.sched_variants)


TaskSchedulerForm.update_sched_options(sched.sched_variants())