kalong 0.5.4__py3-none-any.whl → 0.5.5__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.
- kalong/__init__.py +1 -1
- kalong/config.py +47 -6
- kalong/server.py +20 -1
- kalong/static/assets/index-ByEA1zci.js +166 -0
- kalong/static/index.html +1 -1
- kalong/utils/__init__.py +3 -3
- kalong/websockets.py +10 -1
- {kalong-0.5.4.dist-info → kalong-0.5.5.dist-info}/METADATA +1 -1
- {kalong-0.5.4.dist-info → kalong-0.5.5.dist-info}/RECORD +12 -12
- {kalong-0.5.4.dist-info → kalong-0.5.5.dist-info}/WHEEL +1 -1
- kalong/static/assets/index-DPZ8eRPa.js +0 -229
- {kalong-0.5.4.dist-info → kalong-0.5.5.dist-info}/entry_points.txt +0 -0
- {kalong-0.5.4.dist-info → kalong-0.5.5.dist-info}/licenses/LICENSE +0 -0
kalong/__init__.py
CHANGED
kalong/config.py
CHANGED
|
@@ -7,11 +7,15 @@ defaults = {
|
|
|
7
7
|
"protocol": "http",
|
|
8
8
|
"host": "localhost",
|
|
9
9
|
"port": 59999,
|
|
10
|
+
"front_host": "localhost",
|
|
10
11
|
"front_port": 59999,
|
|
12
|
+
"ws_host": "localhost",
|
|
13
|
+
"ws_port": 59999,
|
|
11
14
|
"log": "warn",
|
|
12
15
|
"detached": False,
|
|
13
16
|
"command": [],
|
|
14
17
|
"inject": None,
|
|
18
|
+
"urlsocket": False,
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
|
|
@@ -24,25 +28,45 @@ class Config:
|
|
|
24
28
|
parser.add_argument(
|
|
25
29
|
"--server",
|
|
26
30
|
action="store_true",
|
|
27
|
-
help="Launch the kalong server.
|
|
31
|
+
help="Launch the kalong server. This option is used by kalong itself",
|
|
28
32
|
)
|
|
29
33
|
parser.add_argument(
|
|
30
34
|
"--protocol",
|
|
31
35
|
default=self.protocol,
|
|
32
36
|
help="Protocol for contacting kalong server",
|
|
33
37
|
)
|
|
34
|
-
parser.add_argument("--host", default=self.host, help="Host of kalong server")
|
|
35
38
|
parser.add_argument(
|
|
36
|
-
"--
|
|
39
|
+
"--host",
|
|
40
|
+
default=self.host,
|
|
41
|
+
help="Host of kalong server",
|
|
37
42
|
)
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
parser.add_argument(
|
|
44
|
+
"--port",
|
|
45
|
+
type=int,
|
|
46
|
+
default=self.port,
|
|
47
|
+
help="Port of kalong server",
|
|
48
|
+
)
|
|
49
|
+
parser.add_argument(
|
|
50
|
+
"--front-host",
|
|
51
|
+
default=self.front_host,
|
|
52
|
+
help="Host of kalong frontend, defaults to host option",
|
|
40
53
|
)
|
|
41
54
|
parser.add_argument(
|
|
42
55
|
"--front-port",
|
|
43
56
|
type=int,
|
|
57
|
+
default=self.front_port,
|
|
44
58
|
help="Port of kalong frontend, defaults to port option",
|
|
45
|
-
|
|
59
|
+
)
|
|
60
|
+
parser.add_argument(
|
|
61
|
+
"--ws-host",
|
|
62
|
+
default=self.ws_host,
|
|
63
|
+
help="Host of kalong websocket server, defaults to host option",
|
|
64
|
+
)
|
|
65
|
+
parser.add_argument(
|
|
66
|
+
"--ws-port",
|
|
67
|
+
type=int,
|
|
68
|
+
default=self.ws_port,
|
|
69
|
+
help="Port of kalong websocket server, defaults to port option",
|
|
46
70
|
)
|
|
47
71
|
parser.add_argument(
|
|
48
72
|
"--log",
|
|
@@ -66,6 +90,11 @@ class Config:
|
|
|
66
90
|
action="store_true",
|
|
67
91
|
help="Break at the start of the python file",
|
|
68
92
|
)
|
|
93
|
+
parser.add_argument(
|
|
94
|
+
"--urlsocket",
|
|
95
|
+
type=str,
|
|
96
|
+
help="Path of the socket into which to feed the url for docker browser opening",
|
|
97
|
+
)
|
|
69
98
|
parser.add_argument(
|
|
70
99
|
"command",
|
|
71
100
|
nargs=REMAINDER,
|
|
@@ -76,8 +105,14 @@ class Config:
|
|
|
76
105
|
|
|
77
106
|
def parse_args(self):
|
|
78
107
|
args = self.get_parser().parse_args()
|
|
108
|
+
if not args.front_host:
|
|
109
|
+
args.front_host = args.host
|
|
79
110
|
if not args.front_port:
|
|
80
111
|
args.front_port = args.port
|
|
112
|
+
if not args.ws_host:
|
|
113
|
+
args.ws_host = args.host
|
|
114
|
+
if not args.ws_port:
|
|
115
|
+
args.ws_port = args.port
|
|
81
116
|
return args
|
|
82
117
|
|
|
83
118
|
def from_args(self):
|
|
@@ -90,8 +125,14 @@ class Config:
|
|
|
90
125
|
if value:
|
|
91
126
|
setattr(self, name, type(name)(value))
|
|
92
127
|
|
|
128
|
+
if os.getenv("KALONG_HOST") and not os.getenv("KALONG_FRONT_HOST"):
|
|
129
|
+
self.front_host = self.host
|
|
93
130
|
if os.getenv("KALONG_PORT") and not os.getenv("KALONG_FRONT_PORT"):
|
|
94
131
|
self.front_port = self.port
|
|
132
|
+
if os.getenv("KALONG_HOST") and not os.getenv("KALONG_WS_HOST"):
|
|
133
|
+
self.ws_host = self.host
|
|
134
|
+
if os.getenv("KALONG_PORT") and not os.getenv("KALONG_WS_PORT"):
|
|
135
|
+
self.ws_port = self.port
|
|
95
136
|
|
|
96
137
|
def get_args_for_server(self):
|
|
97
138
|
yield "--server"
|
kalong/server.py
CHANGED
|
@@ -29,6 +29,25 @@ def maybe_bail(app):
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
|
|
32
|
+
def index():
|
|
33
|
+
index.__content__ = getattr(index, "__content__", None)
|
|
34
|
+
if not index.__content__:
|
|
35
|
+
with open(Path(__file__).parent / "static" / "index.html", "rb") as f:
|
|
36
|
+
index.__content__ = f.read()
|
|
37
|
+
if config.ws_port != config.port or config.ws_host != config.host:
|
|
38
|
+
index.__content__ = index.__content__.replace(
|
|
39
|
+
b"</body>",
|
|
40
|
+
f"""
|
|
41
|
+
<script>
|
|
42
|
+
window.KALONG_WS_HOST = "{config.ws_host}";
|
|
43
|
+
window.KALONG_WS_PORT = {config.ws_port};
|
|
44
|
+
</script>
|
|
45
|
+
</body>
|
|
46
|
+
""".encode(),
|
|
47
|
+
)
|
|
48
|
+
return web.Response(body=index.__content__, content_type="text/html")
|
|
49
|
+
|
|
50
|
+
|
|
32
51
|
async def shutdown(app):
|
|
33
52
|
log.info("App shutdown, closing remaining websockets.")
|
|
34
53
|
await asyncio.gather(
|
|
@@ -60,7 +79,7 @@ async def websocket(request):
|
|
|
60
79
|
state = ws.can_prepare(request)
|
|
61
80
|
if not state.ok:
|
|
62
81
|
log.debug(f"Sending {side} app for {origin}")
|
|
63
|
-
return
|
|
82
|
+
return index()
|
|
64
83
|
|
|
65
84
|
await ws.prepare(request)
|
|
66
85
|
|