Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ build/
dll/
typings/
logs/
env/
*.log*
*.mem.csv
release/
Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"recommendations": [
"stylelint.vscode-stylelint",
"EditorConfig.EditorConfig",
"msjsdiag.debugger-for-chrome",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"rvest.vs-code-prettier-eslint",
Expand Down
58 changes: 29 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"copy-webpack-plugin": "^6.0.3",
"cross-env": "^5.2.1",
"css-loader": "^2.1.1",
"electron": "^9.4.0",
"electron": "^11.5.0",
"electron-builder": "22.11.4",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
Expand Down Expand Up @@ -144,7 +144,7 @@
"rimraf": "^2.7.1",
"sass": "^1.26.10",
"sass-loader": "^9.0.3",
"spectron": "^11.1.0",
"spectron": "^13.0.0",
"style-loader": "^0.23.1",
"stylelint": "^13.6.1",
"to-string-loader": "^1.1.6",
Expand Down
3 changes: 2 additions & 1 deletion python/jsonrpc/error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from typing import Union


class JsonRpcErrorCodes:
Expand All @@ -25,7 +26,7 @@ class JsonRpcError(BaseException):
Class representing a JSON rpc error
"""

def __init__(self, code: str, message: str, data: object = None):
def __init__(self, code: Union[str, int], message: str, data: object = None):
super().__init__()
self.code = code
self.message = message
Expand Down
7 changes: 4 additions & 3 deletions python/jsonrpc/request.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import asyncio
import threading
from typing import Any
from server.aad_auth import AADAuth
from .error import JsonRpcParseError
stream_loop = asyncio.new_event_loop()
Expand Down Expand Up @@ -33,7 +34,7 @@ class JsonRpcRequest:
def __init__(self,
jsonrpc: str,
method: str,
params: any,
params: Any,
options: JsonRpcRequestOptions,
request_id: str,
connection):
Expand All @@ -56,7 +57,7 @@ def __init__(self,
if options.authentication:
self.auth = AADAuth.from_dict(options.authentication)

async def send_stream(self, data: any):
async def send_stream(self, data: Any):
from .response import JsonRpcResponse
response = JsonRpcResponse(
request=self,
Expand All @@ -65,7 +66,7 @@ async def send_stream(self, data: any):
)
await self.connection.send_response(response)

def push_stream(self, data: any):
def push_stream(self, data: Any):
stream_loop.call_soon_threadsafe(
lambda: stream_loop.create_task(self.send_stream(data)))

Expand Down
3 changes: 2 additions & 1 deletion python/jsonrpc/response.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from typing import Any, Optional
from .error import JsonRpcError
from .request import JsonRpcRequest

Expand All @@ -8,7 +9,7 @@ class JsonRpcResponse:
Class for a json rpc response.
"""

def __init__(self, request: JsonRpcRequest, result: any=None, stream=False, error: JsonRpcError=None):
def __init__(self, request: Optional[JsonRpcRequest], result: Any=None, stream=False, error: JsonRpcError=None):
self.jsonrpc = "2.0"
self.result = result
self.error = error
Expand Down
7 changes: 4 additions & 3 deletions python/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# """
# Main module
# """
import asyncio
import logging
import signal
import sys
Expand All @@ -13,7 +14,7 @@ def setup_logging():
logging.basicConfig(format='%(message)s', level="INFO")


def run():
async def main():
"""
Main function of the app that start the server
"""
Expand All @@ -24,9 +25,9 @@ def run():
port = int(sys.argv[1])

ws_server = server.websocket_server.WebsocketServer(port)
ws_server.run_forever()
await ws_server.run_forever()



if __name__ == "__main__":
run()
asyncio.run(main())
4 changes: 2 additions & 2 deletions python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
websockets==9.1
websockets==10.1
pylint==2.3.0
azure-batch-extensions==7.0.0
pyinstaller==3.6
pyinstaller==4.9
azure-batch==8.0.0
3 changes: 2 additions & 1 deletion python/server/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import inspect
import traceback
import azext.batch
from azext.batch.errors import MissingParameterValue
import azure.batch.models as batch_models
import azure.common
import logging
Expand Down Expand Up @@ -59,7 +60,7 @@ async def call_procedure(self, request):
except batch_models.BatchErrorException as e:
# pylint: disable=E1101
raise JsonRpcError(e.response.status_code, e.message.value, e.response.json())
except azext.batch.errors.MissingParameterValue as e:
except MissingParameterValue as e:
raise JsonRpcInvalidParamsError(str(e), {
'paramName': e.parameter_name,
'paramDescription': e.parameter_description,
Expand Down
19 changes: 10 additions & 9 deletions python/server/websocket_server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio
import traceback
import websockets
import logging
from jsonrpc import JsonRpcRequest, JsonRpcResponse, error
from websockets import server
from websockets.exceptions import ConnectionClosed
from .response_stream import ResponseStream
from .app import app
from controllers import *
Expand All @@ -14,17 +15,17 @@ class WebsocketServer:

def __init__(self, port):
self.port = port
self.start_server = websockets.serve(
self.handler, "localhost", self.port)
self.start_server = server.serve(
self.handler, "127.0.0.1", self.port)

def run_forever(self):
async def run_forever(self):
"""
Start to serve the server forever.
"""
print("Starting websocket server...")
asyncio.get_event_loop().run_until_complete(self.start_server)
print("Started server")
asyncio.get_event_loop().run_forever()
async with server.serve(self.handler, "127.0.0.1", self.port):
print("Started server")
await asyncio.Future()

async def handler(self, websocket, _):
"""
Expand All @@ -33,7 +34,7 @@ async def handler(self, websocket, _):
connection = WebsocketConnection(websocket)
try:
await connection.listen()
except websockets.exceptions.ConnectionClosed:
except ConnectionClosed:
logging.info("Websocket connection closed.")


Expand All @@ -54,7 +55,7 @@ async def listen(self):
error=parse_error,
)
await self.send_response(response)
except websockets.exceptions.ConnectionClosed:
except ConnectionClosed:
logging.info("Websocket connection closed.")
else:
await self.process_request(request)
Expand Down
6 changes: 3 additions & 3 deletions src/client/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function setupSingleInstance(batchExplorerApp: BatchExplorerApplication) {
log.info("There is already an instance of BatchExplorer open. Closing this one.");
batchExplorerApp.quit();
} else {
app.on("second-instance", (event, commandLine, workingDirectory) => {
app.on("second-instance", (event, commandLine) => {
log.info("Try to open labs again", commandLine);
batchExplorerApp.openFromArguments(commandLine);
});
Expand All @@ -40,7 +40,7 @@ function registerAuthProtocol() {
// This call needs to be done after electron app is ready.
protocol.registerStringProtocol("urn", (request, callback) => {
// Doesn't matter how the protocol is handled; error is fine
callback();
callback("");
});
}

Expand Down Expand Up @@ -128,7 +128,7 @@ function secureRemoteContentLoading() {

// This reject any permissions requested by remove websites(Like asking for location).
// This should never get called as the above call shouldn't open any remote links
session.defaultSession!.setPermissionRequestHandler((webContents, permission, callback) => {
session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => {
return callback(false);
});
}
4 changes: 3 additions & 1 deletion test/spectron/test-app-start.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ describe("Bundled application is starting correctly", () => {

await app.start();
// eslint-disable-next-line no-console
console.log("User path: ", await app.electron.remote.app.getPath("userData"));
// TODO: Why did the typings break in spectron 13?
const electron = app.electron as unknown as any;
console.log("User path: ", await electron.remote.app.getPath("userData"));
});

afterEach(() => {
Expand Down