From 8e08ee02e09d8d663ed956ecec87f3a70e5b66b4 Mon Sep 17 00:00:00 2001
From: Samuele Kaplun <samuele.kaplun@cern.ch>
Date: Thu, 24 Mar 2011 17:47:04 +0100
Subject: [PATCH] BibSched: improve arguments display for waiting tasks
* When a task is waiting the progress column can be used to display
the actual CLI arguments that will be used to call the given
WAITING task. (closes #557)
---
modules/bibsched/lib/bibtask.py | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/modules/bibsched/lib/bibtask.py b/modules/bibsched/lib/bibtask.py
index 81940d7..575b7e9 100644
|
a
|
b
|
from invenio.webuser import get_user_preferences, get_email |
| 69 | 69 | from invenio.bibtask_config import CFG_BIBTASK_VALID_TASKS, \ |
| 70 | 70 | CFG_BIBTASK_DEFAULT_TASK_SETTINGS |
| 71 | 71 | from invenio.dateutils import parse_runtime_limit |
| | 72 | from invenio.shellutils import escape_shell_arg |
| 72 | 73 | |
| 73 | 74 | # Global _TASK_PARAMS dictionary. |
| 74 | 75 | _TASK_PARAMS = { |
| … |
… |
def task_low_level_submission(name, user, *argv): |
| 183 | 184 | if special_name: |
| 184 | 185 | name = '%s:%s' % (name, special_name) |
| 185 | 186 | |
| | 187 | verbose_argv = 'Will execute: %s' % ' '.join([escape_shell_arg(str(arg)) for arg in argv]) |
| | 188 | |
| 186 | 189 | ## submit task: |
| 187 | 190 | task_id = run_sql("""INSERT INTO schTASK (proc,user, |
| 188 | 191 | runtime,sleeptime,status,progress,arguments,priority) |
| 189 | | VALUES (%s,%s,NOW(),'','WAITING','',%s,%s)""", |
| 190 | | (name, user, marshal.dumps(argv), priority)) |
| | 192 | VALUES (%s,%s,NOW(),'','WAITING',%s,%s,%s)""", |
| | 193 | (name, user, verbose_argv, marshal.dumps(argv), priority)) |
| 191 | 194 | |
| 192 | 195 | except Exception: |
| 193 | 196 | register_exception(alert_admin=True) |
| … |
… |
def _task_submit(argv, authorization_action, authorization_msg): |
| 660 | 663 | else: |
| 661 | 664 | task_name = _TASK_PARAMS['task_name'] |
| 662 | 665 | write_message("storing task options %s\n" % argv, verbose=9) |
| | 666 | verbose_argv = 'Will execute: %s' % ' '.join([escape_shell_arg(str(arg)) for arg in argv]) |
| 663 | 667 | _TASK_PARAMS['task_id'] = run_sql("""INSERT INTO schTASK (proc,user, |
| 664 | 668 | runtime,sleeptime,status,progress,arguments,priority) |
| 665 | | VALUES (%s,%s,%s,%s,'WAITING','',%s, %s)""", |
| | 669 | VALUES (%s,%s,%s,%s,'WAITING',%s,%s, %s)""", |
| 666 | 670 | (task_name, _TASK_PARAMS['user'], _TASK_PARAMS["runtime"], |
| 667 | | _TASK_PARAMS["sleeptime"], marshal.dumps(argv), _TASK_PARAMS['priority'])) |
| | 671 | _TASK_PARAMS["sleeptime"], verbose_argv, marshal.dumps(argv), _TASK_PARAMS['priority'])) |
| 668 | 672 | |
| 669 | 673 | ## update task number: |
| 670 | 674 | write_message("Task #%d submitted." % _TASK_PARAMS['task_id']) |
| … |
… |
def _task_run(task_run_fnc): |
| 765 | 769 | finally: |
| 766 | 770 | task_status = task_read_status() |
| 767 | 771 | if sleeptime: |
| | 772 | argv = _task_get_options(_TASK_PARAMS['task_id'], _TASK_PARAMS['task_name']) |
| | 773 | verbose_argv = 'Will execute: %s' % ' '.join([escape_shell_arg(str(arg)) for arg in argv]) |
| | 774 | |
| 768 | 775 | new_runtime = get_datetime(sleeptime) |
| 769 | 776 | ## The task is a daemon. We resubmit it |
| 770 | 777 | if task_status == 'DONE': |
| 771 | 778 | ## It has finished in a good way. We recycle the database row |
| 772 | | run_sql("UPDATE schTASK SET runtime=%s, status='WAITING', progress='' WHERE id=%s", (new_runtime, _TASK_PARAMS['task_id'])) |
| | 779 | run_sql("UPDATE schTASK SET runtime=%s, status='WAITING', progress=%s WHERE id=%s", (new_runtime, verbose_argv, _TASK_PARAMS['task_id'])) |
| 773 | 780 | write_message("Task #%d finished and resubmitted." % _TASK_PARAMS['task_id']) |
| 774 | 781 | elif task_status == 'STOPPED': |
| 775 | | run_sql("UPDATE schTASK SET status='WAITING', progress='' WHERE id=%s", (_TASK_PARAMS['task_id'], )) |
| | 782 | run_sql("UPDATE schTASK SET status='WAITING', progress=%s WHERE id=%s", (verbose_argv, _TASK_PARAMS['task_id'], )) |
| 776 | 783 | write_message("Task #%d stopped and resubmitted." % _TASK_PARAMS['task_id']) |
| 777 | 784 | else: |
| 778 | 785 | ## We keep the bad result and we resubmit with another id. |