#! /usr/bin/env python
#############################################################
#                                                           #
#   Author: Herve Menager                                   #
#   Organization:'Biological Software and Databases' Group, #
#                Institut Pasteur, Paris.                   #
#   Distributed under GPLv2 Licence. Please refer to the    #
#   COPYING.LIB document.                                   #
#                                                           #
#############################################################
import mb_cgi
from Mobyle.Utils import makeService
import Mobyle.CommandBuilder

def process(self):
    service = makeService(self.request.getfirst('programName',None))
    evaluator = service.getEvaluator()
    for paramName in self.request.keys():
        evaluator.setVar( paramName , self.request.getfirst(paramName) ) 
    #create a commandBuilder
    commandBuilder = Mobyle.CommandBuilder.CommandBuilder()
    #return command line and parameter files
    self.jsonMap = commandBuilder.buildLocalCommand( service )
    
if __name__ == "__main__":
    mb_cgi.JSONCGI(processFunction=process)