Skip to content
Snippets Groups Projects
Commit eeae9804 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

machines: detect empty data

parent 9a9129f7
No related branches found
No related tags found
No related merge requests found
...@@ -115,22 +115,25 @@ def get_parser() -> ArgumentParser: ...@@ -115,22 +115,25 @@ def get_parser() -> ArgumentParser:
if __name__ == "__main__": if __name__ == "__main__":
args = get_parser().parse_args() args = get_parser().parse_args()
machines_data = machines_ldap(**vars(args)) machines_data = machines_ldap(**vars(args))
machines_display(machines_data, args.sort_by) if not machines_data:
print() print("nothing was found.")
users_data = users_ldap() else:
for k, v in machines_data.items(): machines_display(machines_data, args.sort_by)
if not v["utilisateur"] or v["utilisateur"] not in users_data: print()
print(f"{k}: wrong user {v['utilisateur']}") users_data = users_ldap()
continue for k, v in machines_data.items():
user = users_data[v["utilisateur"]] if not v["utilisateur"] or v["utilisateur"] not in users_data:
if user["room"] != v["room"]: print(f"{k}: wrong user {v['utilisateur']}")
print(f"{k}: wrong user's room {user['room']} != {v['room']}") continue
if user["st"] in ["JAMAIS", "NON-PERTINENT"]: user = users_data[v["utilisateur"]]
continue if user["room"] != v["room"]:
d, m, y = (int(i) for i in user["st"].split("/")) print(f"{k}: wrong user's room {user['room']} != {v['room']}")
st = date(y, m, d) if user["st"] in ["JAMAIS", "NON-PERTINENT"]:
if v["datePeremption"] > st: continue
print( d, m, y = (int(i) for i in user["st"].split("/"))
f"{k}: wrong peremption for {user['uid']}: " st = date(y, m, d)
f"{v['datePeremption']:%d/%m/%Y} > {st:%d/%m/%Y}" if v["datePeremption"] > st:
) print(
f"{k}: wrong peremption for {user['uid']}: "
f"{v['datePeremption']:%d/%m/%Y} > {st:%d/%m/%Y}"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment