Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/cli.py
Show First 20 Lines • Show All 341 Lines • ▼ Show 20 Lines | def list_tasks(ctx, task_id, task_type, limit, status, policy, priority, | ||||
output.append('Found %d tasks\n' % ( | output.append('Found %d tasks\n' % ( | ||||
len(tasks))) | len(tasks))) | ||||
for task in tasks: | for task in tasks: | ||||
output.append(pretty_print_task(task, full=True)) | output.append(pretty_print_task(task, full=True)) | ||||
click.echo('\n'.join(output)) | click.echo('\n'.join(output)) | ||||
@task.command('respawn') | |||||
@click.argument('task-ids', required=True, nargs=-1) | |||||
@click.option('--next-run', '-n', required=False, type=DATETIME, | |||||
metavar='DATETIME', default=None, | |||||
ardumont: this date | |||||
help='Re spawn the selected tasks at this date') | |||||
@click.pass_context | |||||
def respawn_tasks(ctx, task_ids, next_run): | |||||
"""Respawn tasks. | |||||
Not Done Inline Actionsgiven ardumont: given | |||||
Respawn tasks given by their ids (see the 'task list' command to | |||||
find task ids) at the given date (immediately by default). | |||||
Eg. | |||||
swh-scheduler task respawn 1 3 12 | |||||
""" | |||||
scheduler = ctx.obj['scheduler'] | |||||
if not scheduler: | |||||
raise ValueError('Scheduler class (local/remote) must be instantiated') | |||||
if next_run is None: | |||||
next_run = arrow.utcnow() | |||||
output = [] | |||||
scheduler.set_status_tasks( | |||||
task_ids, status='next_run_not_scheduled', next_run=next_run) | |||||
output.append('Respawn tasks %s\n' % ( | |||||
task_ids)) | |||||
click.echo('\n'.join(output)) | |||||
@task.command('archive') | @task.command('archive') | ||||
@click.option('--before', '-b', default=None, | @click.option('--before', '-b', default=None, | ||||
help='''Task whose ended date is anterior will be archived. | help='''Task whose ended date is anterior will be archived. | ||||
Default to current month's first day.''') | Default to current month's first day.''') | ||||
@click.option('--after', '-a', default=None, | @click.option('--after', '-a', default=None, | ||||
help='''Task whose ended date is after the specified date will | help='''Task whose ended date is after the specified date will | ||||
be archived. Default to prior month's first day.''') | be archived. Default to prior month's first day.''') | ||||
@click.option('--batch-index', default=1000, type=click.INT, | @click.option('--batch-index', default=1000, type=click.INT, | ||||
▲ Show 20 Lines • Show All 242 Lines • Show Last 20 Lines |
this date