Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions fedn/cli/project_cmd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys

import click
import requests
Expand Down Expand Up @@ -164,19 +165,22 @@ def update_project(ctx, id: str = None, protocol: str = None, host: str = None):
response = get_response(protocol=protocol, host=host, port=None, endpoint=f"projects/{id}", token=None, headers={}, usr_api=studio_api, usr_token=False)
if response.status_code == 200:
url = get_api_url(protocol=protocol, host=host, port=None, endpoint="projects/update", usr_api=studio_api)
headers = {"Content-Type": "application/x-www-form-urlencoded"}

# headers = {"Content-Type": "application/x-www-form-urlencoded"}
headers = {}
_token = get_token(None, True)

if _token:
headers["Authorization"] = _token

# Call the authentication API
try:
requests.post(url, data={"slug": id}, headers=headers)
except requests.exceptions.RequestException as e:
click.secho(str(e), fg="red")
click.secho(f"Project with id '{id}' is up-to-date.", fg="green")
response = requests.post(url, data={"slug": id}, headers=headers)
if response.status_code == 200:
click.secho(f"Project with slug {id} is now updated.", fg="green")
else:
click.secho(f"Unexpected error: {response.status_code}", fg="red")
except requests.exceptions.RequestException:
sys.exit(1)
else:
click.secho(f"Unexpected error: {response.status_code}", fg="red")

Expand Down
Loading