def userlist(): """ List all users""" try: for user in User.select(): print user.login except Exception, e: print "Unexpected error: %s" % e
def useradd(login=None, count=5): """ Add a user""" secret = random_base32() if login is None: login = prompt("Login: "******"Scan QR: http://2qr.ru/otpauth://totp/%(issuer)s:%(login)s?secret=%(secret)s&issuer=%(issuer)s" % ( {'issuer': issuer, 'login': login, 'secret': secret}) print "Or add manually SECRET KEY: %s" % secret print "Emergency codes: %s" % emergency_list except Exception, e: print "Unexpected error: %s" % e
def userdel(login=None): """ Remove a user""" if login is None: login = prompt("Login: "******"User has been deleted" except User.DoesNotExist: print "User not found" except Exception, e: print "Unexpected error: %s" % e
def renew(login=None, count=5): """ Renew a emergency codes""" if login is None: login = prompt("Login: "******"User not found" except Exception, e: print "Unexpected error: %s" % e