def alarm_contact_info_email_post(): """ Generate email with link to confirm. :return: """ # TODO: Authenticate Isadore Instance # TODO: Limit number of times can confirm? # TODO: Confirm expire date? # TODO: Implement info = db.get_info(email=email) oneday = datetime.timedelta(days=1) if info["email_verify"]: last_try_date = info["email_verify"]["last_try"] if datetime.datetime.now() - last_try_date < oneday: abort(400) confirm_code = hashlib.sha1() confirm_code.update(os.urandom(24)) confirm_code = confirm_code.hexdigest() email_verify = {"last_try": datetime.datetime.now(), "confirm_code": confirm_code} db.update_info(info_update=email_verify, email=email) urlparams = urllib.urlencode({"email": email, "confirm_code": email_verify["confirm_code"]}) msgtxt = twiml_messages.email_verify_txt % (urlparams, email_verify(["confirm_code"])) msghtml = twiml_messages.email_verify_html % (urlparams, urlparams, email_verify["confirm_code"]) messaging.sendEmail(toemail=email, fromemail='*****@*****.**', messageTXT=msgtxt, messageHTML=msghtml) return ('Sent', 204)
def enterInfo(self): """ Enter the info into the database """ self.result_list = [ self.ids['Q1'].text, self.ids['Q2'].text, self.ids['Q3'].text, self.ids['Q4'].text, self.ids['Q5'].text ] db.update_info(db_path, self.f_name, self.ids['Q1'].text, self.ids['Q2'].text, self.ids['Q3'].text, self.ids['Q4'].text, self.ids['Q5'].text)
def alarm_contact_info_confirm_voice(): """ Generate confirm code and send call voice phone number. :return: """ # TODO: Authenticate Isadore Instance # TODO: Limit number of times can confirm? # TODO: Confirm expire date? # TODO: Implement info = db.get_info(phone=phone) oneday = datetime.timedelta(days=1) if info["phone_verify"]: last_try_date = info["phone_verify"]["last_try"] if datetime.datetime.now() - last_try_date < oneday: abort(400) phone_verify = {"last_try": datetime.datetime.now(), "confirm_code": None} db.update_info(info_update=phone_verify, phone=phone) messaging.makeCall(phone, 'https://alarms.example.com/alarm_contact_info_phone/confirm/voice2') return ('Sent', 204)
def alarm_contact_confirm_sms_post(): """ Generate confirm code and send out confirm sms message. :return: """ # TODO: Authenticate Isadore Instance # TODO: Limit number of times can confirm? # TODO: Confirm expire date? # TODO: Implement info = db.get_info(phone=phone) oneday = datetime.timedelta(days=1) if info["phone_verify"]: last_try_date = info["phone_verify"]["last_try"] if datetime.datetime.now() - last_try_date < oneday: abort(400) phone_verify = {"last_try": datetime.datetime.now(), "confirm_code": random.randint(100000, 999999)} db.update_info(info_update=phone_verify, phone=phone) msg = twiml_messages.sms_verify % (phone_verify["confirm_code"]) messaging.sendTxt(phone, msg) return ('Sent', 204)
def post(self): uid = int(self.get_secure_cookie('user')) action = self.get_argument('action') if action == 'info': address = self.get_argument('address') account = self.get_argument('account') res = db.update_info(address, account, uid) elif action == 'icon': icon = self.request.files.get('icon') icon = icon[0] res = db.update_icon(uid, icon) elif action == 'pwd': newPwd = self.get_argument('new') res = db.update_pwd(newPwd, uid) if res == 1: warning = 'updata success' else: warning = 'update fail' self.redirect('/config?warning=%s' % warning)
book_item = { 'book_name': book_name, 'book_id': book_id, 'book_info': book_info, 'star': star, 'eval_num': eval_num, 'img_url': img_url, 'mark': mark } if check_book(book_id): save_book(book_item) print(f'保存{tag} {book_name} {book_id} {next_url}') else: print(f'{tag} {book_name} {book_id} 已存在') update_info(book_id, book_info) continue if next_url is not None: time.sleep(random.randint(3, 10)) if next_url.find('start=1000') != -1: url = False else: next_url = base_url + next_url url = next_url time.sleep(random.randint(3, 10)) else: print('没有下一页了,轮到下一个tag') url = False except Exception as e: print('出错, ', e) continue