コード例 #1
0
 def uamTk(self):
     jsonData = sendRequests(LOGIN_SESSION, self.URLS["uamtk"], data={'appid': 'otn'})
     logger.info(jsonData)
     result, msg = jsonStatus(jsonData, ["result_message", "newapptk"])
     if not result:
         return result, msg, None
     else:
         return result, msg, jsonData["newapptk"]
コード例 #2
0
ファイル: captcha.py プロジェクト: lltxwdk/ticket
    def check(self, results):
        formData = {
            'randCode': results,
            'rand': 'sjrand',
        }

        jsonResponse = sendRequests(LOGIN_SESSION,
                                    LOGIN_URL_MAPPING["other"]["captchaCheck"],
                                    data=formData)
        logger.info('other login captcha verify: %s' % jsonResponse)

        def verify(response):
            return response['status'] and self.success_code == response[
                'data']['result']

        v = verify(jsonResponse)
        return v, "Error" if not v else v
コード例 #3
0
ファイル: captcha.py プロジェクト: lltxwdk/ticket
 def check(self, results):
     paramsData = {'answer': results, 'rand': 'sjrand', 'login_site': 'E'}
     while True:
         try:
             json_response = sendRequests(
                 LOGIN_SESSION,
                 LOGIN_URL_MAPPING["normal"]["captchaCheck"],
                 data=paramsData)
             break
         except (ResponseCodeError, ResponseError):
             logger.error("提交验证码错误, 重新提交验证码验证")
             continue
     logger.info('验证码校验结果: %s' % json_response)
     status, msg = jsonStatus(json_response, [], ok_code=self.success_code)
     if not status:
         logger.error("验证码识别失败")
     return status, msg
コード例 #4
0
    def login(self):
        if not LOGIN_SESSION.cookies.get("RAIL_EXPIRATION") or \
           not LOGIN_SESSION.cookies.get("RAIL_DEVICEID"):
            status, msg = self.init()
            if not status:
                return status, msg

        captcha = Captcha("normal")
        status, msg = captcha.verify()
        if not status:
            logger.info("验证码校验失败")
            return status,msg

        payload = {
            'username': Config.train_account.user,
            'password': Config.train_account.pwd,
            'appid': 'otn',
            'answer': captcha.results
        }

        jsonResponse = sendRequests(LOGIN_SESSION, self.URLS['login'], data=payload)
        result, msg = jsonStatus(jsonResponse, [], '0')

        if not result:
            return (False, jsonResponse.get("result_message", None)) \
                if isinstance(jsonResponse, dict) else (False, '登录接口提交返回数据出现问题')

        self.passPortRedirect()
        result, msg, apptk = self.uamTk()

        if not result:
            logger.info(msg)
            return False, msg
        status, msg = self.uamAuthClient(apptk)
        return status, msg




          
コード例 #5
0
 def uamAuthClient(self, apptk):
     jsonResponse = sendRequests(LOGIN_SESSION, self.URLS['uamauthclient'], data={'tk': apptk})
     status, msg = jsonStatus(jsonResponse, ["username", "result_message"])
     if status:
         logger.info("欢迎 {0} 登录".format(jsonResponse["username"]))
     return status, msg
コード例 #6
0
 def passPortRedirect(self):
     sendRequests(LOGIN_SESSION, self.URLS["userLoginRedirect"])