Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/murfey/client/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
If the version number is outside the allowed range then this can trigger
an update on the client, and in that case will terminate the process.
"""
proxy_path = api_base.path.rstrip("/")

Check warning on line 18 in src/murfey/client/update.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/update.py#L18

Added line #L18 was not covered by tests
version_check_url = api_base._replace(
path="/version", query=f"client_version={murfey.__version__}"
path=f"{proxy_path}/version/", query=f"client_version={murfey.__version__}"
)
server_reply = requests.get(version_check_url.geturl())
if server_reply.status_code != 200:
Expand Down Expand Up @@ -59,6 +60,7 @@
Return 'true' on success and 'false' on error."""

assert api_base.hostname is not None
proxy_path = api_base.path.rstrip("/")

Check warning on line 63 in src/murfey/client/update.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/update.py#L63

Added line #L63 was not covered by tests
result = subprocess.run(
[
sys.executable,
Expand All @@ -67,7 +69,7 @@
"--trusted-host",
api_base.hostname,
"-i",
api_base._replace(path="/pypi", query="").geturl(),
api_base._replace(path=f"{proxy_path}/pypi", query="").geturl(),
f"murfey[client]=={version}",
]
)
Expand Down
14 changes: 11 additions & 3 deletions src/murfey/client/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,24 @@
self.id = uuid.uuid4() if id is None else id
log.info(f"Opening websocket connection for Client {self.id}")
websocket.enableTrace(True)
url = urllib.parse.urlparse(server)._replace(scheme="ws", path="")

# Parse server URL and get proxy path used, if any
url = urllib.parse.urlparse(server)._replace(scheme="ws")
proxy_path = url.path.rstrip("/")

Check warning on line 31 in src/murfey/client/websocket.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/websocket.py#L30-L31

Added lines #L30 - L31 were not covered by tests

self._address = url.geturl()
self._alive = True
self._ready = False
self._send_queue: queue.Queue[Optional[str]] = queue.Queue()
self._receive_queue: queue.Queue[Optional[str]] = queue.Queue()

# Construct the websocket URL
# Prepend the proxy path to the new URL path
# It will evaluate to "" if nothing's there, and starts with "/" if present
ws_url = (
url._replace(path=f"/ws/test/{self.id}").geturl()
url._replace(path=f"{proxy_path}/ws/test/{self.id}").geturl()
if register_client
else url._replace(path=f"/ws/connect/{self.id}").geturl()
else url._replace(path=f"{proxy_path}/ws/connect/{self.id}").geturl()
)
self._ws = websocket.WebSocketApp(
ws_url,
Expand Down