cubevis 1.0.50__py3-none-any.whl → 1.0.56__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cubevis/__version__.py +1 -1
- cubevis/bokeh/sources/transport/__init__.py +73 -33
- {cubevis-1.0.50.dist-info → cubevis-1.0.56.dist-info}/METADATA +1 -1
- {cubevis-1.0.50.dist-info → cubevis-1.0.56.dist-info}/RECORD +6 -6
- {cubevis-1.0.50.dist-info → cubevis-1.0.56.dist-info}/WHEEL +0 -0
- {cubevis-1.0.50.dist-info → cubevis-1.0.56.dist-info}/licenses/LICENSE +0 -0
cubevis/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '1.0.
|
|
1
|
+
__version__ = '1.0.56'
|
|
@@ -1,51 +1,91 @@
|
|
|
1
|
+
from cubevis.utils import is_colab
|
|
1
2
|
import websockets
|
|
2
3
|
import http
|
|
3
|
-
from websockets.
|
|
4
|
+
from websockets.http11 import Response # Available in newer versions
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
log_path = "/content/package_debug.txt"
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
# Modern implementation (v14+)
|
|
10
|
+
from websockets.server import ServerConnection as BaseConnection
|
|
11
|
+
IS_LEGACY = False
|
|
12
|
+
except ImportError:
|
|
13
|
+
# Legacy implementation (<v14)
|
|
14
|
+
from websockets.server import WebSocketServerProtocol as BaseConnection
|
|
15
|
+
IS_LEGACY = True
|
|
16
|
+
|
|
17
|
+
class ColabWebSocketServerProtocol(BaseConnection):
|
|
18
|
+
def __init__(self, *args, **kwargs):
|
|
19
|
+
with open(log_path, "a") as f:
|
|
20
|
+
print(f"ColabWebSocketServerProtocol.__init__ Initializing Protocol with args={args} kwargs={kwargs}", file=f)
|
|
21
|
+
super().__init__(*args, **kwargs)
|
|
22
|
+
|
|
23
|
+
async def process_request(self, *args):
|
|
24
|
+
"""Handle both old (path, headers) and new (request) signatures."""
|
|
25
|
+
if IS_LEGACY:
|
|
26
|
+
path, request_headers = args
|
|
27
|
+
request_method = getattr(self, "request_method", "GET")
|
|
28
|
+
else:
|
|
29
|
+
# Modern version passes (request) as the only arg
|
|
30
|
+
request = args[0]
|
|
31
|
+
path = request.path
|
|
32
|
+
request_headers = request.headers
|
|
33
|
+
request_method = request.method
|
|
8
34
|
|
|
9
|
-
|
|
10
|
-
|
|
35
|
+
with open(log_path, "a") as f:
|
|
36
|
+
print(f"ColabWebSocketServerProtocol.process_request: request_header={request_header} request_method={request_method}", file=f)
|
|
37
|
+
|
|
38
|
+
# Logic for CORS/OPTIONS remains similar, but response format differs
|
|
39
|
+
is_upgrade = "upgrade" in request_headers.get("Connection", "").lower()
|
|
11
40
|
|
|
12
41
|
if not is_upgrade:
|
|
13
|
-
response_headers = Headers()
|
|
14
42
|
origin = request_headers.get("Origin")
|
|
15
|
-
|
|
43
|
+
headers = {"Content-Type": "text/plain", "Connection": "close"}
|
|
16
44
|
if origin:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
response_headers["Access-Control-Allow-Headers"] = "Content-Type, Authorization"
|
|
45
|
+
headers.update({
|
|
46
|
+
"Access-Control-Allow-Origin": origin,
|
|
47
|
+
"Access-Control-Allow-Credentials": "true",
|
|
48
|
+
})
|
|
22
49
|
|
|
23
|
-
response_headers["Content-Type"] = "text/plain"
|
|
24
|
-
response_headers["Connection"] = "close"
|
|
25
|
-
|
|
26
|
-
# If it is an OPTIONS request, return 204 No Content immediately
|
|
27
50
|
if request_method == "OPTIONS":
|
|
28
|
-
return http.HTTPStatus.NO_CONTENT,
|
|
29
|
-
|
|
30
|
-
# If it is a GET request (the priming fetch), return 200 OK
|
|
51
|
+
return self._format_response(http.HTTPStatus.NO_CONTENT, headers, b"")
|
|
31
52
|
if request_method == "GET":
|
|
32
|
-
|
|
53
|
+
return self._format_response(http.HTTPStatus.OK, headers, b"OK")
|
|
33
54
|
|
|
34
|
-
# Proceed with standard WS handshake
|
|
35
55
|
return None
|
|
36
56
|
|
|
57
|
+
def _format_response(self, status, headers, body):
|
|
58
|
+
"""Helper to return the correct type based on version."""
|
|
59
|
+
if IS_LEGACY:
|
|
60
|
+
# Legacy expects (status, headers, body)
|
|
61
|
+
return status, headers, body
|
|
62
|
+
else:
|
|
63
|
+
# Modern expects a Response object or self.respond call
|
|
64
|
+
return self.respond(status, body, headers)
|
|
65
|
+
|
|
37
66
|
def create_ws_server(callback, ip_address, port):
|
|
38
67
|
"""
|
|
39
|
-
Uniform wrapper for creating a WebSocket server.
|
|
68
|
+
Uniform wrapper for creating a WebSocket server supporting all versions.
|
|
40
69
|
"""
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
# Prepare base arguments
|
|
71
|
+
kwargs = {
|
|
72
|
+
"ws_handler": callback, # In newer versions 'callback' is the first positional or 'ws_handler'
|
|
73
|
+
"host": "0.0.0.0" if is_colab() else ip_address,
|
|
74
|
+
"port": port,
|
|
75
|
+
"origins": None
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# Inject the custom protocol class using the correct version-specific key
|
|
79
|
+
if IS_LEGACY:
|
|
80
|
+
kwargs["create_protocol"] = ColabWebSocketServerProtocol
|
|
50
81
|
else:
|
|
51
|
-
|
|
82
|
+
kwargs["create_connection"] = ColabWebSocketServerProtocol
|
|
83
|
+
|
|
84
|
+
if is_colab():
|
|
85
|
+
with open(log_path, "a") as f:
|
|
86
|
+
f.write(f"Websocket startup: {kwargs['host']}:{port}\n")
|
|
87
|
+
f.write(f"Using class: {ColabWebSocketServerProtocol.__name__}\n")
|
|
88
|
+
f.write(f"Version mode: {'Legacy' if IS_LEGACY else 'Modern'}\n")
|
|
89
|
+
|
|
90
|
+
# Use **kwargs to bypass signature differences between library versions
|
|
91
|
+
return websockets.serve(**kwargs)
|
|
@@ -55,7 +55,7 @@ cubevis/bokeh/sources/_image_data_source.py,sha256=5sEWdfqoMk08HQ0JWg6bHJ34dWmph
|
|
|
55
55
|
cubevis/bokeh/sources/_image_pipe.py,sha256=pQ05VynLuJbedGja7aXDbVXFkOYbdMceOuOEj-QuluQ,28692
|
|
56
56
|
cubevis/bokeh/sources/_spectra_data_source.py,sha256=qL1IOjSefWlycaqS4Pz5EHwg-1EwCVmNwxysP9lxDeM,2451
|
|
57
57
|
cubevis/bokeh/sources/_updatable_data_source.py,sha256=mjV1u3ZpRE5KCHtZA4tV1JxMf09Ifh4elSWlf6jNXQo,10985
|
|
58
|
-
cubevis/bokeh/sources/transport/__init__.py,sha256=
|
|
58
|
+
cubevis/bokeh/sources/transport/__init__.py,sha256=uUGjgekjD5zpV4R3YiNO0q-txZb4OTjIaxL9vcq-XKE,3617
|
|
59
59
|
cubevis/bokeh/state/__init__.py,sha256=PZ2-7I5XHkMTc-vguYarYCYSJ1pKyEYnSAFa-n8AuTE,1826
|
|
60
60
|
cubevis/bokeh/state/_current.py,sha256=owPMQTme5SBYvIVP3Q4y9hpWHPmyhLHsS2O0sCAAqqo,967
|
|
61
61
|
cubevis/bokeh/state/_initialize.py,sha256=eX06VU1KyTEyoFiAdPBA_XucCKFEgNImv1qVXfXaIkE,12881
|
|
@@ -128,8 +128,8 @@ cubevis/utils/_pkgs.py,sha256=mu2CCzndmJZYP81UkFhxveW_CisWLUvagJVolHOEVgM,2294
|
|
|
128
128
|
cubevis/utils/_regions.py,sha256=TdAg4ZUUyhg3nFmX9_KLboqmc0LkyOdEW8M1WDR5Udk,1669
|
|
129
129
|
cubevis/utils/_static.py,sha256=rN-sqXNqQ5R2M3wmPHU1GPP5OTyyWQlUPRuimCrht-g,2347
|
|
130
130
|
cubevis/utils/_tiles.py,sha256=A9W1X61VOhBMTOKXVajzOIoiV2FBdO5N2SFB9SUpDOo,7336
|
|
131
|
-
cubevis/__version__.py,sha256=
|
|
132
|
-
cubevis-1.0.
|
|
133
|
-
cubevis-1.0.
|
|
134
|
-
cubevis-1.0.
|
|
135
|
-
cubevis-1.0.
|
|
131
|
+
cubevis/__version__.py,sha256=lqlVQQ_gocyEuutkglCnPPwmDKRFeMb8iiOua0uSROg,22
|
|
132
|
+
cubevis-1.0.56.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
|
|
133
|
+
cubevis-1.0.56.dist-info/METADATA,sha256=XSNwuSVQWfJiNvGq-XeMzZcaAyr84PRQOC0sIBCGRtY,2632
|
|
134
|
+
cubevis-1.0.56.dist-info/licenses/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
|
135
|
+
cubevis-1.0.56.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|