#! /usr/bin/env python

'''
@author: Soizic Laguitton

@organization: I2BM, Neurospin, Gif-sur-Yvette, France
@organization: CATI, France
@organization: U{IFR 49<http://www.ifr49.org>}

@license: U{CeCILL version 2<http://www.cecill.info/licences/Licence_CeCILL_V2-en.html>}
'''


import sys

from soma.workflow.client import WorkflowController, Helper

if __name__ == '__main__':

    if len(sys.argv) < 3 or len(sys.argv) > 4:
       raise Exception("The program takes 3 parameter: \n"
                       "    * the workflow identifier (integer) \n"
                       "    * the computing resource id \n"
                       "    * the queue name (option)\n")

    workflow_id = sys.argv[1]

    wfc = WorkflowController(sys.argv[2])

    if len(sys.argv) == 3:
        wfc.restart_workflow(workflow_id)
    else:
        queue = sys.argv[3]
        wfc.restart_workflow(workflow_id, queue)


