Update user-list
This commit is contained in:
parent
22d140480d
commit
e9142a7f56
|
@ -72,21 +72,18 @@ def command_list(args):
|
||||||
"""List all users"""
|
"""List all users"""
|
||||||
# Module imports
|
# Module imports
|
||||||
from amanuensis.config import prepend, json_ro
|
from amanuensis.config import prepend, json_ro
|
||||||
|
from amanuensis.user import UserModel
|
||||||
|
|
||||||
# Perform command
|
# Perform command
|
||||||
user_dirs = os.listdir(prepend('user'))
|
|
||||||
users = []
|
users = []
|
||||||
for uid in user_dirs:
|
with json_ro('user', 'index.json') as index:
|
||||||
if uid == "index.json":
|
for username, uid in index.items():
|
||||||
continue
|
users.append(UserModel.by(uid=uid))
|
||||||
with json_ro('user', uid, 'config.json') as user:
|
|
||||||
users.append(user)
|
|
||||||
|
|
||||||
# Output
|
# Output
|
||||||
users.sort(key=lambda u: u['username'])
|
users.sort(key=lambda u: u.username)
|
||||||
for user in users:
|
for user in users:
|
||||||
print("{0} {1} ({2})".format(
|
print("{0.id} {0.displayname} ({0.username})".format(user))
|
||||||
user['uid'], user['displayname'], user['username']))
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +133,7 @@ def command_passwd(args):
|
||||||
# Verify arguments
|
# Verify arguments
|
||||||
pw = args.password or getpass.getpass("Password: ")
|
pw = args.password or getpass.getpass("Password: ")
|
||||||
|
|
||||||
# Perform commands
|
# Perform command
|
||||||
args.user.set_password(pw)
|
args.user.set_password(pw)
|
||||||
|
|
||||||
# Output
|
# Output
|
||||||
|
|
Loading…
Reference in New Issue