Skip to content

Commit cb38ee9

Browse files
authored
Merge pull request #99 from Geode-solutions/fix/refactor_kill
fix(Kill): kill rpc
2 parents 62963c5 + 70734ef commit cb38ee9

File tree

10 files changed

+51
-11
lines changed

10 files changed

+51
-11
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ __pycache__/
66
.env
77
/node_modules
88
latest_logs
9-
schemas.json
109
build
1110
/src/tests/tests_output/
1211
*.egg-info
1312
.coverage*
14-
.mypy_cache
13+
.mypy_cache
14+
opengeodeweb_viewer_schemas.json

package-lock.json

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies = {file = ["requirements.txt"]}
3333
where = ["src"]
3434

3535
[tool.setuptools.package-data]
36+
"opengeodeweb_viewer.rpc.schemas" = ["*.json"]
3637
"opengeodeweb_viewer.rpc.generic.schemas" = ["*.json"]
3738
"opengeodeweb_viewer.rpc.mesh.schemas" = ["*.json"]
3839
"opengeodeweb_viewer.rpc.mesh.points.schemas" = ["*.json"]

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ wslink==1.12.4
6161
yarl==1.22.0
6262
# via aiohttp
6363

64-
opengeodeweb-microservice~=1.0

src/opengeodeweb_viewer/py.typed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
partial
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"rpc": "kill",
3+
"type": "object",
4+
"properties": {},
5+
"required": [],
6+
"additionalProperties": false
7+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# type: ignore
2+
# Standard library imports
3+
import os
4+
5+
# Third party imports
6+
from wslink import register as exportRpc
7+
8+
# Local application imports
9+
from opengeodeweb_viewer.utils_functions import get_schemas_dict
10+
from opengeodeweb_viewer.vtk_protocol import VtkView
11+
12+
13+
class VtkUtilsView(VtkView):
14+
ogw_prefix = "opengeodeweb_viewer."
15+
ogw_schemas_dict = get_schemas_dict(
16+
os.path.join(os.path.dirname(__file__), "schemas")
17+
)
18+
19+
def __init__(self) -> None:
20+
super().__init__()
21+
22+
@exportRpc(ogw_prefix + ogw_schemas_dict["kill"]["rpc"])
23+
def kill(self) -> None:
24+
print("Manual viewer kill, shutting down...", flush=True)
25+
os._exit(0)

src/opengeodeweb_viewer/utils_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Local application imports
1010

1111

12-
def get_schemas_dict(path):
12+
def get_schemas_dict(path: str) -> object:
1313
json_files = os.listdir(path)
1414
schemas_dict = {}
1515
for json_file in json_files:

src/opengeodeweb_viewer/vtk_protocol.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
# Third party imports
55
import vtk
6-
from vtk.web import protocols as vtk_protocols
6+
from vtk.web import protocols as vtk_protocols # type: ignore
77

88
# Local application imports
99

10+
# mypy: allow-untyped-defs
11+
1012

1113
class VtkView(vtk_protocols.vtkWebProtocol):
1214
def __init__(self):

src/opengeodeweb_viewer/vtkw_server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
VtkModelBlocksView,
3838
)
3939
from .rpc.generic.generic_protocols import VtkGenericView
40+
from .rpc.utils_protocols import VtkUtilsView # type: ignore
4041

4142

4243
# =============================================================================
@@ -78,6 +79,7 @@ def initialize(self):
7879
model_protocols = VtkModelView()
7980
vtk_view = VtkView()
8081
self.registerVtkWebProtocol(vtk_view)
82+
self.registerVtkWebProtocol(VtkUtilsView())
8183
self.registerVtkWebProtocol(VtkViewerView())
8284
self.registerVtkWebProtocol(mesh_protocols)
8385
self.registerVtkWebProtocol(VtkMeshPointsView())

0 commit comments

Comments
 (0)