Skip to content

Commit

Permalink
Dont exit on fail. Handle when homeserver_url doesn't have schema
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-russell committed Aug 5, 2024
1 parent 45aceac commit a35fc70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions fractal/cli/controllers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def login(
MatrixHomeserver,
)

if not homeserver_url.startswith(("http://", "https://")):
homeserver_url = f"https://{homeserver_url}"

try:
hs = MatrixHomeserver.objects.get(url=homeserver_url)
MatrixCredentials.objects.create(
Expand Down
6 changes: 3 additions & 3 deletions fractal/cli/controllers/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def _register_local(
] # type: ignore
except Exception as e:
print(f"No synapse server running locally: {e}.")
exit(1)
raise Exception(f"No synapse server running locally: {e}")

username = parse_matrix_id(matrix_id)[0]
if not homeserver_url:
Expand All @@ -47,9 +47,9 @@ async def _register_local(
)
if result.exit_code != 0:
print(result.output.decode("utf-8"))
exit(1)
raise Exception(f"Failed to create user: {result.output.decode('utf-8')}")

if not homeserver_url.startswith("http://") or homeserver_url.startswith("https://"):
if not homeserver_url.startswith(("http://", "https://")):
homeserver_url = f"https://{homeserver_url}"

async with MatrixClient(homeserver_url) as client:
Expand Down

0 comments on commit a35fc70

Please sign in to comment.