<commit_before>import os
import sqlite3

def Propfair(GEvector,Evector,lambdaList,T = 0):
    if T == 0:
		T = [1, 1, 1]
    #green energy vector, Grid Energy vector , T is the previous scheduled memory
    tc=50
    NDC=len(GEvector)
    Metric=[0]*NDC    # Vector of the metric we used for scheduling
    for i in range(0,NDC):
        Metric[i]=GEvector[i]/T[i]
        
    MAX=Metric.index(max(Metric)) #the index of the choosen one  

    SClist=[0]*len(GEvector) #refresh the Schedule list
    SClist[MAX]=1  #The Data Center which is selected
    #for i in range(0,NDC):
    #    lambdaList[i]=lambdaList[i]+SClist[i]
    for i in range(0,NDC):
        if SClist[i]==1:
            T[i]=(1-(1/tc))*T[i]+((1/tc))*GEvector[i]
        else:
            T[i]=(1-(1/tc))*T[i]
 
    #return SClist#, lambdaList
    return MAX, T
	
def fetchServerInfo():
	fd = os.open("/tmp/ryu/Distributed-Internet-Service-Delivery/controller.db", os.O_RDONLY)
	conn = sqlite3.connect('/dev/fd/%d' % fd)
	os.close(fd)
	cursor = conn.cursor()
	
	currentEnergyValues = [0, 0, 0]
	currentNumberOfUsers = [0, 0, 0]
	
	for i in range(0, 2):
		cursor.execute("SELECT * from energyValues where id = (SELECT MAX(id) from energyValues where server  = ?)", str(i + 1))
		fetchedData = cursor.fetchall()
		currentEnergyValues[i] = fetchedData[0][1]
		currentNumberOfUsers[i] = fetchedData[0][6]
		
	return currentEnergyValues, currentNumberOfUsers
	
GEvector, lambdaList = fetchServerInfo()
#T = [1, 1, 1]
MAX, T = Propfair(GEvector,0,lambdaList)
print (MAX + 1)

		
	
<commit_msg>Bug fix<commit_after>import os
import sqlite3

def Propfair(GEvector,Evector,lambdaList,T = 0):
    if T == 0:
		T = [1, 1, 1]
    #green energy vector, Grid Energy vector , T is the previous scheduled memory
    tc=50
    NDC=len(GEvector)
    Metric=[0]*NDC    # Vector of the metric we used for scheduling
    for i in range(0,NDC):
        Metric[i]=GEvector[i]/T[i]
        
    MAX=Metric.index(max(Metric)) #the index of the choosen one  

    SClist=[0]*len(GEvector) #refresh the Schedule list
    SClist[MAX]=1  #The Data Center which is selected
    #for i in range(0,NDC):
    #    lambdaList[i]=lambdaList[i]+SClist[i]
    for i in range(0,NDC):
        if SClist[i]==1:
            T[i]=(1-(1/tc))*T[i]+((1/tc))*GEvector[i]
        else:
            T[i]=(1-(1/tc))*T[i]
 
    #return SClist#, lambdaList
    return MAX, T
	
def fetchServerInfo():
	fd = os.open("/tmp/ryu/Distributed-Internet-Service-Delivery/controller.db", os.O_RDONLY)
	conn = sqlite3.connect('/dev/fd/%d' % fd)
	os.close(fd)
	cursor = conn.cursor()
	
	currentEnergyValues = [0, 0, 0]
	currentNumberOfUsers = [0, 0, 0]
	
	for i in range(0, 3):
		cursor.execute("SELECT * from energyValues where id = (SELECT MAX(id) from energyValues where server  = ?)", str(i + 1))
		fetchedData = cursor.fetchall()
		currentEnergyValues[i] = fetchedData[0][1]
		currentNumberOfUsers[i] = fetchedData[0][6]
		
	return currentEnergyValues, currentNumberOfUsers
	
GEvector, lambdaList = fetchServerInfo()
#T = [1, 1, 1]
MAX, T = Propfair(GEvector,0,lambdaList)
print (MAX + 1)

		
	

{'fraction_non_alphanumeric': 0.14616870573084353, 'fraction_numerical': 0.025112685125563427, 'mean_word_length': 3.413352272727273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6381045', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1124, 'n_words': 281}