Add mentor query
This commit is contained in:
parent
65b79bb3a4
commit
7e94a15a05
@ -27,19 +27,11 @@ Best regards,
|
|||||||
|
|
||||||
url = "https://infinity-users.projet-horizon.fr/index.php"
|
url = "https://infinity-users.projet-horizon.fr/index.php"
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
def main():
|
||||||
|
pass
|
||||||
|
|
||||||
@click.command()
|
def get_data():
|
||||||
@click.argument("to_bug")# help="The login of the user to bug")
|
|
||||||
def main(to_bug):
|
|
||||||
"""Bug a user on the Infinity platform.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
to_bug (str): The login of the user to bug.
|
|
||||||
"""
|
|
||||||
if to_bug is None:
|
|
||||||
print("Please provide the login of the user to bug")
|
|
||||||
raise SystemExit(1)
|
|
||||||
|
|
||||||
with requests.session() as s:
|
with requests.session() as s:
|
||||||
response = s.post(url, data={"authpw": "astrorizon"})
|
response = s.post(url, data={"authpw": "astrorizon"})
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
@ -86,7 +78,35 @@ def main(to_bug):
|
|||||||
|
|
||||||
# Print the parsed data
|
# Print the parsed data
|
||||||
mapped_login = {user["login"]: user for user in users_tbl}
|
mapped_login = {user["login"]: user for user in users_tbl}
|
||||||
|
return mapped_login
|
||||||
|
|
||||||
|
@main.command()
|
||||||
|
@click.argument("user")
|
||||||
|
def sponsor(user):
|
||||||
|
if user is None:
|
||||||
|
print("Please provide the login of the user to bug")
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
mapped_login = get_data()
|
||||||
|
|
||||||
|
u = mapped_login[user]
|
||||||
|
|
||||||
|
print(u["mentor"])
|
||||||
|
print(mapped_login[u["mentor"]]["name"])
|
||||||
|
|
||||||
|
@main.command()
|
||||||
|
@click.argument("to_bug")# help="The login of the user to bug")
|
||||||
|
def go(to_bug):
|
||||||
|
"""Bug a user on the Infinity platform.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
to_bug (str): The login of the user to bug.
|
||||||
|
"""
|
||||||
|
if to_bug is None:
|
||||||
|
print("Please provide the login of the user to bug")
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
mapped_login = get_data()
|
||||||
|
|
||||||
# Get the current unix login of the user using python os
|
# Get the current unix login of the user using python os
|
||||||
current_login = os.getlogin()
|
current_login = os.getlogin()
|
||||||
@ -114,7 +134,6 @@ def main(to_bug):
|
|||||||
msg["Subject"] = "Your usage of Infinity nodes"
|
msg["Subject"] = "Your usage of Infinity nodes"
|
||||||
msg.attach(MIMEText(email_body, "plain"))
|
msg.attach(MIMEText(email_body, "plain"))
|
||||||
|
|
||||||
|
|
||||||
text = msg.as_string()
|
text = msg.as_string()
|
||||||
print(textwrap.dedent(f"""
|
print(textwrap.dedent(f"""
|
||||||
Here is the draft of the email that is going to be sent:
|
Here is the draft of the email that is going to be sent:
|
||||||
|
Loading…
Reference in New Issue
Block a user