ticket:557: 0001-BibSched-improve-arguments-display-for-waiting-tasks.patch

File 0001-BibSched-improve-arguments-display-for-waiting-tasks.patch, 4.1 KB (added by skaplun, 4 years ago)
  • modules/bibsched/lib/bibtask.py

    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 
    6969from invenio.bibtask_config import CFG_BIBTASK_VALID_TASKS, \ 
    7070    CFG_BIBTASK_DEFAULT_TASK_SETTINGS 
    7171from invenio.dateutils import parse_runtime_limit 
     72from invenio.shellutils import escape_shell_arg 
    7273 
    7374# Global _TASK_PARAMS dictionary. 
    7475_TASK_PARAMS = { 
    def task_low_level_submission(name, user, *argv): 
    183184        if special_name: 
    184185            name = '%s:%s' % (name, special_name) 
    185186 
     187        verbose_argv = 'Will execute: %s' % ' '.join([escape_shell_arg(str(arg)) for arg in argv]) 
     188 
    186189        ## submit task: 
    187190        task_id = run_sql("""INSERT INTO schTASK (proc,user, 
    188191            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)) 
    191194 
    192195    except Exception: 
    193196        register_exception(alert_admin=True) 
    def _task_submit(argv, authorization_action, authorization_msg): 
    660663    else: 
    661664        task_name = _TASK_PARAMS['task_name'] 
    662665    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]) 
    663667    _TASK_PARAMS['task_id'] = run_sql("""INSERT INTO schTASK (proc,user, 
    664668                                           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)""", 
    666670        (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'])) 
    668672 
    669673    ## update task number: 
    670674    write_message("Task #%d submitted." % _TASK_PARAMS['task_id']) 
    def _task_run(task_run_fnc): 
    765769    finally: 
    766770        task_status = task_read_status() 
    767771        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 
    768775            new_runtime = get_datetime(sleeptime) 
    769776            ## The task is a daemon. We resubmit it 
    770777            if task_status == 'DONE': 
    771778                ## 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'])) 
    773780                write_message("Task #%d finished and resubmitted." % _TASK_PARAMS['task_id']) 
    774781            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'], )) 
    776783                write_message("Task #%d stopped and resubmitted." % _TASK_PARAMS['task_id']) 
    777784            else: 
    778785                ## We keep the bad result and we resubmit with another id.