Example #1
0
    def load(self):
        f = file(self.loadName)

        for line in f.readlines():
            sa = line.split(',')
            g = grade.Grade(sa[0], sa[1], int(sa[2]))
            self.grades.append(g)
        print 'load data ok'
Example #2
0
 def listBefore(self):
     cur = self.db.cursor()
     cur.execute("select id,name,value from grade")
     res = cur.fetchall()
     grades = []
     for line in res:
         g = grade.Grade(line[0], line[1], line[2])
         grades.append(g)
     return grades
Example #3
0
    def find(self, grade_id):
        g = None

        cur = self.db.cursor()
        cur.execute("select id,name,value from grade where id=?", (grade_id, ))
        res = cur.fetchall()
        if len(res) > 0:
            g = grade.Grade(res[0][0], res[0][1], res[0][2])

        return g
Example #4
0
	def listBefore(self):
		grades=[]
		self.sock.send('L')
		data=self.sock.recv(2048)
		lines=data.split(';')
		for line in lines:
			sa=line.split(',')
			if len(sa)>2:
				g=grade.Grade(sa[0],sa[1],int(sa[2]))
				grades.append(g)
		return grades
Example #5
0
	def find(self,grade_id):
		g=None

		cmd='F,%s' % (grade_id)
		self.sock.send(cmd)
		data=self.sock.recv(2048)
		sa=data.split(',')
		if sa[0]=='ok':
			g=grade.Grade(sa[1],sa[2],int(sa[3]))
		
		return g
Example #6
0
 def gradeAdd(self):
     print '--add--'
     grade_id = raw_input('id:')
     g = self.find(grade_id)
     if g:
         print grade_id, ' exists!'
     else:
         g = grade.Grade(grade_id, '', 0)
         self.input(g)
         self.grades.append(g)
         print '--add ok--'
Example #7
0
 def gradeAdd(self):
     print '--add--'
     grade_id = raw_input('id:')
     g = self.find(grade_id)
     if g:
         print grade_id, ' exists!'
     else:
         g = grade.Grade(grade_id, '', 0)
         self.input(g)
         affRow = self.addAfter(g)
         if affRow == 1:
             print '--add ok--'
         else:
             print '--add err--'
def test_grade_object():
    good_score = {
        'uuid': '123761238yhfdjsbfasd9f0nvdf',
        'foo_check': {
            'check_name': 'foo',
            'score': 5,
            'message': 'you are secure',
            'score_possible': 5
        },
        'bar_check': {
            'check_name': 'foo',
            'score': 60,
            'message': 'you are secure',
            'score_possible': 60
        }
    }

    g = grade.Grade()
    this_grade = g.get_grade(good_score)
    assert g is not None
    assert this_grade['score'] == 100
    assert this_grade['grade'] == 'A+'
def test_grade_rounding():
    good_score = {
        'uuid': '123761238yhfdjsbfasd9f0nvdf',
        'foo_check': {
            'check_name': 'foo',
            'score': 5,
            'message': 'you are secure',
            'score_possible': 5
        },
        'bar_check': {
            'check_name': 'foo',
            'score': 25,
            'message': 'you are secure',
            'score_possible': 60
        }
    }

    g = grade.Grade()
    this_grade = g.get_grade(good_score)
    print this_grade
    assert g is not None
    # 63 is rounded up to 65 in this case
    assert this_grade['score'] == 45
    assert this_grade['grade'] == 'C-'
Example #10
0
def get_scan(profile_id):
    u = user.User(session['userinfo'])
    s = user.Scan(u).find_score_by_key(profile_id)
    g = grade.Grade().get_grade(s)
    return render_template('report.html', user=u, score=s, grade=g)
Example #11
0
 def newg(self):
     self.app.withdraw()
     self.newwindow = Toplevel()
     ob = g.Grade(self.newwindow, self.app)
Example #12
0
    except getopt.GetoptError, err:
        print str(err)
        Usage()
        sys.exit(2)
    for o, a in opts:
        if o in ('-h', '--help'):
            Usage()
            sys.exit(1)
        elif o in ('-u'):
            username = a
        elif o in ('-p'):
            password = a
        else:
            print 'unhandled option'
            exit(3)

    if username != '' and password != '':
        grades = grade.Grade(username, password)
        gradespider = grades.verifyLogin()
        if gradespider:
            grades.generateSheet()
            print 'Successful Please go to the desktop view'
        else:
            print 'username or password error'
    else:
        Usage()


if __name__ == '__main__':
    main()
Example #13
0
import grade

grades = []

f = file('datafile/d1.txt')

for line in f.readlines():
    sa = line.split(',')
    g = grade.Grade(sa[0], sa[1], int(sa[2]))
    grades.append(g)

for g in grades:
    print g