Esempio n. 1
0
 def callback(resp):
     path = self.checkimg_path
     fp = open(path, 'wb')
     fp.write(resp.body)
     fp.close()
     if UPLOAD_CHECKIMG:
         logging.info(u"正在上传验证码..")
         res = upload_file("check.jpg", path)
         path = res.read()
     check_code = ""
     if not HTTP_CHECKIMG:
         print u"验证图片: {0}".format(path)
         while not check_code:
             check_code = raw_input("输入验证图片上的验证码: ")
         ccode = check_code.strip().lower()
         self.check_code = ccode
         pwd = self.handle_pwd(r, ccode.upper(), uin)
         self.before_login(pwd)
     else:
         if os.path.exists("wait"):
             os.remove("wait")
         logging.info(u"请打开http://{0}:{1} 提交验证码"
                      .format(HTTP_LISTEN, HTTP_PORT))
         self.handler.r = r
         self.handler.uin = uin
         self.handler.next_callback = self.before_login
         self.require_check_time = time.time()
         if EMAIL_NOTICE:
             if send_notice_email():
                 logging.info(u"已成功发送邮件提醒")
             else:
                 logging.warn(u"发送邮件提醒失败")
Esempio n. 2
0
    def handle_verify_code(self, path, r, uin):
        self.verify_img_path = path

        if getattr(config, "UPLOAD_CHECKIMG", False):
            logger.info(u"正在上传验证码...")
            res = self.hub.upload_file("check.jpg", self.hub.checkimg_path)
            logger.info(u"验证码已上传, 地址为: {0}".format(res.read()))

        if getattr(config, "HTTP_CHECKIMG", False):
            if hasattr(self, "handler") and self.handler:
                self.handler.r = r
                self.handler.uin = uin

            logger.info("请打开 http://{0}:{1} 输入验证码"
                        .format(config.HTTP_LISTEN, config.HTTP_PORT))
            if getattr(config, "EMAIL_NOTICE", False):
                if send_notice_email():
                    logger.info("发送通知邮件成功")
                else:
                    logger.warning("发送通知邮件失败")
        else:
            logger.info(u"验证码本地路径为: {0}".format(self.hub.checkimg_path))
            check_code = None
            while not check_code:
                check_code = raw_input("输入验证码: ")
            self.enter_verify_code(check_code, r, uin)
Esempio n. 3
0
 def callback(resp):
     path = self.checkimg_path
     fp = open(path, "wb")
     fp.write(resp.body)
     fp.close()
     if UPLOAD_CHECKIMG:
         logging.info(u"正在上传验证码..")
         res = upload_file("check.jpg", path)
         path = res.read()
     check_code = ""
     if not HTTP_CHECKIMG:
         print u"验证图片: {0}".format(path)
         while not check_code:
             check_code = raw_input("输入验证图片上的验证码: ")
         ccode = check_code.strip().lower()
         self.check_code = ccode
         pwd = self.handle_pwd(r, ccode.upper(), uin)
         self.before_login(pwd)
     else:
         if os.path.exists("wait"):
             os.remove("wait")
         logging.info(u"请打开http://{0}:{1} 提交验证码".format(HTTP_LISTEN, HTTP_PORT))
         self.handler.r = r
         self.handler.uin = uin
         self.handler.next_callback = self.before_login
         self.require_check_time = time.time()
         if EMAIL_NOTICE:
             if send_notice_email():
                 logging.info(u"已成功发送邮件提醒")
             else:
                 logging.warn(u"发送邮件提醒失败")