Esempio n. 1
0
def save_res(data,task):
    conn = connMysql()
    cur = conn.cursor()
    sql = "UPDATE `gr`.`main` SET `res` = "+trim(data)+" where running_id= " +str(task[1])
    cur.execute(sql)
    conn.commit()
    cur.close
    conn.close()
Esempio n. 2
0
def save_res(data,name,running_id):
    conn = connMysql()
    cur = conn.cursor()
    sql = "UPDATE `gr`.`main` SET `"+name+"` = \""+data+"\" where running_id= " +str(running_id)
    print sql
    cur.execute(sql)
    conn.commit()
    cur.close
    conn.close()
Esempio n. 3
0
def get_job():
    conn = connMysql()
    cur = conn.cursor()
    sql = "SELECT * FROM `main` WHERE `status`=0 LIMIT 0,30"
    cur.execute(sql)
    dataset = cur.fetchall()
    cur.close()
    conn.close()
    return dataset
Esempio n. 4
0
def save_Et(Et,task):
    conn = connMysql()
    cur = conn.cursor()
    sql = "UPDATE `gr`.`main` SET `Et` = "+str(Et)+" where running_id="+\
            str(task[1])
    cur.execute(sql)
    conn.commit()
    cur.close()
    conn.close()
Esempio n. 5
0
def clean_pre_data(running_id):
    conn = connMysql()
    cur = conn.cursor()
    sql = "UPDATE `gr`.`main` SET `Et` = null where running_id= " +str(running_id)
   # print sql
    cur.execute(sql)
    conn.commit()
    cur.close()
    conn.close()
    return 0
Esempio n. 6
0
def mark_as_complete(running_id):
    conn = connMysql()
    cur = conn.cursor()
    sql = "UPDATE `gr`.`main` SET `status` = 1 where running_id= " +str(running_id)
    print sql
    cur.execute(sql)
    conn.commit()
    cur.close()
    conn.close()
    return 0
Esempio n. 7
0
def save_res_plot(res,running_id):
    conn = connMysql()
    cur = conn.cursor()
    sql = "UPDATE `gr`.`main` SET `throughput` =\""+res+"\" where running_id=\
    "+str(running_id)
    print sql
    cur.execute(sql)
    conn.commit()
    cur.close()
    conn.close()
    return 0
Esempio n. 8
0
def saveFileToDatabase(username,passwd):
	newfile = open(username+'_1','r')
	data_raw = newfile.read()
	data = unicode(data_raw,'gb2312','ignore').encode('utf-8','ignore')
	conn = connMysql()
	cur = conn.cursor()
	sql = "UPDATE signup SET score ='"+ data +"' where userid = '" + username  + "' AND passwd= '"+ passwd + "'" 
	print sql
	cur.execute(sql)
	cur.close()
	conn.close()
Esempio n. 9
0
def saveScore(username,passwd,info_data):
		conn = connMysql()
		#cur = conn.cursor()
		cur = conn.cursor()
		sql_a = str(info_data[0])
		sql_b = str(info_data[1])
		print sql_a
		sql1 = "UPDATE signup SET info_data ='"+ sql_a +"' where userid = '" + username  + "' AND passwd= '"+ passwd + "'" 
		sql2 = "UPDATE signup SET fullgrade ='"+ sql_b +"' where userid = '" + username  + "' AND passwd= '"+ passwd + "'" 
		#print sql_0
		cur.execute(sql1)
		cur.execute(sql2)
		cur.close()
		conn.close()
		return 1
Esempio n. 10
0
def saveFileToDatabase(username,passwd,id):
	newfile = open(username+'_1','r')
	data = newfile.read()
	#print data[1]
	print "here"
	data = trim(data)
	print "here"
	conn = connMysql()
	cur = conn.cursor()
	#sql="insert into signup (username,passwd,score) values (%s,%s,%s)"
	sql = "UPDATE signup SET score ='"+ data +"' where id = '" + id  + "'" 
	#print sql
	#param = (username,passwd,data)
	
	cur.execute(sql)
	print "here"
	cur.close()
	conn.close()
Esempio n. 11
0
def save_Et(Et,running_id):
    conn = connMysql()
    cur = conn.cursor()
    get_old_Et = "Select `Et` from `gr`.`main` where running_id = "+\
            str(running_id)
    cur.execute(get_old_Et)
    pre_res = cur.fetchone()[0]
    if pre_res:
        new_data = pre_res+","+str(Et)
    else:
        new_data = str(Et)
    print new_data

    sql = "UPDATE `gr`.`main` SET `Et` = \""+new_data+"\" where running_id="+\
            str(running_id)
    print sql
    cur.execute(sql)
    conn.commit()
    cur.close()
    conn.close()
Esempio n. 12
0
def calGPA(username,passwd,id,mode):
	j = 0 
	a = ['优秀','良好','中等','及格','免修']
	b = ['95','85','75','65','0']
	c = ['90','85','82','78','75','72','68','64','60','0']
	d = ['4','3.7','3.3','3.0','2.7','2.3','2.0','1.5','1.0','0']
	k = 0
	fullgrade = 0
	Name = []
	Proportion = []
	changePro = []
	Score = []
	cgp = 0
	T = []
	f = 0
	conn = connMysql()
	cur = conn.cursor()
	sql = "SELECT score FROM  `signup` WHERE id = '" + id  + "'"
	cur.execute(sql)
	temp = cur.fetchall()
	print temp
	cur.close()
	conn.close()
	wholedata = temp[0][0]
	data = wholedata.split("@")

	t =  (len(data) -1) /7 #判断一共有多少门课程
	f = t #用f来保存课程总数
	while t != 0:
		zz = data[j * 7 + 6].strip() #从filename中取出成绩
		print zz
		if zz != a[4]: #如果没有免修的科目
			for k in [0,1,2,3]: #判断是否有需要转换五级分制的成绩
				if zz == a[k]:
					zz = b[k]	#将五级分制的成绩替换为相应的百分制			
			jd = float(data[j * 7 + 4].strip()) #取出绩点
			fullgrade += jd #计算学分总数
			Proportion.append(jd) #将学分单独存放在一个数组中
			score = float(zz)
			Score.append(score)  #将成绩单独存放在另外一个数组中
		else:
			f -= 1 # 如果存在免修的情况 课程数要减去一,同时忽略该课程
		t -= 1 #更改课程数量,直到处理完毕
		j += 1 

 #循环读取成绩,计算成绩对应的绩点,并将其保存到一个新数组中
	for x in Score:
		for k in [0,1,2,3,4,5,6,7,8,9]:
			
			tr = (x >= int(c[k]))
			if tr == True:
				changePro.append(d[k])
				break
			
	#DEBUG时使用		
	#print Score
	#print Proportion,
	#print changePro

#按照公式计算GPA
	while f > 0:
		cgp += float(Proportion[f - 1]) * float(changePro[f - 1])
		f-=1
	GPA [0]= cgp / fullgrade
	GPA [1] = fullgrade
	return GPA
Esempio n. 13
0
j = 0
a = ["优秀", "良好", "中等", "及格", "免修"]
b = ["95", "85", "75", "65", "0"]
c = ["90", "85", "82", "78", "75", "72", "68", "64", "60", "0"]
d = ["4", "3.7", "3.3", "3.0", "2.7", "2.3", "2.0", "1.5", "1.0", "0"]
k = 0
fullgrade = 0
Name = []
Proportion = []
changePro = []
Score = []
cgp = 0
T = []
f = 0

conn = connMysql()
cur = conn.cursor()
sql = "SELECT score FROM  `signup` WHERE id = '" + "271" + "'"
cur.execute(sql)
t = cur.fetchall()

b = t[0][0]
print b
d = b.split("@")
print d[2]
t = (len(d) - 1) / 7
print t
z = d[2 * 7 + 6]
print z
cur.close()
conn.close()