示例#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