我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用flask_script.prompt_pass()。
def create(email, password): 'Create User Account' if email is None: email = prompt('Email') if password is None: password = prompt_pass('Password') try: NodeDefender.db.user.create(email) NodeDefender.db.user.set_password(email, password) NodeDefender.db.user.enable(email) except ValueError: print("User already present") return print("User {} Successfully added!".format(email))
def run(self): username = prompt("??????") with app.app_context(): g_db = db.session while True: old_user = models.User.query.filter_by(username=username).first() if old_user: print "?????" username = prompt("????????") else: break nickname = prompt("?????") while True: password = prompt_pass("?????") confirm_password = prompt_pass("??????") if password != confirm_password: print "????, ???????" continue break super_user = models.User(username, nickname, password, "", is_superuser=True) g_db.add(super_user) g_db.commit() print super_user.create_date.strftime("%Y%m%d%H%M%S") print "???????%s??" % username
def run(self): email = prompt('Email Address') password = prompt_pass('Password') if password == prompt_pass('Confirm Password'): user = app.user_datastore.create_user(email=email, password=encrypt_password(password)) app.user_datastore.activate_user(user) db.session.commit() self.stdout.write('New User Created, <{id} : {email}>'.format(id=user.id, email=user.email)) else: self.stderr.write('Passwords did not match!')
def read_pwd(): password = prompt_pass('Password') again = prompt_pass('Repeat password') if password != again: raise InvalidCommand('Repeated password differs!') return password