示例#1
0
def createFolders_callback(data):
	
	params = dict(data);

	root = params.pop('moldb_root');
	prototype = params.pop('moldb_prototype');
	printOnly = params.pop('moldb_printOnly');
	project_name = params.pop('moldb_projectName');

	visited={}
	m = buildImplementation(params,prototype,visited);

	meth = [];

	for pid in sorted(visited.keys()):
		meth.append(visited[pid]);

	folder = root + '/' + m.getRef();

	relroot = '$MOLDB_PROJECTS/'+project_name+'/Methods';	
	relfolder = relroot + '/' + m.getRef();	

	print folder;

	if printOnly: return

	# mkdir
	mkdir_p(folder);

	#chain.implementation	
	chain = Chain();
	chain.fromMethods(meth,m.getHash(),project_name,False);
		
	f=open(folder + '/chain.imp','w');
	f.write( chain.toString() );
	f.close();



	#PARAMETERS
	paramStr = 'PROJECT='+project_name+'\n';
	paramStr += 'FOLDER='+relfolder+'\n'
	paramStr += 'PROTOTYPES=$MOLDB_PROJECTS/'+project_name+'/Prototypes\n';
	paramStr += paramsString(params);
	
	f=open(folder+'/PARAMETERS','w');
	f.write(paramStr);
	f.close();

	os.system('chmod +x '+folder+ '/PARAMETERS');
	

	#DEPENDENCIES
	depStr = dependenciesString(m.dependencies,relroot);
	f=open(folder+'/DEPENDENCIES','w');
	f.write(depStr);
	f.close();
	
	os.system('chmod +x '+ folder +'/DEPENDENCIES');

	#Scripts
	strPrm = '#!/bin/bash\n'
	strPrm += '# METHOD '+m.name+'\n';
	strPrm += '# ID' + str(m.getHash())+'\n';
	strPrm += '# --- Dependencies --- \n'
	strPrm += '. ./DEPENDENCIES\n'
#	strPrm += dependenciesString(m.dependencies,root);
	
	strPrm += '# --- Method Parameters ---\n'
	strPrm += '. ./PARAMETERS\n'
#	strPrm += 'PROJECT='+root+'\n'
#	strPrm += 'FOLDER=' + folder +'\n'

	strPrm += paramsString(params);	
	strPrm += '\n # ---- Script ----\n'



	for script in m.scripts:
		f=open(folder+'/'+script.name,'w');
		f.write(strPrm+script.text);
		f.close();

		os.system('chmod +x '+folder+'/'+script.name);
示例#2
0
def createFolders_callback(data):

    params = dict(data)

    root = params.pop('moldb_root')
    prototype = params.pop('moldb_prototype')
    printOnly = params.pop('moldb_printOnly')
    project_name = params.pop('moldb_projectName')

    visited = {}
    m = buildImplementation(params, prototype, visited)

    meth = []

    for pid in sorted(visited.keys()):
        meth.append(visited[pid])

    folder = root + '/' + m.getRef()

    relroot = '$MOLDB_PROJECTS/' + project_name + '/Methods'
    relfolder = relroot + '/' + m.getRef()

    print folder

    if printOnly: return

    # mkdir
    mkdir_p(folder)

    #chain.implementation
    chain = Chain()
    chain.fromMethods(meth, m.getHash(), project_name, False)

    f = open(folder + '/chain.imp', 'w')
    f.write(chain.toString())
    f.close()

    #PARAMETERS
    paramStr = 'PROJECT=' + project_name + '\n'
    paramStr += 'FOLDER=' + relfolder + '\n'
    paramStr += 'PROTOTYPES=$MOLDB_PROJECTS/' + project_name + '/Prototypes\n'
    paramStr += paramsString(params)

    f = open(folder + '/PARAMETERS', 'w')
    f.write(paramStr)
    f.close()

    os.system('chmod +x ' + folder + '/PARAMETERS')

    #DEPENDENCIES
    depStr = dependenciesString(m.dependencies, relroot)
    f = open(folder + '/DEPENDENCIES', 'w')
    f.write(depStr)
    f.close()

    os.system('chmod +x ' + folder + '/DEPENDENCIES')

    #Scripts
    strPrm = '#!/bin/bash\n'
    strPrm += '# METHOD ' + m.name + '\n'
    strPrm += '# ID' + str(m.getHash()) + '\n'
    strPrm += '# --- Dependencies --- \n'
    strPrm += '. ./DEPENDENCIES\n'
    #	strPrm += dependenciesString(m.dependencies,root);

    strPrm += '# --- Method Parameters ---\n'
    strPrm += '. ./PARAMETERS\n'
    #	strPrm += 'PROJECT='+root+'\n'
    #	strPrm += 'FOLDER=' + folder +'\n'

    strPrm += paramsString(params)
    strPrm += '\n # ---- Script ----\n'

    for script in m.scripts:
        f = open(folder + '/' + script.name, 'w')
        f.write(strPrm + script.text)
        f.close()

        os.system('chmod +x ' + folder + '/' + script.name)