Exemple #1
0
def ajax_cleancode_compile(request):
    logger.info('Compilation Called....')
    res = {}
    if request.method == 'POST':
        lang = request.POST.get('language', 'c')
        name = request.POST.get('name', None)
        main = request.POST.get('main', None)
        func = request.POST.get('func', None)
        input = request.POST.get('input', None)
        depends = request.POST.get('depends', None)
        # Unicode
        #name =  name.encode('utf8') if name else ''
        #main =  main.encode('utf8').strip() if main else ''
        #func =  func.encode('utf8') if func else ''
        #input =  input.encode('utf8') if input else ''
        [name, main, func, input] = [
            xx.encode('utf8') if xx else ''
            for xx in [name, main, func, input]
        ]
        # Logic  Here ..
        from CommonLib.codecompile.executeLib import Execute
        ex = Execute(lang, name, main, func, input, depends)
        #pdb.set_trace();
        ex.save(name, main, func, input)
        res = ex.compile(name)
        res['status'] = 'success'  # TODO we shoud have a try catch here..
        #ex.run(name)
        #ex.testperf(name)
    return HttpResponse(decodeUnicodeDirectory(res),
                        content_type='application/json')
Exemple #2
0
def ajax_cleancode_perf(request):
    res= {}
    if request.method == 'POST':
        lang=request.POST.get('language','c')
        name=request.POST.get('name',None)
        main=request.POST.get('main',None)
        func=request.POST.get('func',None)
        input=request.POST.get('input',None)
        # Unicode
        [ name,main,func,input] = [ xx.encode('utf8') if xx else '' for xx in [ name,main,func,input] ]
        # Logic  Here ..
        from CommonLib.codecompile.executeLib import Execute
        ex = Execute(lang,name,main,func,input)
        res = ex.testperf(name)
        res['status']='success' # TODO we shoud have a try catch here..
    return HttpResponse(decodeUnicodeDirectory(res), content_type = 'application/json')