ocp-vscode 2.3.1__tar.gz → 2.3.2__tar.gz
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.
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/PKG-INFO +2 -2
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/README.md +8 -4
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode/__init__.py +1 -1
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode/comms.py +11 -5
- ocp_vscode-2.3.2/ocp_vscode/daemonize.py +199 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode.egg-info/PKG-INFO +2 -2
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode.egg-info/SOURCES.txt +1 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode.egg-info/requires.txt +1 -1
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/setup.cfg +1 -1
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/setup.py +2 -2
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/LICENSE +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode/animation.py +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode/backend.py +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode/build123d.py +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode/colors.py +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode/config.py +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode/show.py +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode/state.py +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode.egg-info/dependency_links.txt +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode.egg-info/not-zip-safe +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/ocp_vscode.egg-info/top_level.txt +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/test/test_for_backend.py +0 -0
- {ocp_vscode-2.3.1 → ocp_vscode-2.3.2}/test/testextension.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ocp_vscode
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.2
|
|
4
4
|
Summary: OCP CAD Viewer for VSCode
|
|
5
5
|
Home-page: https://github.com/bernhard-42/vscode-ocp-cad-viewer
|
|
6
6
|
Author: Bernhard Walter
|
|
@@ -21,6 +21,6 @@ Requires-Dist: ocp-tessellate<2.4.0,>=2.3.2
|
|
|
21
21
|
Requires-Dist: requests
|
|
22
22
|
Requires-Dist: ipykernel
|
|
23
23
|
Requires-Dist: orjson
|
|
24
|
-
Requires-Dist: websockets
|
|
24
|
+
Requires-Dist: websockets>=12.0
|
|
25
25
|
|
|
26
26
|
An extension to show OCP cad CAD objects (CadQuery, build123d) in VS Code via threejs
|
|
@@ -21,7 +21,7 @@ _OCP CAD Viewer_ for VS Code is an extension to show [CadQuery](https://github.c
|
|
|
21
21
|
|
|
22
22
|
### Installation
|
|
23
23
|
|
|
24
|
-
1. Open the VS Code Marketplace, and search and install _OCP CAD Viewer 2.
|
|
24
|
+
1. Open the VS Code Marketplace, and search and install _OCP CAD Viewer 2.3.2_.
|
|
25
25
|
|
|
26
26
|
Afterwards the OCP viewer is available in the VS Code sidebar:
|
|
27
27
|
|
|
@@ -202,14 +202,18 @@ NATIVE_TESSELLATOR=1 OCP_VSCODE_PYTEST=1 pytest -v -s pytests/
|
|
|
202
202
|
|
|
203
203
|
## Changes
|
|
204
204
|
|
|
205
|
+
v2.3.2
|
|
206
|
+
- Fix regression that Python script hang in threading before exit ([#73](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/60))
|
|
207
|
+
|
|
205
208
|
v2.3.1
|
|
206
209
|
- Add latest ocp-tessellate to fixed regression with handling instances
|
|
207
210
|
- Make native default if ocp-addons exists
|
|
208
211
|
|
|
209
212
|
v2.3.0
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
-
|
|
213
|
+
Fine tune communication to ensure the memory view of buffers will be passed through to javascript for performance (*)
|
|
214
|
+
Use of the new protocol v3 of three-cad-viewer
|
|
215
|
+
Fix show_all regressions https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/71. It should also properly catch exceptions now to not interrupt viausl debugging
|
|
216
|
+
Add newest ocp-tessellate to allow using native tessellator from ocp_addons
|
|
213
217
|
|
|
214
218
|
v2.2.2
|
|
215
219
|
- Fix regression in measure tools
|
|
@@ -8,7 +8,10 @@ import socket
|
|
|
8
8
|
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# TODO:
|
|
12
|
+
# As soon as websockets 12.1 is released, replace with
|
|
13
|
+
# "from websockets.sync.client import connect"
|
|
14
|
+
from .daemonize import connect
|
|
12
15
|
|
|
13
16
|
import orjson
|
|
14
17
|
from ocp_tessellate.utils import Timer
|
|
@@ -34,7 +37,7 @@ CMD_URL = "ws://127.0.0.1"
|
|
|
34
37
|
CMD_PORT = 3939
|
|
35
38
|
|
|
36
39
|
INIT_DONE = False
|
|
37
|
-
|
|
40
|
+
WS = None
|
|
38
41
|
|
|
39
42
|
#
|
|
40
43
|
# Send data to the viewer
|
|
@@ -110,6 +113,8 @@ def set_port(port):
|
|
|
110
113
|
|
|
111
114
|
def _send(data, message_type, port=None, timeit=False):
|
|
112
115
|
"""Send data to the viewer"""
|
|
116
|
+
global WS
|
|
117
|
+
|
|
113
118
|
if port is None:
|
|
114
119
|
if not INIT_DONE:
|
|
115
120
|
find_and_set_port()
|
|
@@ -132,13 +137,14 @@ def _send(data, message_type, port=None, timeit=False):
|
|
|
132
137
|
j = b"S:" + j
|
|
133
138
|
|
|
134
139
|
with Timer(timeit, "", f"websocket send {len(j)/1024/1024:.3f} MB", 1):
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
if WS is None:
|
|
141
|
+
WS = connect(f"{CMD_URL}:{port}")
|
|
142
|
+
WS.send(j)
|
|
137
143
|
|
|
138
144
|
result = None
|
|
139
145
|
if message_type == MessageType.COMMAND:
|
|
140
146
|
try:
|
|
141
|
-
result = json.loads(
|
|
147
|
+
result = json.loads(WS.recv())
|
|
142
148
|
except Exception as ex: # pylint: disable=broad-except
|
|
143
149
|
print(ex)
|
|
144
150
|
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Copyright (c) Aymeric Augustin and contributors
|
|
2
|
+
# see https://github.com/python-websockets/websockets/blob/main/LICENSE
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
import socket
|
|
6
|
+
import threading
|
|
7
|
+
import uuid
|
|
8
|
+
from typing import Optional, Dict
|
|
9
|
+
|
|
10
|
+
from websockets.sync.client import ClientProtocol, connect as _connect
|
|
11
|
+
from websockets.sync.connection import Connection
|
|
12
|
+
from websockets.sync.messages import Assembler
|
|
13
|
+
from websockets.sync.utils import Deadline
|
|
14
|
+
from websockets.datastructures import HeadersLike
|
|
15
|
+
from websockets.protocol import Protocol
|
|
16
|
+
from websockets.http import USER_AGENT
|
|
17
|
+
from websockets.http11 import Request, Response
|
|
18
|
+
from websockets.protocol import CONNECTING, OPEN, Event
|
|
19
|
+
from websockets.typing import LoggerLike
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DaemonConnection(Connection):
|
|
23
|
+
"""
|
|
24
|
+
Threaded implementation of a WebSocket connection.
|
|
25
|
+
|
|
26
|
+
:class:`Connection` provides APIs shared between WebSocket servers and
|
|
27
|
+
clients.
|
|
28
|
+
|
|
29
|
+
You shouldn't use it directly. Instead, use
|
|
30
|
+
:class:`~websockets.sync.client.ClientConnection` or
|
|
31
|
+
:class:`~websockets.sync.server.ServerConnection`.
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
recv_bufsize = 65536
|
|
36
|
+
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
socket: socket.socket,
|
|
40
|
+
protocol: Protocol,
|
|
41
|
+
*,
|
|
42
|
+
close_timeout: Optional[float] = 10,
|
|
43
|
+
) -> None:
|
|
44
|
+
self.socket = socket
|
|
45
|
+
self.protocol = protocol
|
|
46
|
+
self.close_timeout = close_timeout
|
|
47
|
+
|
|
48
|
+
# Inject reference to this instance in the protocol's logger.
|
|
49
|
+
self.protocol.logger = logging.LoggerAdapter(
|
|
50
|
+
self.protocol.logger,
|
|
51
|
+
{"websocket": self},
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# Copy attributes from the protocol for convenience.
|
|
55
|
+
self.id: uuid.UUID = self.protocol.id
|
|
56
|
+
"""Unique identifier of the connection. Useful in logs."""
|
|
57
|
+
self.logger: LoggerLike = self.protocol.logger
|
|
58
|
+
"""Logger for this connection."""
|
|
59
|
+
self.debug = self.protocol.debug
|
|
60
|
+
|
|
61
|
+
# HTTP handshake request and response.
|
|
62
|
+
self.request: Optional[Request] = None
|
|
63
|
+
"""Opening handshake request."""
|
|
64
|
+
self.response: Optional[Response] = None
|
|
65
|
+
"""Opening handshake response."""
|
|
66
|
+
|
|
67
|
+
# Mutex serializing interactions with the protocol.
|
|
68
|
+
self.protocol_mutex = threading.Lock()
|
|
69
|
+
|
|
70
|
+
# Assembler turning frames into messages and serializing reads.
|
|
71
|
+
self.recv_messages = Assembler()
|
|
72
|
+
|
|
73
|
+
# Whether we are busy sending a fragmented message.
|
|
74
|
+
self.send_in_progress = False
|
|
75
|
+
|
|
76
|
+
# Deadline for the closing handshake.
|
|
77
|
+
self.close_deadline: Optional[Deadline] = None
|
|
78
|
+
|
|
79
|
+
# Mapping of ping IDs to pong waiters, in chronological order.
|
|
80
|
+
self.pings: Dict[bytes, threading.Event] = {}
|
|
81
|
+
|
|
82
|
+
# Receiving events from the socket.
|
|
83
|
+
|
|
84
|
+
# !!! Start patch based on 12.0 (this is the only patched line) !!!
|
|
85
|
+
# self.recv_events_thread = threading.Thread(target=self.recv_events)
|
|
86
|
+
self.recv_events_thread = threading.Thread(target=self.recv_events, daemon=True)
|
|
87
|
+
# !!! End patch !!!
|
|
88
|
+
|
|
89
|
+
self.recv_events_thread.start()
|
|
90
|
+
|
|
91
|
+
# Exception raised in recv_events, to be chained to ConnectionClosed
|
|
92
|
+
# in the user thread in order to show why the TCP connection dropped.
|
|
93
|
+
self.recv_events_exc: Optional[BaseException] = None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class DaemonClientConnection(DaemonConnection):
|
|
97
|
+
"""
|
|
98
|
+
Threaded implementation of a WebSocket client connection.
|
|
99
|
+
|
|
100
|
+
:class:`ClientConnection` provides :meth:`recv` and :meth:`send` methods for
|
|
101
|
+
receiving and sending messages.
|
|
102
|
+
|
|
103
|
+
It supports iteration to receive messages::
|
|
104
|
+
|
|
105
|
+
for message in websocket:
|
|
106
|
+
process(message)
|
|
107
|
+
|
|
108
|
+
The iterator exits normally when the connection is closed with close code
|
|
109
|
+
1000 (OK) or 1001 (going away) or without a close code. It raises a
|
|
110
|
+
:exc:`~websockets.exceptions.ConnectionClosedError` when the connection is
|
|
111
|
+
closed with any other code.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
socket: Socket connected to a WebSocket server.
|
|
115
|
+
protocol: Sans-I/O connection.
|
|
116
|
+
close_timeout: Timeout for closing the connection in seconds.
|
|
117
|
+
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
def __init__(
|
|
121
|
+
self,
|
|
122
|
+
socket: socket.socket,
|
|
123
|
+
protocol: ClientProtocol,
|
|
124
|
+
*,
|
|
125
|
+
close_timeout: Optional[float] = 10,
|
|
126
|
+
) -> None:
|
|
127
|
+
self.protocol: ClientProtocol
|
|
128
|
+
self.response_rcvd = threading.Event()
|
|
129
|
+
super().__init__(
|
|
130
|
+
socket,
|
|
131
|
+
protocol,
|
|
132
|
+
close_timeout=close_timeout,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def handshake(
|
|
136
|
+
self,
|
|
137
|
+
additional_headers: Optional[HeadersLike] = None,
|
|
138
|
+
user_agent_header: Optional[str] = USER_AGENT,
|
|
139
|
+
timeout: Optional[float] = None,
|
|
140
|
+
) -> None:
|
|
141
|
+
"""
|
|
142
|
+
Perform the opening handshake.
|
|
143
|
+
|
|
144
|
+
"""
|
|
145
|
+
with self.send_context(expected_state=CONNECTING):
|
|
146
|
+
self.request = self.protocol.connect()
|
|
147
|
+
if additional_headers is not None:
|
|
148
|
+
self.request.headers.update(additional_headers)
|
|
149
|
+
if user_agent_header is not None:
|
|
150
|
+
self.request.headers["User-Agent"] = user_agent_header
|
|
151
|
+
self.protocol.send_request(self.request)
|
|
152
|
+
|
|
153
|
+
if not self.response_rcvd.wait(timeout):
|
|
154
|
+
self.close_socket()
|
|
155
|
+
self.recv_events_thread.join()
|
|
156
|
+
raise TimeoutError("timed out during handshake")
|
|
157
|
+
|
|
158
|
+
if self.response is None:
|
|
159
|
+
self.close_socket()
|
|
160
|
+
self.recv_events_thread.join()
|
|
161
|
+
raise ConnectionError("connection closed during handshake")
|
|
162
|
+
|
|
163
|
+
if self.protocol.state is not OPEN:
|
|
164
|
+
self.recv_events_thread.join(self.close_timeout)
|
|
165
|
+
self.close_socket()
|
|
166
|
+
self.recv_events_thread.join()
|
|
167
|
+
|
|
168
|
+
if self.protocol.handshake_exc is not None:
|
|
169
|
+
raise self.protocol.handshake_exc
|
|
170
|
+
|
|
171
|
+
def process_event(self, event: Event) -> None:
|
|
172
|
+
"""
|
|
173
|
+
Process one incoming event.
|
|
174
|
+
|
|
175
|
+
"""
|
|
176
|
+
# First event - handshake response.
|
|
177
|
+
if self.response is None:
|
|
178
|
+
assert isinstance(event, Response)
|
|
179
|
+
self.response = event
|
|
180
|
+
self.response_rcvd.set()
|
|
181
|
+
# Later events - frames.
|
|
182
|
+
else:
|
|
183
|
+
super().process_event(event)
|
|
184
|
+
|
|
185
|
+
def recv_events(self) -> None:
|
|
186
|
+
"""
|
|
187
|
+
Read incoming data from the socket and process events.
|
|
188
|
+
|
|
189
|
+
"""
|
|
190
|
+
try:
|
|
191
|
+
super().recv_events()
|
|
192
|
+
finally:
|
|
193
|
+
# If the connection is closed during the handshake, unblock it.
|
|
194
|
+
self.response_rcvd.set()
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
# Simple shim
|
|
198
|
+
def connect(url):
|
|
199
|
+
return _connect(url, create_connection=DaemonClientConnection)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ocp_vscode
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.2
|
|
4
4
|
Summary: OCP CAD Viewer for VSCode
|
|
5
5
|
Home-page: https://github.com/bernhard-42/vscode-ocp-cad-viewer
|
|
6
6
|
Author: Bernhard Walter
|
|
@@ -21,6 +21,6 @@ Requires-Dist: ocp-tessellate<2.4.0,>=2.3.2
|
|
|
21
21
|
Requires-Dist: requests
|
|
22
22
|
Requires-Dist: ipykernel
|
|
23
23
|
Requires-Dist: orjson
|
|
24
|
-
Requires-Dist: websockets
|
|
24
|
+
Requires-Dist: websockets>=12.0
|
|
25
25
|
|
|
26
26
|
An extension to show OCP cad CAD objects (CadQuery, build123d) in VS Code via threejs
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup_args = {
|
|
4
4
|
"name": "ocp_vscode",
|
|
5
|
-
"version": "2.3.
|
|
5
|
+
"version": "2.3.2",
|
|
6
6
|
"description": "OCP CAD Viewer for VSCode",
|
|
7
7
|
"long_description": "An extension to show OCP cad CAD objects (CadQuery, build123d) in VS Code via threejs",
|
|
8
8
|
"include_package_data": True,
|
|
@@ -12,7 +12,7 @@ setup_args = {
|
|
|
12
12
|
"requests",
|
|
13
13
|
"ipykernel",
|
|
14
14
|
"orjson",
|
|
15
|
-
"websockets>=
|
|
15
|
+
"websockets>=12.0",
|
|
16
16
|
],
|
|
17
17
|
"packages": find_packages(),
|
|
18
18
|
"zip_safe": False,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|