cubevis 1.0.52__py3-none-any.whl → 1.0.57__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 +66 -42
- {cubevis-1.0.52.dist-info → cubevis-1.0.57.dist-info}/METADATA +1 -1
- {cubevis-1.0.52.dist-info → cubevis-1.0.57.dist-info}/RECORD +6 -6
- {cubevis-1.0.52.dist-info → cubevis-1.0.57.dist-info}/WHEEL +0 -0
- {cubevis-1.0.52.dist-info → cubevis-1.0.57.dist-info}/licenses/LICENSE +0 -0
cubevis/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '1.0.
|
|
1
|
+
__version__ = '1.0.57'
|
|
@@ -1,56 +1,80 @@
|
|
|
1
|
+
from cubevis.utils import is_colab
|
|
1
2
|
import websockets
|
|
2
3
|
import http
|
|
3
|
-
|
|
4
|
+
import asyncio
|
|
5
|
+
try:
|
|
6
|
+
from websockets.http11 import Response
|
|
7
|
+
except ImportError:
|
|
8
|
+
Response = None # Fallback for very old versions
|
|
4
9
|
|
|
5
10
|
log_path = "/content/package_debug.txt"
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
try:
|
|
13
|
+
from websockets.server import ServerConnection as BaseConnection
|
|
14
|
+
IS_LEGACY = False
|
|
15
|
+
except ImportError:
|
|
16
|
+
from websockets.server import WebSocketServerProtocol as BaseConnection
|
|
17
|
+
IS_LEGACY = True
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
def universal_process_request(*args):
|
|
20
|
+
"""
|
|
21
|
+
Handles CORS priming.
|
|
22
|
+
Legacy signature: (path, request_headers)
|
|
23
|
+
Modern signature: (request)
|
|
24
|
+
"""
|
|
25
|
+
if IS_LEGACY:
|
|
26
|
+
# Legacy passes: (path, headers)
|
|
27
|
+
path, headers = args[0], args[1]
|
|
28
|
+
method = "GET"
|
|
29
|
+
else:
|
|
30
|
+
request = args[0]
|
|
31
|
+
path, headers, method = request.path, request.headers, request.method
|
|
15
32
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
origin = request_headers.get("Origin")
|
|
33
|
+
with open(log_path, "a") as f:
|
|
34
|
+
f.write(f"Top-level process_request: {method} {path}\n")
|
|
19
35
|
|
|
20
|
-
|
|
21
|
-
response_headers["Access-Control-Allow-Origin"] = origin
|
|
22
|
-
response_headers["Access-Control-Allow-Credentials"] = "true"
|
|
23
|
-
# Add necessary headers for the OPTIONS preflight response
|
|
24
|
-
response_headers["Access-Control-Allow-Methods"] = "GET, OPTIONS"
|
|
25
|
-
response_headers["Access-Control-Allow-Headers"] = "Content-Type, Authorization"
|
|
36
|
+
is_upgrade = "upgrade" in headers.get("Connection", "").lower()
|
|
26
37
|
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
if not is_upgrade:
|
|
39
|
+
origin = headers.get("Origin", "*")
|
|
40
|
+
resp_headers = {
|
|
41
|
+
"Content-Type": "text/plain",
|
|
42
|
+
"Connection": "close",
|
|
43
|
+
"Access-Control-Allow-Origin": origin,
|
|
44
|
+
"Access-Control-Allow-Credentials": "true",
|
|
45
|
+
"Access-Control-Allow-Methods": "GET, OPTIONS, POST",
|
|
46
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
|
47
|
+
}
|
|
29
48
|
|
|
30
|
-
|
|
31
|
-
if
|
|
32
|
-
return http.HTTPStatus.NO_CONTENT, response_headers, b"" # 204 Status and empty body
|
|
49
|
+
if method == "OPTIONS":
|
|
50
|
+
return (http.HTTPStatus.NO_CONTENT, resp_headers, b"") if IS_LEGACY else Response(http.HTTPStatus.NO_CONTENT, "No Content", resp_headers)
|
|
33
51
|
|
|
34
|
-
|
|
35
|
-
if
|
|
36
|
-
return http.HTTPStatus.OK, response_headers, b"OK"
|
|
52
|
+
if method == "GET":
|
|
53
|
+
return (http.HTTPStatus.OK, resp_headers, b"OK") if IS_LEGACY else Response(http.HTTPStatus.OK, "OK", resp_headers)
|
|
37
54
|
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
return None
|
|
56
|
+
|
|
57
|
+
class ColabWebSocketServerProtocol(BaseConnection):
|
|
58
|
+
def __init__(self, *args, **kwargs):
|
|
59
|
+
with open(log_path, "a") as f:
|
|
60
|
+
f.write(f"ColabWebSocketServerProtocol.__init__ constructed\n")
|
|
61
|
+
super().__init__(*args, **kwargs)
|
|
40
62
|
|
|
41
63
|
def create_ws_server(callback, ip_address, port):
|
|
42
|
-
""
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
host = "0.0.0.0" if is_colab() else ip_address
|
|
65
|
+
|
|
66
|
+
# Pass everything. websockets.serve ignores unknown kwargs.
|
|
67
|
+
conf = {
|
|
68
|
+
"host": host,
|
|
69
|
+
"port": port,
|
|
70
|
+
"origins": None,
|
|
71
|
+
"process_request": universal_process_request,
|
|
72
|
+
"create_connection": ColabWebSocketServerProtocol,
|
|
73
|
+
"create_protocol": ColabWebSocketServerProtocol
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if is_colab():
|
|
77
|
+
with open(log_path, "a") as f:
|
|
78
|
+
f.write(f"Websocket startup: {host}:{port} | Mode: {'Legacy' if IS_LEGACY else 'Modern'}\n")
|
|
79
|
+
|
|
80
|
+
return websockets.serve(callback, **conf)
|
|
@@ -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=3GndkyA6IjBpzmyTdWcv57wjIhaWbwdw4S7YRCmPf_g,2711
|
|
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=EUC4hHKVVCOux1CoHox94dqZjOBLxEP5FyomwB3-pmo,22
|
|
132
|
+
cubevis-1.0.57.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
|
|
133
|
+
cubevis-1.0.57.dist-info/METADATA,sha256=p1UD-wQzS8TN3K6wX6jc-oQIDVPJI4TMy5tclx16IrE,2632
|
|
134
|
+
cubevis-1.0.57.dist-info/licenses/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
|
135
|
+
cubevis-1.0.57.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|