Esempio n. 1
0
def runScript(request):
    code = request.POST.get('scriptCode')

    if code == "":
        request.session['userScript'] = ""
        request.session['scriptOutput'] = ""
        output = ""
    else:
        bto = BTOGenerator()
        output = bto.generateCode(str(code))		
        request.session['userScript'] = code
        request.session['scriptOutput'] = output

    request.session.modified = True
    return HttpResponse(output)
Esempio n. 2
0
def runScript(request):
    code = request.POST.get('scriptCode')

    if code == "":
        request.session['userScript'] = ""
        request.session['scriptOutput'] = ""
        output = ""
    else:
        bto = BTOGenerator()
        output = bto.generateCode(str(code))
        request.session['userScript'] = code
        request.session['scriptOutput'] = output

    request.session.modified = True
    return HttpResponse(output)
Esempio n. 3
0
def make_mfile(request, paramProperty):
    dajax = Dajax()

    ### set defaultDir = /homes/salin/Lighthouse/Dlighthouse/
    defaultDir = os.getcwd()

    ### call codeGen.templates.BTOGenerator
    bto = BTOGenerator()

    ### create /private/tmp/lighthouse_temp and go there
    bto.generateTmpDir()

    ### create and write .m file in the current work dir: /private/tmp/lighthouse_temp
    inArray = []
    outArray = []
    inoutArray = []
    ### filename = [kernelName].m
    f = open('%s.m' % paramProperty['kernelName'], 'w')
    f.write('%s\n' % paramProperty['kernelName'])
    for item in paramProperty:
        if paramProperty[item][0] == 'in':
            inArray.append(str(item + ': ' + paramProperty[item][1]))
        if paramProperty[item][0] == 'out':
            outArray.append(str(item + ': ' + paramProperty[item][1]))
        if paramProperty[item][0] == 'inout':
            inoutArray.append(str(item + ': ' + paramProperty[item][1]))

    if inArray:
        f.write('in\n')
        f.write('  ')
        for item in inArray[:-1]:
            f.write('%s, ' % (item))
        f.write('%s \n' % inArray[-1])

    if inoutArray:
        f.write('inout\n')
        f.write('  ')
        for item in inoutArray[:-1]:
            f.write('%s, ' % (item))
        f.write('%s \n' % inoutArray[-1])

    if outArray:
        f.write('out\n')
        f.write('  ')
        for item in outArray[:-1]:
            f.write('%s, ' % (item))
        f.write('%s \n' % outArray[-1])

    f.write('{\n')
    f.write('   %s\n' % paramProperty['equation'])
    f.write('}')
    f.close()

    btoArgs = paramProperty['btoArgs']

    try:
        output = bto.submitToBTO('%s.m' % paramProperty['kernelName'], btoArgs)

    except Exception, e:
        print 'submitToBTO Exception caught:', str(e)
        print 'bto.submitToBTO(', '%s.m' % paramProperty['kernelName'], ')'
Esempio n. 4
0
def make_mfile(request, paramProperty):
	dajax = Dajax()
	
	### set defaultDir = /homes/salin/Lighthouse/Dlighthouse/
	defaultDir = os.getcwd()

	### call codeGen.templates.BTOGenerator
	bto = BTOGenerator()
	
	### create /private/tmp/lighthouse_temp and go there
	bto.generateTmpDir()
	
	### create and write .m file in the current work dir: /private/tmp/lighthouse_temp
	inArray = []
	outArray = []
	inoutArray = []
	### filename = [kernelName].m
	f=open('%s.m'%paramProperty['kernelName'], 'w')
	f.write('%s\n'%paramProperty['kernelName'])
	for item in paramProperty:
		if paramProperty[item][0] == 'in':
			inArray.append(str(item+': '+paramProperty[item][1]))
		if paramProperty[item][0] == 'out':
			outArray.append(str(item+': '+paramProperty[item][1]))
		if paramProperty[item][0] == 'inout':
			inoutArray.append(str(item+': '+paramProperty[item][1]))
			
	if inArray:
		f.write('in\n')
		f.write('  ')
		for item in inArray[:-1]:
			f.write('%s, '% (item))
		f.write('%s \n'%inArray[-1])
		
	if inoutArray:
		f.write('inout\n')
		f.write('  ')
		for item in inoutArray[:-1]:
			f.write('%s, '% (item))
		f.write('%s \n'%inoutArray[-1])
		
	if outArray:
		f.write('out\n')
		f.write('  ')
		for item in outArray[:-1]:
			f.write('%s, '% (item))
		f.write('%s \n'%outArray[-1])

	f.write('{\n')
	f.write('   %s\n'%paramProperty['equation'])
	f.write('}')
	f.close()

	btoArgs = paramProperty['btoArgs'];

	try:
		output = bto.submitToBTO('%s.m'%paramProperty['kernelName'], btoArgs)

	except Exception, e:
		print 'submitToBTO Exception caught:', str(e)
		print 'bto.submitToBTO(','%s.m'%paramProperty['kernelName'],')'