Skip to content

Commit 00e6978

Browse files
authored
Fix Python backend and update various dependencies (#2411)
* Remove deprecated Chrome debugger extension from VSCode recommendations * Update to Electron 11 and PyInstaller 4 * Fix broken python websocket server Fixes #2384 A previous dependency update caused an issue between pyinstaller and websockets. Updated both and fixed the issue by changing how websockets is imported.
1 parent 4b75cdf commit 00e6978

File tree

13 files changed

+64
-56
lines changed

13 files changed

+64
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ build/
33
dll/
44
typings/
55
logs/
6+
env/
67
*.log*
78
*.mem.csv
89
release/

.vscode/extensions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"recommendations": [
33
"stylelint.vscode-stylelint",
44
"EditorConfig.EditorConfig",
5-
"msjsdiag.debugger-for-chrome",
65
"dbaeumer.vscode-eslint",
76
"esbenp.prettier-vscode",
87
"rvest.vs-code-prettier-eslint",

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"copy-webpack-plugin": "^6.0.3",
102102
"cross-env": "^5.2.1",
103103
"css-loader": "^2.1.1",
104-
"electron": "^9.4.0",
104+
"electron": "^11.5.0",
105105
"electron-builder": "22.11.4",
106106
"eslint": "^7.19.0",
107107
"eslint-config-prettier": "^7.2.0",
@@ -144,7 +144,7 @@
144144
"rimraf": "^2.7.1",
145145
"sass": "^1.26.10",
146146
"sass-loader": "^9.0.3",
147-
"spectron": "^11.1.0",
147+
"spectron": "^13.0.0",
148148
"style-loader": "^0.23.1",
149149
"stylelint": "^13.6.1",
150150
"to-string-loader": "^1.1.6",

python/jsonrpc/error.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from typing import Union
23

34

45
class JsonRpcErrorCodes:
@@ -25,7 +26,7 @@ class JsonRpcError(BaseException):
2526
Class representing a JSON rpc error
2627
"""
2728

28-
def __init__(self, code: str, message: str, data: object = None):
29+
def __init__(self, code: Union[str, int], message: str, data: object = None):
2930
super().__init__()
3031
self.code = code
3132
self.message = message

python/jsonrpc/request.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import asyncio
33
import threading
4+
from typing import Any
45
from server.aad_auth import AADAuth
56
from .error import JsonRpcParseError
67
stream_loop = asyncio.new_event_loop()
@@ -33,7 +34,7 @@ class JsonRpcRequest:
3334
def __init__(self,
3435
jsonrpc: str,
3536
method: str,
36-
params: any,
37+
params: Any,
3738
options: JsonRpcRequestOptions,
3839
request_id: str,
3940
connection):
@@ -56,7 +57,7 @@ def __init__(self,
5657
if options.authentication:
5758
self.auth = AADAuth.from_dict(options.authentication)
5859

59-
async def send_stream(self, data: any):
60+
async def send_stream(self, data: Any):
6061
from .response import JsonRpcResponse
6162
response = JsonRpcResponse(
6263
request=self,
@@ -65,7 +66,7 @@ async def send_stream(self, data: any):
6566
)
6667
await self.connection.send_response(response)
6768

68-
def push_stream(self, data: any):
69+
def push_stream(self, data: Any):
6970
stream_loop.call_soon_threadsafe(
7071
lambda: stream_loop.create_task(self.send_stream(data)))
7172

python/jsonrpc/response.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from typing import Any, Optional
23
from .error import JsonRpcError
34
from .request import JsonRpcRequest
45

@@ -8,7 +9,7 @@ class JsonRpcResponse:
89
Class for a json rpc response.
910
"""
1011

11-
def __init__(self, request: JsonRpcRequest, result: any=None, stream=False, error: JsonRpcError=None):
12+
def __init__(self, request: Optional[JsonRpcRequest], result: Any=None, stream=False, error: JsonRpcError=None):
1213
self.jsonrpc = "2.0"
1314
self.result = result
1415
self.error = error

python/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# """
22
# Main module
33
# """
4+
import asyncio
45
import logging
56
import signal
67
import sys
@@ -13,7 +14,7 @@ def setup_logging():
1314
logging.basicConfig(format='%(message)s', level="INFO")
1415

1516

16-
def run():
17+
async def main():
1718
"""
1819
Main function of the app that start the server
1920
"""
@@ -24,9 +25,9 @@ def run():
2425
port = int(sys.argv[1])
2526

2627
ws_server = server.websocket_server.WebsocketServer(port)
27-
ws_server.run_forever()
28+
await ws_server.run_forever()
2829

2930

3031

3132
if __name__ == "__main__":
32-
run()
33+
asyncio.run(main())

python/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
websockets==9.1
1+
websockets==10.1
22
pylint==2.3.0
33
azure-batch-extensions==7.0.0
4-
pyinstaller==3.6
4+
pyinstaller==4.9
55
azure-batch==8.0.0

python/server/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import inspect
22
import traceback
33
import azext.batch
4+
from azext.batch.errors import MissingParameterValue
45
import azure.batch.models as batch_models
56
import azure.common
67
import logging
@@ -59,7 +60,7 @@ async def call_procedure(self, request):
5960
except batch_models.BatchErrorException as e:
6061
# pylint: disable=E1101
6162
raise JsonRpcError(e.response.status_code, e.message.value, e.response.json())
62-
except azext.batch.errors.MissingParameterValue as e:
63+
except MissingParameterValue as e:
6364
raise JsonRpcInvalidParamsError(str(e), {
6465
'paramName': e.parameter_name,
6566
'paramDescription': e.parameter_description,

0 commit comments

Comments
 (0)