diff --git a/webservice/manual_launch.py b/webservice/manual_launch.py index 18078b1ca390a0d61b724a51f2ae5a9e33b467a5..a5a53aa9f93ee8322231de145627923741b607b5 100644 --- a/webservice/manual_launch.py +++ b/webservice/manual_launch.py @@ -18,7 +18,7 @@ from rich.progress import ( TextColumn, TimeElapsedColumn, ) -from rich.prompt import Prompt +from rich.prompt import Confirm parser = argparse.ArgumentParser( description="Manually submit calibration jobs.", @@ -82,14 +82,17 @@ def get_bearer_token() -> str: return BEARER["access_token"] with Client() as client: - response = client.post( - f"{config['metadata-client']['token-url']}", - data={ - "grant_type": "client_credentials", - "client_id": config["metadata-client"]["user-id"], - "client_secret": config["metadata-client"]["user-secret"], - }, - ) + data = { + "grant_type": "client_credentials", + "client_id": config["metadata-client"]["user-id"], + "client_secret": config["metadata-client"]["user-secret"], + } + + # With a real user the scope must be set to public + if not str(config["metadata-client"]["user-email"]).endswith("example.com"): + data["scope"] = "public" + + response = client.post(f"{config['metadata-client']['token-url']}", data=data) data = response.json() @@ -192,9 +195,9 @@ def main( if not really: print("[yellow]`--really` flag missing, not submitting jobs") - if not noconfirm and not Prompt.ask( + if not noconfirm and not Confirm.ask( f"Submit [red bold]{len(requests)}[/red bold] jobs for proposal " - f"[bold]{proposal_no}[/bold]? [y/[bold]n[/bold]]", + f"[bold]{proposal_no}[/bold]?", default=False, ): print("[bold red]Aborted[/bold red]") @@ -212,7 +215,7 @@ def main( ) con = zmq.Context() socket = con.socket(zmq.REQ) - con = socket.connect("tcp://max-exfl-cal001:5555") + socket.connect("tcp://max-exfl-cal001:5555") if not really: # Fake socket for testing, just logs what would have been sent via ZMQ