checks that index array is populated before considering a user 'active'
This commit is contained in:
parent
893d8b6413
commit
3f45ac68d8
9
slog.py
9
slog.py
|
@ -19,14 +19,19 @@ class Utils:
|
|||
return str(datetime.datetime.utcnow())
|
||||
|
||||
def list_active_users():
|
||||
"""returns a list of all users having a slog index"""
|
||||
"""returns a list of all users having a (populated) slog index"""
|
||||
active_users = []
|
||||
for homedir in os.listdir("/home/"):
|
||||
if "." in homedir:
|
||||
continue
|
||||
try:
|
||||
if "index" in os.listdir(f"/home/{homedir}/.slog/"):
|
||||
active_users.append(homedir)
|
||||
# check if index is not empty
|
||||
with open(f"/home/{homedir}/.slog/index", "r", encoding="utf-8") as indexfile:
|
||||
index_data = json.loads(indexfile.read())
|
||||
|
||||
if len(index_data) != 0:
|
||||
active_users.append(homedir)
|
||||
except (FileNotFoundError, PermissionError):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue