Skip to content

Commit

Permalink
refactor: format with black and add missing module headers
Browse files Browse the repository at this point in the history
  • Loading branch information
hlouzada committed Apr 18, 2024
1 parent d56d683 commit ee72159
Show file tree
Hide file tree
Showing 9 changed files with 337 additions and 196 deletions.
208 changes: 143 additions & 65 deletions spyder/plugins/remoteclient/api/client.py

Large diffs are not rendered by default.

35 changes: 23 additions & 12 deletions spyder/plugins/remoteclient/api/jupyterhub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
import uuid
import logging
import time
Expand Down Expand Up @@ -194,34 +199,40 @@ async def get_services(self):
return await response.json()

async def get_service(self, service_name):
async with self.session.get(self.api_url / "services" / service_name) as response:
async with self.session.get(
self.api_url / "services" / service_name
) as response:
if response.status == 404:
return None
elif response.status == 200:
return await response.json()

async def execute_post_service(self, service_name, url='', data=None):
async with self.session.post(self.hub_url / "services" / service_name / url, data=data) as response:

async def execute_post_service(self, service_name, url="", data=None):
async with self.session.post(
self.hub_url / "services" / service_name / url, data=data
) as response:
if response.status == 404:
return None
elif response.status == 200:
return await response.json()

async def execute_get_service(self, service_name, url=''):
async with self.session.get(self.hub_url / "services" / service_name / url) as response:

async def execute_get_service(self, service_name, url=""):
async with self.session.get(
self.hub_url / "services" / service_name / url
) as response:
if response.status == 404:
return None
elif response.status == 200:
return await response.json()

async def execute_delete_service(self, service_name, url=''):
async with self.session.delete(self.hub_url / "services" / service_name / url) as response:

async def execute_delete_service(self, service_name, url=""):
async with self.session.delete(
self.hub_url / "services" / service_name / url
) as response:
if response.status == 404:
return None
elif response.status == 200:
return await response.json()




class JupyterAPI:
Expand Down
5 changes: 5 additions & 0 deletions spyder/plugins/remoteclient/api/jupyterhub/auth.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
import re

import aiohttp
Expand Down
5 changes: 5 additions & 0 deletions spyder/plugins/remoteclient/api/jupyterhub/execute.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
import uuid
import difflib
import logging
Expand Down
5 changes: 5 additions & 0 deletions spyder/plugins/remoteclient/api/jupyterhub/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
import json


Expand Down
15 changes: 14 additions & 1 deletion spyder/plugins/remoteclient/api/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
class KernelsList(typing.TypedDict):
kernels: list[str]


class KernelInfo(typing.TypedDict):
alive: bool
pid: int


class DeleteKernel(typing.TypedDict):
success: bool


class KernelConnectionInfo(typing.TypedDict):
shell_port: int
iopub_port: int
Expand All @@ -35,6 +38,7 @@ class KernelConnectionInfo(typing.TypedDict):
signature_scheme: str
kernel_name: str


class SSHClientOptions(typing.TypedDict):
host: str
port: int | None
Expand All @@ -45,19 +49,28 @@ class SSHClientOptions(typing.TypedDict):
config: typing.Sequence[str] | None
platform: str | None


class ConnectionStatus:
Inactive = "inactive"
Connecting = "connecting"
Active = "active"
Error = "error"


class ConnectionInfo(typing.TypedDict):
id: str
status: ConnectionStatus
message: str


class RemoteClientLog(typing.TypedDict):
id: str
message: str
level: logging.DEBUG | logging.INFO | logging.WARNING | logging.ERROR | logging.CRITICAL
level: (
logging.DEBUG
| logging.INFO
| logging.WARNING
| logging.ERROR
| logging.CRITICAL
)
created: float
Loading

0 comments on commit ee72159

Please sign in to comment.