示例#1
0
 def setUp(self):
     self.year = "2012-2013"
     self.term = "1"
     self.sno = username
     self.passwd = password
     self.course_type = '30'
     self.campus = '1'
     self.cookie = fakesysujwxt.login(self.sno, self.passwd)[1]
示例#2
0
def get_table(username, password, year, term):
    cookie = fakesysujwxt.login( username, password )
    if cookie[ 0 ] == True:
        cookie = cookie[ 1 ]
    else:
        print "password mismatch!"
        return -1
    result = fakesysujwxt.get_timetable( cookie.encode('ascii'),
                                     year.encode('ascii'),
                                     term.encode('ascii'))
    if result[ 0 ] == True:
        result = result[ 1 ]
    course = re.findall( r'jc=\'(?P<jc>.*?)\'.*?kcmc=\'(?P<kcmc>.*?)\'.*?dd=\'(?P<dd>.*?)\'.*?zfw=\'(?P<zfw>.*?)\'.*?weekpos=(?P<weekpos>.*?);', result, re.S )
    ret = [ { "time": match[ 0 ] , "course_name": match[ 1 ], "location": match[ 2 ], "duration": match[ 3 ], "week_pos": match[ 4 ] } for match in course ]
    return ret
示例#3
0
def sign_in():
    if logged_in():
        return redirect(url_for('index'))

    if request.method == 'GET':
        return render_template('sign_in.html')

    # POST
    username, password = [request.form[x] for x in ['username', 'password']]

    #login in with sysujwxt module here
    success, result = sysujwxt.login(username, password)

    if success:
        flash(u'登录成功', 'success')

        info_success, info_result = sysujwxt.get_info(result)
        if info_success:
            info = re.match(
                r'.+"xm":"(?P<name>.+?)".+"xymc":"(?P<school>.+?)".+"zyfxmc":"(?P<major>.+?)"',
                info_result)
            name, school, major = info.groups()
            # set cookie here
            next_url = request.args.get('next', '/')
            response = make_response(redirect(next_url))
            response.set_cookie('sno', username, SESSION_TIMEOUT)
            response.set_cookie('name', name, SESSION_TIMEOUT)
            response.set_cookie('school', school, SESSION_TIMEOUT)
            response.set_cookie('major', major, SESSION_TIMEOUT)
            response.set_cookie('JSESSIONID', result, SESSION_TIMEOUT)
            return response
        elif info_result == 'timeout' or info_result == 'expired':
            flash(u'= =哦希特, 貌似学校的系统挂了,换个时间再来试试吧', 'info')
            return render_template('sign_in.html', username=username)
    elif result == 'timeout':
        flash(u'= =哦希特, 貌似学校的系统挂了,换个时间再来试试吧', 'info')
        return render_template('sign_in.html', username=username)
    elif result == 'errorpass':
        flash(u'密码错误', 'error')
        return render_template('sign_in.html', username=username)
示例#4
0
def sign_in():
    if logged_in():
        return redirect(url_for('index'))

    if request.method == 'GET':
        return render_template('sign_in.html')

    # POST
    username, password = [request.form[x] for x in ['username', 'password']]

    #login in with sysujwxt module here
    success, result = sysujwxt.login(username, password)

    if success:
        flash(u'登录成功', 'success')

        info_success, info_result = sysujwxt.get_info(result)
        if info_success:
            info = re.match(r'.+"xm":"(?P<name>.+?)".+"xymc":"(?P<school>.+?)".+"zyfxmc":"(?P<major>.+?)"',
                            info_result)
            name, school, major = info.groups()
            # set cookie here
            next_url = request.args.get('next', '/')
            response = make_response(redirect(next_url))
            response.set_cookie('sno', username, SESSION_TIMEOUT)
            response.set_cookie('name', name, SESSION_TIMEOUT)
            response.set_cookie('school', school, SESSION_TIMEOUT)
            response.set_cookie('major', major, SESSION_TIMEOUT)
            response.set_cookie('JSESSIONID', result, SESSION_TIMEOUT)
            return response
        elif info_result == 'timeout' or info_result == 'expired':
            flash(u'= =哦希特, 貌似学校的系统挂了,换个时间再来试试吧', 'info')
            return render_template('sign_in.html', username=username)
    elif result == 'timeout':
        flash(u'= =哦希特, 貌似学校的系统挂了,换个时间再来试试吧', 'info')
        return render_template('sign_in.html', username=username)
    elif result == 'errorpass':
        flash(u'密码错误', 'error')
        return render_template('sign_in.html', username=username)
示例#5
0
def get_table(username, password, year, term):
    cookie = fakesysujwxt.login(username, password)
    if cookie[0] == True:
        cookie = cookie[1]
    else:
        print "password mismatch!"
        return -1
    result = fakesysujwxt.get_timetable(cookie.encode('ascii'),
                                        year.encode('ascii'),
                                        term.encode('ascii'))
    if result[0] == True:
        result = result[1]
    course = re.findall(
        r'jc=\'(?P<jc>.*?)\'.*?kcmc=\'(?P<kcmc>.*?)\'.*?dd=\'(?P<dd>.*?)\'.*?zfw=\'(?P<zfw>.*?)\'.*?weekpos=(?P<weekpos>.*?);',
        result, re.S)
    ret = [{
        "time": match[0],
        "course_name": match[1],
        "location": match[2],
        "duration": match[3],
        "week_pos": match[4]
    } for match in course]
    return ret
示例#6
0
 def test_login_failed(self):
     success, result = fakesysujwxt.login(self.sno, "")
     self.assertFalse(success)
示例#7
0
 def test_login_success(self):
     success, result = fakesysujwxt.login(self.sno, self.passwd)
     self.assertTrue(success)
        for question in questions:
            question_id = question['resourceId']
            if question is questions[-1]:
                question_list.append([question_id, None])
                break
            options = jwxt.get_option_list(cookie, question['resourceId'])
            if options[0] is True:
                options = json.loads(jwxt.format_to_json(options[1]))
            else:
                return (False, 'fail to get option list on question %s!' %
                        question_id)
            option_id = options['body']['dataStores']['qzStore']['rowSet'][
                'primary'][0]['resourceid']
            question_list.append([question_id, option_id])
        course_ooxx_code = jwxt.get_course_ooxx_code(cookie, \
                course['jsbh'], course['kch'], course['khlx'], \
                course['jxbh'], course['khtxbh'], course['pjlx'])
        if course_ooxx_code[0] is True:
            course_ooxx_code = json.loads(
                jwxt.format_to_json(course_ooxx_code[1]))
            course_ooxx_code = course_ooxx_code['body']['parameters']['bjid']
        else:
            return (False, 'fail to get ooxx_code on course %s!' % course_id)
        result = jwxt.submit_evaluation(cookie, question_list,
                                        course_ooxx_code)


if __name__ == "__main__":
    _, cookie = jwxt.login(sys.argv[1], sys.argv[2])
    one_click_evaluate(cookie)
示例#9
0
    elif s >= 2.0:
        return 2.7


def add_score(jd, xf, score):
    jd += [
        toronto(float(i["jd"]))
        for i in score["body"]["dataStores"]["kccjStore"]["rowSet"]["primary"]
    ]
    xf += [
        float(i["xf"])
        for i in score["body"]["dataStores"]["kccjStore"]["rowSet"]["primary"]
    ]


if __name__ == "__main__":
    username = sys.argv[1]
    password = sys.argv[2]
    _, cookie = fakesysujwxt.login(username, password)
    jd = []
    xf = []
    year_start = 2011
    for yy in range(2):
        for term in range(1, 4):
            year = "%d-%d" % (year_start + yy, year_start + yy + 1)
            raw_score = fakesysujwxt.get_score(cookie, username, year, term)[1]
            score = json.loads(fakesysujwxt.format_to_json(raw_score))
            add_score(jd, xf, score)
    a = sum([i * j for i, j in zip(jd, xf)])
    print a / sum(xf)
示例#10
0
    if s >= 3.5:
        return 4.0
    elif s >= 3.0:
        return 3.7
    elif s >= 2.7:
        return 3.3
    elif s >= 2.3:
        return 3.0
    elif s >= 2.0:
        return 2.7

def add_score(jd, xf, score):
    jd += [toronto(float(i["jd"])) for i in score["body"]["dataStores"]["kccjStore"]["rowSet"]["primary"]]
    xf += [float(i["xf"]) for i in score["body"]["dataStores"]["kccjStore"]["rowSet"]["primary"]]

if __name__ == "__main__":
    username = sys.argv[1]
    password = sys.argv[2]
    _, cookie = fakesysujwxt.login(username, password)
    jd = []
    xf = []
    year_start = 2011
    for yy in range(2):
        for term in range(1, 4):
            year = "%d-%d" % (year_start + yy, year_start + yy + 1)
            raw_score = fakesysujwxt.get_score(cookie, username, year, term)[1]
            score = json.loads(fakesysujwxt.format_to_json(raw_score))
            add_score(jd, xf, score)
    a = sum([i * j for i, j in zip(jd, xf)])
    print a / sum(xf)
            questions = questions['body']['dataStores']['wjStroe']['rowSet']['primary']
        else:
            return (False,
                    'fail to get question list on course %s!' % course_id)
        for question in questions:
            question_id = question['resourceId']
            if question is questions[-1]:
                question_list.append([question_id, None])
                break
            options = jwxt.get_option_list(cookie, question['resourceId'])
            if options[0] is True:
                options = json.loads(jwxt.format_to_json(options[1]))
            else:
                return (False,
                        'fail to get option list on question %s!' % question_id)
            option_id = options['body']['dataStores']['qzStore']['rowSet']['primary'][0]['resourceid']
            question_list.append([question_id, option_id])
        course_ooxx_code = jwxt.get_course_ooxx_code(cookie, \
                course['jsbh'], course['kch'], course['khlx'], \
                course['jxbh'], course['khtxbh'], course['pjlx'])
        if course_ooxx_code[0] is True:
            course_ooxx_code = json.loads(jwxt.format_to_json(course_ooxx_code[1]))
            course_ooxx_code = course_ooxx_code['body']['parameters']['bjid']
        else:
            return (False, 'fail to get ooxx_code on course %s!' % course_id)
        result = jwxt.submit_evaluation(cookie, question_list, course_ooxx_code)

if __name__ == "__main__":
    _, cookie = jwxt.login(sys.argv[1], sys.argv[2])
    one_click_evaluate(cookie)