Last active
February 6, 2022 19:55
-
-
Save Apocryphon-X/eb1804146c63f496aedb25a09c83faa3 to your computer and use it in GitHub Desktop.
Tool to find out which users connected (or not) to an omegaUp contest.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| # Copyright (c) 2022 @Apocryphon (Dante Mendoza Leyva). | |
| # All rights reserved. | |
| import omegaup.api | |
| import sys | |
| class Client: | |
| def __init__(self, api_token): | |
| self.ctx = omegaup.api.Client(api_token=api_token) | |
| def get_inactive_users(self, contest_alias): | |
| for user in self.ctx.contest.users(contest_alias=contest_alias)["users"]: | |
| username = user["username"] | |
| if user["access_time"] is None: | |
| yield self.ctx.user.profile(username=username) | |
| def get_active_users(self, contest_alias): | |
| for user in self.ctx.contest.users(contest_alias=contest_alias)["users"]: | |
| username = user["username"] | |
| if user["access_time"] is not None: | |
| yield self.ctx.user.profile(username=username) | |
| def main(): | |
| ctx = Client("INSERT_API_TOKEN_HERE") | |
| fetch_mode = "active" | |
| if len(sys.argv) >= 3: | |
| fetch_mode = sys.argv[2] | |
| if fetch_mode == "active": | |
| api_dict = ctx.get_active_users(sys.argv[1]) | |
| else: | |
| api_dict = ctx.get_inactive_users(sys.argv[1]) | |
| for user in api_dict: | |
| print(f'- Usuario: {user["username"]}') | |
| print(f'- Nombre: {user["name"]}') | |
| print(f'- Escuela: {user["school"]}') | |
| print("-" * 20) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment