コード例 #1
0
ファイル: utils.py プロジェクト: carze/vappio
def runTask(taskName, f):
    """
    This takes a task name and a function. It runs the function, if the function does not throw an exception
    then it loads the task and marks it as completed.  If an exception is thrown it loads the task and
    marks it as failed and logs the exception in the task.

    runTask will fail if the task does not exist
    """

    try:
        f()
        task.updateTask(task.loadTask(taskName).setState(task.TASK_COMPLETED))
    except Exception, err:
        task.updateTask(task.loadTask(taskName
                                      ).setState(task.TASK_FAILED
                                                 ).addException(str(err), err, errors.getStacktrace()))
コード例 #2
0
ファイル: utils.py プロジェクト: carze/vappio
def runTask(taskName, f):
    """
    This takes a task name and a function. It runs the function, if the function does not throw an exception
    then it loads the task and marks it as completed.  If an exception is thrown it loads the task and
    marks it as failed and logs the exception in the task.

    runTask will fail if the task does not exist
    """

    try:
        f()
        task.updateTask(task.loadTask(taskName).setState(task.TASK_COMPLETED))
    except Exception, err:
        task.updateTask(
            task.loadTask(taskName).setState(task.TASK_FAILED).addException(
                str(err), err, errors.getStacktrace()))
コード例 #3
0
ファイル: utils.py プロジェクト: carze/vappio
def blockOnTaskAndForward(host, name, taskName, dstTask):
    notificationsL = []
    errorsL = []
    endState = blockOnTask(host,
                           name,
                           taskName,
                           notifyF=notificationsL.append,
                           errorF=errorsL.append)
    for m in notificationsL:
        dstTask = dstTask.addMessage(task.MSG_NOTIFICATION, m)
    for m in errorsL:
        dstTask = dstTask.addMessage(task.MSG_ERROR, m)
        
    tsk = task.updateTask(dstTask)

    return endState, tsk
コード例 #4
0
ファイル: utils.py プロジェクト: carze/vappio
def blockOnTaskAndForward(host, name, taskName, dstTask):
    notificationsL = []
    errorsL = []
    endState = blockOnTask(host,
                           name,
                           taskName,
                           notifyF=notificationsL.append,
                           errorF=errorsL.append)
    for m in notificationsL:
        dstTask = dstTask.addMessage(task.MSG_NOTIFICATION, m)
    for m in errorsL:
        dstTask = dstTask.addMessage(task.MSG_ERROR, m)

    tsk = task.updateTask(dstTask)

    return endState, tsk