Python login 模块,login() 实例源码

我们从Python开源项目中,提取了以下38个代码示例,用于说明如何使用login.login()

项目:uniq    作者:CiscoDevNet    | 项目源码 | 文件源码
def argparser():
    """ Returns an argparser instance (argparse.ArgumentParser) to support command line options."""

    parser = argparse.ArgumentParser(description='Arguments for logging in APIC-EM cluster.')
    parser.add_argument('-c', '--cluster',
                        required=False,
                        action='store',
                        help='cluster ip/name of APIC-EM.')
    parser.add_argument('-u', '--username',
                        required=False,
                        action='store',
                        help='Username to login.')
    parser.add_argument('-p', '--password',
                        required=False,
                        action='store',
                        help='Password to login.')
    return parser
项目:crysadm    作者:HuiMi24    | 项目源码 | 文件源码
def __relogin(username, password, account_info, account_key):
    print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
          username.encode('utf-8'), 'relogin')
    login_result = login(username, password, conf.ENCRYPT_PWD_URL)

    if login_result.get('errorCode') != 0:
        account_info['status'] = login_result.get('errorDesc')
        account_info['active'] = False
        r_session.set(account_key, json.dumps(account_info))
        return False, account_info

    account_info['session_id'] = login_result.get('sessionID')
    account_info['status'] = 'OK'
    r_session.set(account_key, json.dumps(account_info))
    return True, account_info


# ????????
项目:crysadm    作者:seatom    | 项目源码 | 文件源码
def __relogin(username, password, account_info, account_key):
    print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'), username.encode('utf-8'), 'relogin')
    login_result = login(username, password, conf.ENCRYPT_PWD_URL)

    if login_result.get('errorCode') != 0:
        account_info['status'] = login_result.get('errorDesc')
        account_info['active'] = False
        r_session.set(account_key, json.dumps(account_info))
        return False, account_info

    account_info['session_id'] = login_result.get('sessionID')
    account_info['status'] = 'OK'
    r_session.set(account_key, json.dumps(account_info))
    return True, account_info

# ????????
项目:crysadm    作者:seatom    | 项目源码 | 文件源码
def __relogin(username, password, account_info, account_key):
    print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'), username.encode('utf-8'), 'relogin')
    login_result = login(username, password, conf.ENCRYPT_PWD_URL)

    if login_result.get('errorCode') != 0:
        account_info['status'] = login_result.get('errorDesc')
        account_info['active'] = False
        r_session.set(account_key, json.dumps(account_info))
        return False, account_info

    account_info['session_id'] = login_result.get('sessionID')
    account_info['status'] = 'OK'
    r_session.set(account_key, json.dumps(account_info))
    return True, account_info

# ????????
项目:taokeCPS    作者:taokeCPS    | 项目源码 | 文件源码
def check_gaoyong(itemid):
    url = 'http://pub.alimama.com/items/channel/qqhd.json?q=https://detail.tmall.com/item.htm?id=%s' %itemid
    headers = login.headers
    html = requests.get(url, headers=headers)
    r = html.json()['data']
    gaoyong_status = r['head']['status'] #?????????“OK”????“NORESULT”????

    #??????
    if gaoyong_status == 'OK':
        eventRate = r['pageList'][0]['eventRate'] #????????
        print('? ??????????,????? %.2f%% ????????' %eventRate)
        return True

    #???????
    elif gaoyong_status == 'NORESULT':
        print('? ????????????')
        return False

#2. ????????????,????ID???True?????False?????
项目:taokeCPS    作者:taokeCPS    | 项目源码 | 文件源码
def check_special(itemid):
    url = 'http://pub.alimama.com/items/search.json?q=https://item.taobao.com/item.htm?id=%s' %itemid
    headers = login.headers
    html = requests.get(url, headers=headers)
    r = html.json()['data']['pageList'][0]
    special_status = r['includeDxjh'] #????????

    #??????
    if special_status == 1:
        return True

    #?????
    elif special_status == 0:
        return False

#3. ????ID???????????ID,?? > ??????????ID?????None
项目:crysadm    作者:sanzuwu    | 项目源码 | 文件源码
def __relogin(username, password, account_info, account_key):
    print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'), username.encode('utf-8'), 'relogin')
    login_result = login(username, password, conf.ENCRYPT_PWD_URL)

    if login_result.get('errorCode') != 0:
        account_info['status'] = login_result.get('errorDesc')
        account_info['active'] = False
        r_session.set(account_key, json.dumps(account_info))
        return False, account_info

    account_info['session_id'] = login_result.get('sessionID')
    account_info['status'] = 'OK'
    r_session.set(account_key, json.dumps(account_info))
    return True, account_info

# ????????
项目:thunderVIP    作者:liaojiacan    | 项目源码 | 文件源码
def main():

    with open("account.txt") as  f:
        for account in f:
            uAndp = account.split(" ");
            print(account,login.login(uAndp[0],uAndp[1])[1])
项目:thunderVIP    作者:liaojiacan    | 项目源码 | 文件源码
def test(self):
        r = login.login("username", "password")
        print(r)
项目:Spider_Hub    作者:WiseDoge    | 项目源码 | 文件源码
def main_from_me():
    """
    ???????????????????
    """
    account = input('Please input your account\n>  ')
    secret = input("input your secret\n>  ")
    login.login(session, secret, account)
    my_url = get_my_url()
    crawl(my_url)
项目:Spider_Hub    作者:WiseDoge    | 项目源码 | 文件源码
def main_from_one(start_url):
    """
    ???????????????????????????????????????????URL??????????????????
    """
    account = input('Please input your account\n>  ')
    secret = input("input your secret\n>  ")
    login.login(session, secret, account)
    crawl(start_url)
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def __init__(self, reg_no, pswd):

        #logging into student login
        self.br = login(reg_no,pswd)

        #checking that are we logged in or not
        if self.br.geturl() == ("https://academics.vit.ac.in/student/stud_home.asp") or self.br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
            print "SUCCESS"

        else :
            print "FAIL"

    #function to get the timetable
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def get_slot(reg_no = "", pwd = "", coursekey = ""):

    br = login(reg_no,pwd)

    print br.geturl()

    if br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
        print "SUCCESS"

        br.open("https://academics.vit.ac.in/student/coursepage_view.asp?sem=FS&crs=%(key)s&slt=&fac=" % {"key" : coursekey})
        response = br.open("https://academics.vit.ac.in/student/coursepage_view.asp?sem=FS&crs=%(key)s&slt=&fac=" % {"key" : coursekey})
        soup = BeautifulSoup(response.get_data())

        br.select_form("coursepage_view")

        #print br.read()
        forms = soup.findAll("select")

        #print forms[1]
        options = forms[1].findAll("option")
        options = options[1:]
        slot = {}

        for o in options:
            slot[o['value']] = o.getText()

        return {"status" : "Success_level_2" , "slot" : slot}

    else :
        print "FAIL"
        return {"status" : "Failure_level_2"}

#########################################################################################################################################################
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def get_faculty(reg_no = "", pwd = "", coursekey = "", slotkey = ""):

    br = login(reg_no,pwd)

    print br.geturl()

    if br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
        print "SUCCESS"

        br.open("https://academics.vit.ac.in/student/coursepage_view.asp?sem=FS&crs=%(ckey)s&slt=%(skey)s&fac=" % {"ckey" : coursekey, "skey": slotkey})
        response = br.open("https://academics.vit.ac.in/student/coursepage_view.asp?sem=FS&crs=%(key)s&slt=%(skey)s&fac=" % {"key" : coursekey, "skey" : slotkey})
        soup = BeautifulSoup(response.get_data())

        br.select_form("coursepage_view")

        #print br.read()
        forms = soup.findAll("select")

        #print forms[1]
        options = forms[2].findAll("option")
        options = options[1:]

        slot = {}

        for o in options:
            slot[o['value']] = o.getText()

        return {"status" : "Success_level_2" , "slot" : slot}

    else :
        print "FAIL"
        return {"status" : "Failure_level_2"}

#########################################################################################################################################################
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def get_data(reg_no = "", pwd = "", coursekey = "", slotkey = "", fackey = ""):

    br = login(reg_no,pwd)

    print br.geturl()

    if br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
        print "SUCCESS"

        def select_form(form):
            return form.attrs.get('action', None) == 'coursepage_view3.asp'

        br.open("https://academics.vit.ac.in/student/coursepage_view.asp?sem=FS&crs=%(ckey)s&slt=%(skey)s&fac=%(fkey)s" % {"ckey" : coursekey, "skey": slotkey, "fkey" : fackey})
        response = br.open("https://academics.vit.ac.in/student/coursepage_view.asp?sem=FS&crs=%(key)s&slt=%(skey)s&fac=%(fkey)s" % {"key" : coursekey, "skey" : slotkey, "fkey" : fackey})
        soup = BeautifulSoup(response.get_data())

        #form = soup.find("form",)
        br.select_form(predicate = select_form)
        res = br.submit()

        print br.geturl()

        soup = BeautifulSoup(res.get_data())

        #extracting data
        links = soup.findAll('a')
        href = []
        for l in links:
            href.append(l['href'])

        return {"status" : "Success_finally" , "uploads" : href}

    else :
        print "FAIL"
        return {"status" : "Failure_end"}
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def getFacultyAdvisor(reg_no = "", pwd = ""):

    #logging in
    br = login(reg_no,pwd)

    #checking that are we logged in or not
    if br.geturl() == ("https://academics.vit.ac.in/student/stud_home.asp") or br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
        print "SUCCESS"

        #opening faculty advisor details page
        br.open("https://academics.vit.ac.in/student/faculty_advisor_view.asp")
        response = br.open("https://academics.vit.ac.in/student/faculty_advisor_view.asp")

        #getting the soup
        soup = BeautifulSoup(response.get_data())

        #extracting tables
        tables = soup.findChildren('table')
        myTable = tables[1]
        rows = myTable.findChildren(['th','tr'])

        #extracting data
        for row in rows:

            #creating thread for each row
            thrd = myThread(row)
            #starting the thread
            thrd.start()

            #appending into thread list
            threads.append(thrd)

        #waiting for each thread to complete
        for t in threads:
            t.join()

        return {"status" : "Success" , "faculty_det" : faculty_advisor}

    else :
        print "FAIL"
        return {"Status" : "Failure", "Reason" : "Wrong Captcha"}
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def login_det():
    reg_no = request.args.get("regNo")
    pwd = request.args.get("psswd")

    return jsonify(**login(reg_no, pwd))

################################################################################ SPOTLIGHT #############
项目:PnPTools    作者:aradford123    | 项目源码 | 文件源码
def main():
    apic = login()
    for namespace in ["config", "template", "image"]:
        process_namespace(apic, namespace)
        print()
项目:PnPTools    作者:aradford123    | 项目源码 | 文件源码
def main(argv):

    apic = login()
    if len(argv) != 1:
        print("Error: Usage %s serial" % sys.argv[0])
        sys.exit(1)
    else:
        serial = argv[0]

    FINAL_STATUS="PROVISIONED"
    print("Watching unclaimed for serial:%s" % serial)
    starttime = time.time()
    status = "EMPTY"
    last_status = "first"
    last_time = starttime
    while status != FINAL_STATUS:
        status, status_detail = watch_status(apic, serial, last_status)
        if status_detail != last_status:
            now = time.time()
            print("%s: Duration (%d) %s" % (time.strftime("%H:%M:%S"), now - starttime, status_detail))
            last_status = status_detail
            last_time = now
        elif now - last_time > 300:
            print("waiting 5 mins")
            last_time = now
        time.sleep(2)


    print("%s: Completed (%d): %s" % (time.strftime("%H:%M:%S"), now - starttime, status))

    if status == FINAL_STATUS:
        sys.exit(0)
    else:
        sys.exit(3)
项目:fetcher    作者:soothion    | 项目源码 | 文件源码
def __init__(self):
        self.cookies = login().getCookies()
        self.s = requests.Session()
项目:fetcher    作者:soothion    | 项目源码 | 文件源码
def get(self,url):
        print('????'+url)##
        try:
            content = self.s.get(url,cookies=self.cookies).text
        except Exception as e:
            print('error:',e)
            time.sleep(10)
            content = self.s.get(url,cookies=self.cookies).text

        em = '<em style="padding: 0px 10px">|</em><span><a href="http://passport.jikexueyuan.com/sso/login" postion="index_index_header" rel="nofollow" jktag="&posGP=112001&posOper=900002">??</a></span>'
        if not content.find(em)==-1:
            cookies = login().login()
            content = self.s.get(url,cookies=cookies).text
            self.cookies = cookies
        return content
项目:SinaWeibo    作者:chengshuyi    | 项目源码 | 文件源码
def main(u,p,c):
    rt={}
    rt['time']=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
    t   =''
    l   =login(u,p,c)
    state=l.login()
    rt['login state']=str(state)
    sysLog(rt)
    return state
项目:taokeCPS    作者:taokeCPS    | 项目源码 | 文件源码
def get_campaign_id(itemid):
    url = 'http://pub.alimama.com/items/search.json?q=https://item.taobao.com/item.htm?id=%s' %itemid
    headers = login.headers
    html = requests.get(url, headers=headers)
    r = html.json()['data']['pageList'][0]

    tkRate = r['tkRate'] #????????????
    SpecialRate = r['tkSpecialCampaignIdRateMap'] #????????
    includeDxjh = r['includeDxjh'] #????????

    for k,rate in set(SpecialRate.items()):
        rate = float(rate)
        SpecialRate[k] = rate

    #?????????????
    CampaignID,highrate = max(zip(SpecialRate.keys(),SpecialRate.values()))

    if highrate >= tkRate:
        #????????????????
        return CampaignID

    else:
        #????????????????
        # print('? ????????????????????')
        return None


#3. ??????KeeperID??????KeeperID?????None
项目:taokeCPS    作者:taokeCPS    | 项目源码 | 文件源码
def get_keeper_id(itemid):
    url = 'http://pub.alimama.com/pubauc/getCommonCampaignByItemId.json?itemId=%s'%itemid
    headers = login.headers
    cookies = login.login()

    html = requests.get(url, headers=headers, cookies=cookies)
    result = html.json()['data'][0]
    KeeperID = result['ShopKeeperID'] #KeeperID

    return KeeperID

    # # ???????????
    # for result in results['data']:
    #     #CampaignID,ShopKeeperID,AvgCommission,manualAudit
    #     commissionRate = result['commissionRate'] #??????
    #     CampaignID = result['CampaignID'] #????ID
    #     ShopKeeperID = result['ShopKeeperID'] #KeeperID
    #     AvgCommission = result['AvgCommission'] #??????
    #     manualAudit = result['manualAudit'] #?????????=1???=0
    #     Exist = result['Exist'] #????? true????,false?????
    #     print('?????')
    #     print (Exist)
    #
    #     # ExistStatus = 2???,1?????
    #     ExistStatus = result['ExistStatus'] if 'ExistStatus' in result.keys() else '' #???????????????
    #
    #     # print('CampaignID = %d'%CampaignID)
    #
    #     #??????????????????ID,????????
    #     if CampaignID == str(CampaignID) and Exist is False:
    #         print('keepid = %s'%ShopKeeperID)
    #         break
    #         return ShopKeeperID
    #     else:
    #         print('?????ID????')
    #         return None


#4. ?????????????,????ID??? True?False?None
项目:taokeCPS    作者:taokeCPS    | 项目源码 | 文件源码
def enroll(itemid):

    headers = login.headers
    cookies = login.login()
    token = cookies['_tb_token_']

    CampaignID = get_campaign_id(itemid)
    KeeperID = get_keeper_id(itemid)

    apply_reason = '????????????????????????????????????????????????'
    data = {
         'campId': CampaignID,
         'keeperid': KeeperID,
        'applyreason':apply_reason,
        '_tb_token_':token
    }
    # print (CampaignID,KeeperID)
    url = 'http://pub.alimama.com/pubauc/applyForCommonCampaign.json'
    r = requests.post(url, headers=headers, cookies=cookies, data=data)
    r = r.json()

    if r['ok'] == True and r['info']['ok'] == True:
        #????????
        return True
    else:
        if '??' in r['info']['message']:
            #????????????????????????
            return None
        elif '??' in r['info']['message']:
            #???????cookies?????token???
            return False

#5. ????????????itemid????????????True????????????False????????None
项目:v2ex-terminal    作者:creatorYC    | 项目源码 | 文件源码
def main():
    txt = get_logo()
    print termcolor.colored(txt, "cyan")
    if not os.path.exists("cookies"):
        flag, username = is_login()
        # ?????????
        globlevalue.username = username
        if flag:
            Logging.debug(u"???????")
        else:
            resp = login()
            if resp.status_code == 200:
                Logging.success(u'???????????...')
                session.cookies.save()
                get_once()
                page = session.get(mission_url, headers=headers).content
                soup = BS(page, "html.parser")
                is_attain = soup.find('li', attrs={'class': 'fa fa-ok-sign'})
                if is_attain:
                    Logging.success(u'????????')
                    work()
                else:
                    mission()
                    work()
            else:
                Logging.error(u'?????')
    else:
        get_once()
        flag, username = is_login()
        # ?????????
        globlevalue.username = username
        page = session.get(mission_url, headers=headers).content
        soup = BS(page, "html.parser")
        is_attain = soup.find('li', attrs={'class': 'fa fa-ok-sign'})
        if is_attain:
            Logging.success(u'????????')
        else:
            mission()
        work()
项目:GPA    作者:RigeI    | 项目源码 | 文件源码
def main():

    os.system('clear')
    flag = -1
    username = input('??:')
    password = input('??:')

    times = 0
    while flag < 0:
        times += 1
        print(">>>?????%s???"%(times))
        s, flag = login.login(username, password)
        if flag < 0:
            print('>>>????')
        if times > 10:
            print(">>>??????,???????????")
            return

    print('>>>????')

    text = HTML_HEAD+login.get_score(s)
    # ????,??????
    fun.saveTextFile(text, './html/info.html')
    print('>>>??????html??')
    infos = spider.get_subjects(text)
    allPoint = 0.0
    allScore = 0.0
    for info in infos:
        allPoint += float(info.getPoint())
        allScore += ((float(info.getScore())/10.0)-5.0)*float(info.getPoint())
    print("?????????????%s"%(allScore/allPoint))
项目:uniq    作者:CiscoDevNet    | 项目源码 | 文件源码
def login():
    """ Login to APIC-EM northbound APIs in shell.

    Returns:
        Client (NbClientManager) which is already logged in.
    """

    parser = argparser()
    args = parser.parse_args()

    using_parser = False
    if args.cluster or args.username or args.password:
        using_parser = True

    host = args.cluster or None
    username = args.username or None
    password = args.password or None
    client = None

    while not client:
        host_prompt = 'Host Address[{}]: '.format(host) if host else 'Host Address: '
        username_prompt = 'Username[{}]: '.format(username) if username else 'Username: '

        if not using_parser or not host:
            host = input(host_prompt) or host
        if not using_parser or not username:
            username = input(username_prompt) or username
        if not using_parser or not password:
            password = getpass.getpass('Password: ') or password
        using_parser = False

        try:
            client = NbClientManager(
                server=host,
                username=username,
                password=password,
                connect=True)
        except requests.exceptions.HTTPError as exc_info:
            if exc_info.response.status_code == 401:
                print('Authentication Failed. Please provide valid username/password.')
                continue
            else:
                print('HTTP Status Code {code}. Reason: {reason}'.format(
                    code=exc_info.response.status_code,
                    reason=exc_info.response.reason))
                exit(1)
        except requests.exceptions.ConnectionError:
            print('Connection aborted. Please check if the host {} is available.'.format(host))
            exit(1)
    return client
项目:Crunchyroll-XML-Decoder    作者:jaw20    | 项目源码 | 文件源码
def makechoise():
    seleccion = 0
    print '''Options:
0.- Exit
1.- Download Anime 
2.- Download Subtitle only
3.- Login
4.- Login As Guest
5.- Download an entire Anime(Autocatch links)
6.- Run Queue
7.- Settings
'''
    try:
        seleccion = int(input("> "))
    except:
        try:
            os.system('cls')
        except:
            try:
                os.system('clear')
            except:
                pass
        print "ERROR: Invalid option."
        makechoise()
    if seleccion == 1 :
        ultimate.ultimate(raw_input('Please enter Crunchyroll video URL:\n'), '', '')
    elif seleccion == 2 :
        decode.decode(raw_input('Please enter Crunchyroll video URL:\n'))
    elif seleccion == 3 :
        username = raw_input(u'Username: ')
        password = getpass('Password(don\'t worry the password are typing but hidden:')
        login.login(username, password)
        makechoise()
    elif seleccion == 4 :
        login.login('', '')
        makechoise()
    elif seleccion == 5 :
        autocatch()
        queueu('.\\queue.txt')
    elif seleccion == 6 :
        queueu('.\\queue.txt')
    elif seleccion == 7 :
        settings_()
        makechoise()
    elif seleccion == 8 :
        import debug
    elif seleccion == 0 :
        sys.exit()
    else:
        try:
            os.system('cls')
        except:
            try:
                os.system('clear')
            except:
                pass
        print "ERROR: Invalid option."
        makechoise()
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#(    )#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def getTimetable(reg_no = "", pswd = ""):

    #logging in
    br = login(reg_no,pswd)

    #checking that are we logged in or not
    if br.geturl() == ("https://academics.vit.ac.in/student/stud_home.asp") or br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
        print "SUCCESS"

        #opening time table page
        br.open("https://academics.vit.ac.in/student/timetable_ws.asp")
        response = br.open("https://academics.vit.ac.in/student/timetable_ws.asp")

        #getting the soup
        soup = BeautifulSoup(response.get_data())

        #extracting tables from soup
        tables = soup.findAll('table')

        #getting required table
        myTable = tables[1]
        rows = myTable.findChildren(['th','tr'])
        rows = rows[1:]


        #extracting data
        for row in rows:

            #creating thread for each row
            thrd = myThread(row)
            #starting the thread
            thrd.start()

            #appending into thread list
            threads.append(thrd)

        #waiting for each thread to complete
        for t in threads:
            t.join()

        #returning the attendance
        return {"status" : "Success" , "time_table" : time_table}

    #failure due to wrong captcha
    else :
        print "FAIL"
        return {"Status" : "Failure", "Reason" : "Wrong Captcha"}
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def getCalmarks(reg_no = "", pwd = ""):

    #logging in
    br = login(reg_no,pwd)

    #checking that are we logged in or not
    if br.geturl() == ("https://academics.vit.ac.in/student/stud_home.asp") or br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
        print "SUCCESS"

        #opening the cal marks page
        br.open("https://academics.vit.ac.in/student/cal_da.asp?sem=WS")
        response = br.open("https://academics.vit.ac.in/student/cal_da.asp?sem=WS")

        #getting the soup
        soup = BeautifulSoup(response.get_data())

        #getting the required table
        print len(soup.findAll(table))
        myTable = soup.findAll('table')[1]

        #initialising some required variables
        calmarks = {}

        rows = myTable.findChildren(['th','tr'])
        rows = rows[1:]

        calmarks = {}
        i = 0

        #extracting the table
        for row in rows:

            #creating thread for each row
            thrd = myThread(br, row, i, calmarks)
            i= i+1
            #starting the thread
            thrd.start()

            #appending into thread list
            threads.append(thrd)

        #waiting for each thread to complete
        for t in threads:
            t.join()

        return {"status" : "Success" , "CAL_marks" : calmarks}

    else :
        print "FAIL"
        return {"Status" : "Failure", "Reason" : "Wrong Captcha"}
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def changePassword(reg_no = "", pwd = "", newpwd = ""):

    #logging in
    br = login(reg_no,pwd)

    #checking that are we logged in or not
    if br.geturl() == ("https://academics.vit.ac.in/student/stud_home.asp") or br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
        print "SUCCESS"

        #opening the change password page
        br.open("https://academics.vit.ac.in/student/changepswd.asp")
        response = br.open("https://academics.vit.ac.in/student/changepswd.asp")

        #selecting the form
        br.select_form("changepswd")

        #filling the form details
        br["oldpswd"] = str(pwd)
        br["newpswd"] = str(newpwd)
        br["cfmnewpswd"] = str(newpwd)

        #submitting the values and changing the password
        br.method = "POST"
        response = br.submit()

        #getting the soup
        soup = BeautifulSoup(response.get_data())

        #extracting status of password changing procedure
        tables = soup.findAll("table")
        myTable = tables[0]
        rows = myTable.findChildren(['th','tr'])
        cells = rows[0].findChildren("td")
        font = cells[1].findAll("font")
        change_status = font[1].string

        if change_status == "Incorrect old password...!!":
            print change_status

        elif font[1].string == "Your password is successfully changed.":
            print change_status

        else:
            return {"status" : "Success" , "password change status" : "other errors"}

        return {"status" : "Success" , "password change status" : change_status}

    else :
        print "FAIL"
        return {"Status" : "Failure", "Reason" : "Wrong Captcha"}
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def getMessages(reg_no = "", pwd = ""):

    #logging in
    br = login(reg_no,pwd)

    #checking if logged in or not
    if br.geturl() == ("https://academics.vit.ac.in/student/stud_home.asp") or br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
        print "SUCCESS"

        #opening the meesages page
        br.open("https://academics.vit.ac.in/student/class_message_view.asp?sem=WS")
        response = br.open("https://academics.vit.ac.in/student/class_message_view.asp?sem=WS")

        #getting the soup
        soup = BeautifulSoup(response.get_data())

        #checking if there is a mesage or not
        try:

            tables = soup.findAll('table')
            myTable = tables[1]
            rows = myTable.findChildren(['th','tr'])

            rows = rows[1:]

            for row in rows[:-1]:

                #creating thread for each row
                thrd = myThread(row)
                #starting the thread
                thrd.start()

                #appending into thread list
                threads.append(thrd)

            #waiting for each thread to complete
            for t in threads:
                t.join()

        except:

            print "nothing"

        return {"status" : "Success", "Messages" : messages}

    else :
        print "FAIL"
        return {"Status" : "Failure", "Reason" : "Wrong Captcha"}
项目:studentLogin_API_Flask    作者:PiyushGoyal443    | 项目源码 | 文件源码
def getMarks15(reg_no = "", pwd = ""):

    #logging in
    br = login(reg_no,pwd)

    #checking that are we logged in or not
    if br.geturl() == ("https://academics.vit.ac.in/student/stud_home.asp") or br.geturl() == ("https://academics.vit.ac.in/student/home.asp"):
        print "SUCCESS"

        #opening marks page
        br.open("https://academics.vit.ac.in/student/marks.asp?sem=WS")
        response = br.open("https://academics.vit.ac.in/student/marks.asp?sem=WS")

        #getting the soup
        soup = BeautifulSoup(response.get_data())

        #extracting tables
        tables = soup.findAll('table')
        myTable = tables[1]

        #initialising some required variables
        rows = myTable.findChildren(['th','tr'])
        rows = rows[2:]

        #extracting data
        for row in rows:

            #creating thread for each row
            thrd = myThread(row)
            #starting the thread
            thrd.start()

            #appending into thread list
            threads.append(thrd)

        #waiting for each thread to complete
        for t in threads:
            t.join()

        return {"status" : "Success" , "marks" : marks}

    else :
        print "FAIL"
        return {"Status" : "Failure", "Reason" : "Wrong Captcha"}
项目:tencent_mini    作者:IpursueI    | 项目源码 | 文件源码
def functionChoice(post, files):
    methodData = post.get("method", "postFormError")
    #return HttpResponse(json.dumps(post))
    if methodData == "postFormError":
        return HttpResponse(util.errorJsonWrapper("post????method??"))
    else:
        try:
            data = json.loads(methodData)
        except ValueError:
            return HttpResponse(util.errorJsonWrapper("json???????????"))
        try:
            funcName = data["name"]
        except KeyError:
            return HttpResponse(util.errorJsonWrapper("json???????name??"))
        try:
            funcArgs = data["args"]
        except KeyError:
            return HttpResponse(util.errorJsonWrapper("json???????args??"))

        if funcName == "register":
            return HttpResponse(register.register(funcArgs))
        elif funcName == "completeUserInfo":
            return HttpResponse(completeUserInfo.completeUserInfo(funcArgs,files))
        elif funcName == "login":
            return HttpResponse(login.login(funcArgs))
        elif funcName == "issueAdoptPetInfo":
            return HttpResponse(issueAdoptPetInfo.issueAdoptPetInfo(funcArgs,files))
        elif funcName == "issueFosterPetInfo":
            return HttpResponse(issueFosterPetInfo.issueFosterPetInfo(funcArgs))
        elif funcName == "getInfoList":
            return HttpResponse(getInfoList_dev.getInfoList(funcArgs))
        elif funcName == "getUserInfoList":
            return HttpResponse(getUserInfoList.getUserInfoList(funcArgs))
        elif funcName == "getAdoptDetailList":
            return HttpResponse(getAdoptDetailList.getAdoptDetailList(funcArgs))
        elif funcName == "authenticateUser":
            return HttpResponse(authenticateUser.authenticateUser(funcArgs,files))
        elif funcName == "logout":
            return HttpResponse(logout.logout(funcArgs))
        elif funcName == "cancelFoster":
            return HttpResponse(cancelFoster.cancelFoster(funcArgs))
        else:
            return HttpResponse(util.errorJsonWrapper(funcName+u":???????"))
项目:crysadm    作者:HuiMi24    | 项目源码 | 文件源码
def account_add():
    # ?????????????????
    account_name = request.values.get('xl_username')
    password = request.values.get('xl_password')
    md5_password = md5(password)

    user = session.get('user_info')

    accounts_key = 'accounts:%s' % user.get('username')

    if user.get('max_account_no') is None:
        user['max_account_no'] = 5

    account_no = r_session.scard(accounts_key)

    if account_no is not None:
        if account_no >= user.get('max_account_no'):
            session['error_message'] = '??????%d????' % account_no
            return redirect(url_for('accounts'))

    login_result = login(account_name, md5_password,
                         app.config.get('ENCRYPT_PWD_URL'))
    if login_result.get('errorCode') != 0:
        error_message = login_result.get('errorDesc')
        session['error_message'] = '??????????%s?' % error_message
        return redirect(url_for('accounts'))

    xl_session_id = login_result.get('sessionID')
    xl_nick_name = login_result.get('nickName')
    xl_user_name = login_result.get('userName')
    xl_user_id = str(login_result.get('userID'))
    xl_user_new_no = str(login_result.get('userNewNo'))
    xl_account_name = account_name
    xl_password = md5_password

    r_session.sadd(accounts_key, xl_user_id)

    account_key = 'account:%s:%s' % (user.get('username'), xl_user_id)
    xl_account_data = dict(session_id=xl_session_id, nick_name=xl_nick_name, username=xl_user_name,
                           user_id=xl_user_id, user_new_no=xl_user_new_no, account_name=xl_account_name,
                           password=xl_password, active=True, status='OK',
                           createdtime=datetime.now().strftime('%Y-%m-%d %H:%M'))
    r_session.set(account_key, json.dumps(xl_account_data))

    return redirect(url_for('accounts'))


# ???????????
项目:crysadm    作者:seatom    | 项目源码 | 文件源码
def account_add():
    account_name = request.values.get('xl_username')
    password = request.values.get('xl_password')
    md5_password = md5(password)

    user = session.get('user_info')

    accounts_key = 'accounts:%s' % user.get('username')

    if user.get('max_account_no') is None:
        user['max_account_no'] = 5

    account_no = r_session.scard(accounts_key)

    if account_no is not None:
        if account_no >= user.get('max_account_no'):
            session['error_message'] = '??????%d????' % account_no
            return redirect(url_for('accounts'))

    login_result = login(account_name, md5_password, app.config.get('ENCRYPT_PWD_URL'))
    if login_result.get('errorCode') != 0:
        error_message = login_result.get('errorDesc')
        session['error_message'] = '??????????%s?' % error_message
        return redirect(url_for('accounts'))

    xl_session_id = login_result.get('sessionID')
    xl_nick_name = login_result.get('nickName')
    xl_user_name = login_result.get('userName')
    xl_user_id = str(login_result.get('userID'))
    xl_user_new_no = str(login_result.get('userNewNo'))
    xl_account_name = account_name
    xl_password = md5_password

    r_session.sadd(accounts_key, xl_user_id)

    account_key = 'account:%s:%s' % (user.get('username'), xl_user_id)
    xl_account_data = dict(session_id=xl_session_id, nick_name=xl_nick_name, username=xl_user_name,
                           user_id=xl_user_id, user_new_no=xl_user_new_no, account_name=xl_account_name,
                           password=xl_password, active=True, status='OK',
                           createdtime=datetime.now().strftime('%Y-%m-%d %H:%M'))
    r_session.set(account_key, json.dumps(xl_account_data))

    return redirect(url_for('accounts'))

# ???????????
项目:crysadm    作者:sanzuwu    | 项目源码 | 文件源码
def account_add():
    account_name = request.values.get('xl_username')
    password = request.values.get('xl_password')
    md5_password = md5(password)

    user = session.get('user_info')

    accounts_key = 'accounts:%s' % user.get('username')

    if user.get('max_account_no') is None:
        user['max_account_no'] = 5

    account_no = r_session.scard(accounts_key)

    if account_no is not None:
        if account_no >= user.get('max_account_no'):
            session['error_message'] = '??????%d????' % account_no
            return redirect(url_for('accounts'))

    login_result = login(account_name, md5_password, app.config.get('ENCRYPT_PWD_URL'))
    if login_result.get('errorCode') != 0:
        error_message = login_result.get('errorDesc')
        session['error_message'] = '??????????%s?' % error_message
        return redirect(url_for('accounts'))

    xl_session_id = login_result.get('sessionID')
    xl_nick_name = login_result.get('nickName')
    xl_user_name = login_result.get('userName')
    xl_user_id = str(login_result.get('userID'))
    xl_user_new_no = str(login_result.get('userNewNo'))
    xl_account_name = account_name
    xl_password = md5_password

    r_session.sadd(accounts_key, xl_user_id)

    account_key = 'account:%s:%s' % (user.get('username'), xl_user_id)
    xl_account_data = dict(session_id=xl_session_id, nick_name=xl_nick_name, username=xl_user_name,
                           user_id=xl_user_id, user_new_no=xl_user_new_no, account_name=xl_account_name,
                           password=xl_password, active=True, status='OK',
                           createdtime=datetime.now().strftime('%Y-%m-%d %H:%M'))
    r_session.set(account_key, json.dumps(xl_account_data))

    return redirect(url_for('accounts'))

# ???????????