From ec88dffe4fea711c7165fb2da8d5b66dd8849645 Mon Sep 17 00:00:00 2001 From: wenxianping <931128603@qq.com> Date: Thu, 25 Jan 2018 21:39:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8B=E8=BD=BD=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init/login.py | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/init/login.py b/init/login.py index 74b2170..9a045c0 100644 --- a/init/login.py +++ b/init/login.py @@ -45,28 +45,31 @@ class GoLogin: codeimgUrl = code_url img_path = './tkcode' result = self.httpClint.send(codeimgUrl, is_logger=False) - try: - open(img_path, 'wb').write(result) - if self.is_aotu_code: - if self.aotu_code_type == 1: - return DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"], img_path).main() - elif self.aotu_code_type == 2: - rc = RClient(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"]) - im = open('./tkcode', 'rb').read() - Result = rc.rk_create(im, 6113) - if "Result" in Result: - return self.codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False) - else: - if "Error" in Result and Result["Error"]: - print Result["Error"] - return "" - else: - img = Image.open('./tkcode') - img.show() - return self.codexy() - except OSError as e: - print (e) - return "" + if "message" in result: + print("验证码下载失败,正在重试") + else: + try: + open(img_path, 'wb').write(result) + if self.is_aotu_code: + if self.aotu_code_type == 1: + return DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"], img_path).main() + elif self.aotu_code_type == 2: + rc = RClient(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"]) + im = open('./tkcode', 'rb').read() + Result = rc.rk_create(im, 6113) + if "Result" in Result: + return self.codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False) + else: + if "Error" in Result and Result["Error"]: + print Result["Error"] + return "" + else: + img = Image.open('./tkcode') + img.show() + return self.codexy() + except OSError as e: + print (e) + return "" def codexy(self, Ofset=None, is_raw_input=True): """