move djls Python agent code and create new binary workspace package (#34)

closer to this thing being installable
This commit is contained in:
Josh Thomas 2024-12-15 21:21:18 -06:00 committed by GitHub
parent 9845c0e861
commit e7d0cb1245
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 62 additions and 42 deletions

View file

View file

@ -1,12 +0,0 @@
from __future__ import annotations
import sys
if sys.version_info >= (3, 12):
from typing import override as typing_override
else:
from typing_extensions import (
override as typing_override, # pyright: ignore[reportUnreachable]
)
override = typing_override

View file

@ -1,127 +0,0 @@
from __future__ import annotations
import struct
import sys
from typing import Any
from typing import cast
from google.protobuf.message import Message
from .logging import configure_logging
from .proto.v1 import messages_pb2
logger = configure_logging()
class LSPAgent:
def __init__(self):
from .handlers import handlers
self.handlers = handlers
logger.debug(
"LSPAgent initialized with handlers: %s", list(self.handlers.keys())
)
async def serve(self):
print("ready", flush=True)
try:
import django
django.setup()
except Exception as e:
error_response = self.create_error(messages_pb2.Error.DJANGO_ERROR, str(e))
self.write_message(error_response)
while True:
try:
data = self.read_message()
if not data:
break
response = await self.handle_request(data)
self.write_message(response)
except Exception as e:
error_response = self.create_error(messages_pb2.Error.UNKNOWN, str(e))
self.write_message(error_response)
def read_message(self) -> bytes | None:
length_bytes = sys.stdin.buffer.read(4)
logger.debug("Read length bytes: %r", length_bytes)
if not length_bytes:
return None
length = struct.unpack(">I", length_bytes)[0]
logger.debug("Unpacked length: %d", length)
data = sys.stdin.buffer.read(length)
logger.debug("Read data bytes: %r", data)
return data
async def handle_request(self, request_data: bytes) -> Message:
request = messages_pb2.Request()
request.ParseFromString(request_data)
command_name = request.WhichOneof("command")
logger.debug("Command name: %s", command_name)
if not command_name:
logger.error("No command specified")
return self.create_error(
messages_pb2.Error.INVALID_REQUEST, "No command specified"
)
handler = self.handlers.get(command_name)
if not handler:
logger.error("Unknown command: %s", command_name)
return self.create_error(
messages_pb2.Error.INVALID_REQUEST, f"Unknown command: {command_name}"
)
try:
command_message = getattr(request, command_name)
result = await handler(command_message)
return messages_pb2.Response(**{command_name: cast(Any, result)})
except Exception as e:
logger.exception("Error executing command")
return self.create_error(messages_pb2.Error.UNKNOWN, str(e))
def write_message(self, message: Message) -> None:
data = message.SerializeToString()
logger.debug(f"Sending response, length: {len(data)}, data: {data!r}")
length = struct.pack(">I", len(data))
logger.debug(f"Length bytes: {length!r}")
sys.stdout.buffer.write(length)
sys.stdout.buffer.write(data)
sys.stdout.buffer.flush()
def create_error(
self, code: messages_pb2.Error.Code, message: str
) -> messages_pb2.Response:
response = messages_pb2.Response()
response.error.code = code
response.error.message = message
return response
async def main() -> None:
logger.debug("Starting DJLS...")
try:
logger.debug("Initializing LSPAgent...")
agent = LSPAgent()
logger.debug("Starting LSPAgent serve...")
await agent.serve()
except KeyboardInterrupt:
logger.debug("Received KeyboardInterrupt")
sys.exit(0)
except Exception as e:
logger.exception("Fatal error")
print(f"error: {e}", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
import asyncio
asyncio.run(main())

View file

@ -1,204 +0,0 @@
from __future__ import annotations
import importlib.metadata
import inspect
import os
import subprocess
import sys
import sysconfig
import traceback
from collections.abc import Awaitable
from collections.abc import Coroutine
from functools import wraps
from typing import Any
from typing import Callable
from typing import TypeVar
from typing import cast
import django
from django.apps import apps
from google.protobuf.message import Message
from .proto.v1 import commands_pb2
from .proto.v1 import django_pb2
from .proto.v1 import messages_pb2
from .proto.v1 import python_pb2
T = TypeVar("T", bound=Message)
R = TypeVar("R", bound=Message)
handlers: dict[str, Callable[[Message], Coroutine[Any, Any, Message]]] = {}
def proto_handler(
request_type: type[T],
error: messages_pb2.Error | None = None,
) -> Callable[
[Callable[[T], R] | Callable[[T], Awaitable[R]]],
Callable[[T], Coroutine[Any, Any, R]],
]:
for req_field in messages_pb2.Request.DESCRIPTOR.fields:
if req_field.message_type == request_type.DESCRIPTOR:
command_name = req_field.name
# Find corresponding response type
for resp_field in messages_pb2.Response.DESCRIPTOR.fields:
if resp_field.name == command_name:
response_type = resp_field.message_type._concrete_class
break
else:
raise ValueError(f"No response type found for {request_type}")
break
else:
raise ValueError(f"Message type {request_type} not found in Request message")
def decorator(
func: Callable[[T], R] | Callable[[T], Awaitable[R]],
) -> Callable[[T], Coroutine[Any, Any, R]]:
is_async = inspect.iscoroutinefunction(func)
@wraps(func)
async def wrapper(request: T) -> R:
try:
if is_async:
result = await cast(Callable[[T], Awaitable[R]], func)(request)
else:
result = cast(Callable[[T], R], func)(request)
# Runtime type checking
if not isinstance(result, response_type):
raise TypeError(
f"Handler returned {type(result)}, expected {response_type}"
)
return result
except Exception as e:
if error:
err = error
else:
err = messages_pb2.Error(
code=messages_pb2.Error.PYTHON_ERROR,
message=str(e),
traceback=traceback.format_exc(),
)
return cast(R, messages_pb2.Response(error=err))
handlers[command_name] = wrapper # pyright: ignore[reportArgumentType]
return wrapper
return decorator
@proto_handler(commands_pb2.Check.HealthRequest)
async def check__health(
_request: commands_pb2.Check.HealthRequest,
) -> commands_pb2.Check.HealthResponse:
return commands_pb2.Check.HealthResponse(passed=True)
@proto_handler(commands_pb2.Check.GeoDjangoPrereqsRequest)
async def check__geodjango_prereqs(
request: commands_pb2.Check.GeoDjangoPrereqsRequest,
) -> commands_pb2.Check.GeoDjangoPrereqsResponse:
has_geodjango = apps.is_installed("django.contrib.gis")
try:
gdal_process = subprocess.run(
["gdalinfo", "--version"], capture_output=True, check=False
)
gdal_is_installed = gdal_process.returncode == 0
except FileNotFoundError:
gdal_is_installed = False
return commands_pb2.Check.GeoDjangoPrereqsResponse(
passed=(not has_geodjango) or gdal_is_installed
)
@proto_handler(commands_pb2.Python.GetEnvironmentRequest)
async def python__get_environment(
_request: commands_pb2.Python.GetEnvironmentRequest,
) -> commands_pb2.Python.GetEnvironmentResponse:
packages = {}
for dist in importlib.metadata.distributions():
try:
requires = []
try:
requires = list(dist.requires) if hasattr(dist, "requires") else []
except Exception:
pass
location = None
try:
location = str(dist._path) if hasattr(dist, "_path") else None
except Exception:
pass
packages[dist.metadata["Name"]] = python_pb2.Package(
dist_name=dist.metadata["Name"],
dist_version=dist.metadata["Version"],
dist_location=location,
dist_requires=requires,
dist_requires_python=dist.metadata.get("Requires-Python"),
dist_entry_points=str(dist.entry_points)
if hasattr(dist, "entry_points")
else None,
)
except Exception:
continue
sysconfig_paths = sysconfig.get_paths()
version_info = python_pb2.VersionInfo(
major=sys.version_info.major,
minor=sys.version_info.minor,
micro=sys.version_info.micro,
releaselevel={
"alpha": python_pb2.ReleaseLevel.ALPHA,
"beta": python_pb2.ReleaseLevel.BETA,
"candidate": python_pb2.ReleaseLevel.CANDIDATE,
"final": python_pb2.ReleaseLevel.FINAL,
}[sys.version_info.releaselevel],
serial=sys.version_info.serial,
)
return commands_pb2.Python.GetEnvironmentResponse(
python=python_pb2.Python(
os=python_pb2.Os(environ={k: v for k, v in os.environ.items()}),
site=python_pb2.Site(packages=packages),
sys=python_pb2.Sys(
debug_build=hasattr(sys, "gettotalrefcount"),
dev_mode=sys.flags.dev_mode,
is_venv=sys.prefix != sys.base_prefix,
abiflags=sys.abiflags,
base_prefix=sys.base_prefix,
default_encoding=sys.getdefaultencoding(),
executable=sys.executable,
filesystem_encoding=sys.getfilesystemencoding(),
implementation_name=sys.implementation.name,
platform=sys.platform,
prefix=sys.prefix,
builtin_module_names=list(sys.builtin_module_names),
dll_paths=sys.path if sys.platform == "win32" else [],
path=sys.path,
version_info=version_info,
),
sysconfig=python_pb2.Sysconfig(
data=sysconfig_paths.get("data", ""),
include=sysconfig_paths.get("include", ""),
platinclude=sysconfig_paths.get("platinclude", ""),
platlib=sysconfig_paths.get("platlib", ""),
platstdlib=sysconfig_paths.get("platstdlib", ""),
purelib=sysconfig_paths.get("purelib", ""),
scripts=sysconfig_paths.get("scripts", ""),
stdlib=sysconfig_paths.get("stdlib", ""),
),
)
)
@proto_handler(commands_pb2.Django.GetProjectInfoRequest)
async def django__get_project_info(
_request: commands_pb2.Django.GetProjectInfoRequest,
) -> commands_pb2.Django.GetProjectInfoResponse:
return commands_pb2.Django.GetProjectInfoResponse(
project=django_pb2.Project(version=django.__version__)
)

View file

@ -1,44 +0,0 @@
from __future__ import annotations
import logging
import sys
from dataclasses import dataclass
from pathlib import Path
@dataclass
class LogConfig:
log_file: Path | str = "/tmp/djls_debug.log"
log_level: int = logging.DEBUG
console_level: int = logging.DEBUG
file_level: int = logging.DEBUG
format: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
def configure_logging(config: LogConfig | None = None) -> logging.Logger:
if config is None:
config = LogConfig()
logger = logging.getLogger("djls")
logger.setLevel(config.log_level)
# Clear any existing handlers
logger.handlers.clear()
# File handler
fh = logging.FileHandler(config.log_file)
fh.setLevel(config.file_level)
# Console handler
ch = logging.StreamHandler(sys.stderr)
ch.setLevel(config.console_level)
# Formatter
formatter = logging.Formatter(config.format)
fh.setFormatter(formatter)
ch.setFormatter(formatter)
logger.addHandler(fh)
logger.addHandler(ch)
return logger

View file

@ -1,4 +0,0 @@
# WARNING: This file is generated by protobuf. DO NOT EDIT!
# Any changes made to this file will be overwritten when the protobuf files are regenerated.
# Source: generated by py-init

View file

@ -1,62 +0,0 @@
# WARNING: This file is generated by protobuf. DO NOT EDIT!
# Any changes made to this file will be overwritten when the protobuf files are regenerated.
# Source: v1/commands.proto
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: v1/commands.proto
# Protobuf Python Version: 5.29.1
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
5,
29,
1,
'',
'v1/commands.proto'
)
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from . import django_pb2 as v1_dot_django__pb2
from . import python_pb2 as v1_dot_python__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11v1/commands.proto\x12\x10\x64jls.v1.commands\x1a\x0fv1/django.proto\x1a\x0fv1/python.proto\"\xbd\x01\n\x05\x43heck\x1a\x0f\n\rHealthRequest\x1a>\n\x0eHealthResponse\x12\x0e\n\x06passed\x18\x01 \x01(\x08\x12\x12\n\x05\x65rror\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\x1a\x19\n\x17GeoDjangoPrereqsRequest\x1aH\n\x18GeoDjangoPrereqsResponse\x12\x0e\n\x06passed\x18\x01 \x01(\x08\x12\x12\n\x05\x65rror\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"c\n\x06Python\x1a\x17\n\x15GetEnvironmentRequest\x1a@\n\x16GetEnvironmentResponse\x12&\n\x06python\x18\x01 \x01(\x0b\x32\x16.djls.v1.python.Python\"e\n\x06\x44jango\x1a\x17\n\x15GetProjectInfoRequest\x1a\x42\n\x16GetProjectInfoResponse\x12(\n\x07project\x18\x01 \x01(\x0b\x32\x17.djls.v1.django.Projectb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'v1.commands_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals['_CHECK']._serialized_start=74
_globals['_CHECK']._serialized_end=263
_globals['_CHECK_HEALTHREQUEST']._serialized_start=83
_globals['_CHECK_HEALTHREQUEST']._serialized_end=98
_globals['_CHECK_HEALTHRESPONSE']._serialized_start=100
_globals['_CHECK_HEALTHRESPONSE']._serialized_end=162
_globals['_CHECK_GEODJANGOPREREQSREQUEST']._serialized_start=164
_globals['_CHECK_GEODJANGOPREREQSREQUEST']._serialized_end=189
_globals['_CHECK_GEODJANGOPREREQSRESPONSE']._serialized_start=191
_globals['_CHECK_GEODJANGOPREREQSRESPONSE']._serialized_end=263
_globals['_PYTHON']._serialized_start=265
_globals['_PYTHON']._serialized_end=364
_globals['_PYTHON_GETENVIRONMENTREQUEST']._serialized_start=275
_globals['_PYTHON_GETENVIRONMENTREQUEST']._serialized_end=298
_globals['_PYTHON_GETENVIRONMENTRESPONSE']._serialized_start=300
_globals['_PYTHON_GETENVIRONMENTRESPONSE']._serialized_end=364
_globals['_DJANGO']._serialized_start=366
_globals['_DJANGO']._serialized_end=467
_globals['_DJANGO_GETPROJECTINFOREQUEST']._serialized_start=376
_globals['_DJANGO_GETPROJECTINFOREQUEST']._serialized_end=399
_globals['_DJANGO_GETPROJECTINFORESPONSE']._serialized_start=401
_globals['_DJANGO_GETPROJECTINFORESPONSE']._serialized_end=467
# @@protoc_insertion_point(module_scope)

View file

@ -1,59 +0,0 @@
# WARNING: This file is generated by protobuf. DO NOT EDIT!
# Any changes made to this file will be overwritten when the protobuf files are regenerated.
# Source: v1/commands.proto
from . import django_pb2 as _django_pb2
from . import python_pb2 as _python_pb2
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union
DESCRIPTOR: _descriptor.FileDescriptor
class Check(_message.Message):
__slots__ = ()
class HealthRequest(_message.Message):
__slots__ = ()
def __init__(self) -> None: ...
class HealthResponse(_message.Message):
__slots__ = ("passed", "error")
PASSED_FIELD_NUMBER: _ClassVar[int]
ERROR_FIELD_NUMBER: _ClassVar[int]
passed: bool
error: str
def __init__(self, passed: bool = ..., error: _Optional[str] = ...) -> None: ...
class GeoDjangoPrereqsRequest(_message.Message):
__slots__ = ()
def __init__(self) -> None: ...
class GeoDjangoPrereqsResponse(_message.Message):
__slots__ = ("passed", "error")
PASSED_FIELD_NUMBER: _ClassVar[int]
ERROR_FIELD_NUMBER: _ClassVar[int]
passed: bool
error: str
def __init__(self, passed: bool = ..., error: _Optional[str] = ...) -> None: ...
def __init__(self) -> None: ...
class Python(_message.Message):
__slots__ = ()
class GetEnvironmentRequest(_message.Message):
__slots__ = ()
def __init__(self) -> None: ...
class GetEnvironmentResponse(_message.Message):
__slots__ = ("python",)
PYTHON_FIELD_NUMBER: _ClassVar[int]
python: _python_pb2.Python
def __init__(self, python: _Optional[_Union[_python_pb2.Python, _Mapping]] = ...) -> None: ...
def __init__(self) -> None: ...
class Django(_message.Message):
__slots__ = ()
class GetProjectInfoRequest(_message.Message):
__slots__ = ()
def __init__(self) -> None: ...
class GetProjectInfoResponse(_message.Message):
__slots__ = ("project",)
PROJECT_FIELD_NUMBER: _ClassVar[int]
project: _django_pb2.Project
def __init__(self, project: _Optional[_Union[_django_pb2.Project, _Mapping]] = ...) -> None: ...
def __init__(self) -> None: ...

View file

@ -1,40 +0,0 @@
# WARNING: This file is generated by protobuf. DO NOT EDIT!
# Any changes made to this file will be overwritten when the protobuf files are regenerated.
# Source: v1/django.proto
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: v1/django.proto
# Protobuf Python Version: 5.29.1
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
5,
29,
1,
'',
'v1/django.proto'
)
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fv1/django.proto\x12\x0e\x64jls.v1.django\"\x1a\n\x07Project\x12\x0f\n\x07version\x18\x03 \x01(\tb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'v1.django_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals['_PROJECT']._serialized_start=35
_globals['_PROJECT']._serialized_end=61
# @@protoc_insertion_point(module_scope)

View file

@ -1,15 +0,0 @@
# WARNING: This file is generated by protobuf. DO NOT EDIT!
# Any changes made to this file will be overwritten when the protobuf files are regenerated.
# Source: v1/django.proto
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Optional as _Optional
DESCRIPTOR: _descriptor.FileDescriptor
class Project(_message.Message):
__slots__ = ("version",)
VERSION_FIELD_NUMBER: _ClassVar[int]
version: str
def __init__(self, version: _Optional[str] = ...) -> None: ...

View file

@ -1,47 +0,0 @@
# WARNING: This file is generated by protobuf. DO NOT EDIT!
# Any changes made to this file will be overwritten when the protobuf files are regenerated.
# Source: v1/messages.proto
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: v1/messages.proto
# Protobuf Python Version: 5.29.1
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
5,
29,
1,
'',
'v1/messages.proto'
)
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from . import commands_pb2 as v1_dot_commands__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11v1/messages.proto\x12\x10\x64jls.v1.messages\x1a\x11v1/commands.proto\"\xd2\x02\n\x07Request\x12>\n\rcheck__health\x18\x01 \x01(\x0b\x32%.djls.v1.commands.Check.HealthRequestH\x00\x12S\n\x18\x63heck__geodjango_prereqs\x18\x02 \x01(\x0b\x32/.djls.v1.commands.Check.GeoDjangoPrereqsRequestH\x00\x12R\n\x17python__get_environment\x18\xe8\x07 \x01(\x0b\x32..djls.v1.commands.Python.GetEnvironmentRequestH\x00\x12S\n\x18\x64jango__get_project_info\x18\xd0\x0f \x01(\x0b\x32..djls.v1.commands.Django.GetProjectInfoRequestH\x00\x42\t\n\x07\x63ommand\"\x81\x03\n\x08Response\x12?\n\rcheck__health\x18\x01 \x01(\x0b\x32&.djls.v1.commands.Check.HealthResponseH\x00\x12T\n\x18\x63heck__geodjango_prereqs\x18\x02 \x01(\x0b\x32\x30.djls.v1.commands.Check.GeoDjangoPrereqsResponseH\x00\x12S\n\x17python__get_environment\x18\xe8\x07 \x01(\x0b\x32/.djls.v1.commands.Python.GetEnvironmentResponseH\x00\x12T\n\x18\x64jango__get_project_info\x18\xd0\x0f \x01(\x0b\x32/.djls.v1.commands.Django.GetProjectInfoResponseH\x00\x12)\n\x05\x65rror\x18\xa8\x46 \x01(\x0b\x32\x17.djls.v1.messages.ErrorH\x00\x42\x08\n\x06result\"\xa5\x01\n\x05\x45rror\x12*\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x1c.djls.v1.messages.Error.Code\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x11\n\ttraceback\x18\x03 \x01(\t\"L\n\x04\x43ode\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x13\n\x0fINVALID_REQUEST\x10\x01\x12\x10\n\x0cPYTHON_ERROR\x10\x02\x12\x10\n\x0c\x44JANGO_ERROR\x10\x03\x62\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'v1.messages_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals['_REQUEST']._serialized_start=59
_globals['_REQUEST']._serialized_end=397
_globals['_RESPONSE']._serialized_start=400
_globals['_RESPONSE']._serialized_end=785
_globals['_ERROR']._serialized_start=788
_globals['_ERROR']._serialized_end=953
_globals['_ERROR_CODE']._serialized_start=877
_globals['_ERROR_CODE']._serialized_end=953
# @@protoc_insertion_point(module_scope)

View file

@ -1,57 +0,0 @@
# WARNING: This file is generated by protobuf. DO NOT EDIT!
# Any changes made to this file will be overwritten when the protobuf files are regenerated.
# Source: v1/messages.proto
from . import commands_pb2 as _commands_pb2
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union
DESCRIPTOR: _descriptor.FileDescriptor
class Request(_message.Message):
__slots__ = ("check__health", "check__geodjango_prereqs", "python__get_environment", "django__get_project_info")
CHECK__HEALTH_FIELD_NUMBER: _ClassVar[int]
CHECK__GEODJANGO_PREREQS_FIELD_NUMBER: _ClassVar[int]
PYTHON__GET_ENVIRONMENT_FIELD_NUMBER: _ClassVar[int]
DJANGO__GET_PROJECT_INFO_FIELD_NUMBER: _ClassVar[int]
check__health: _commands_pb2.Check.HealthRequest
check__geodjango_prereqs: _commands_pb2.Check.GeoDjangoPrereqsRequest
python__get_environment: _commands_pb2.Python.GetEnvironmentRequest
django__get_project_info: _commands_pb2.Django.GetProjectInfoRequest
def __init__(self, check__health: _Optional[_Union[_commands_pb2.Check.HealthRequest, _Mapping]] = ..., check__geodjango_prereqs: _Optional[_Union[_commands_pb2.Check.GeoDjangoPrereqsRequest, _Mapping]] = ..., python__get_environment: _Optional[_Union[_commands_pb2.Python.GetEnvironmentRequest, _Mapping]] = ..., django__get_project_info: _Optional[_Union[_commands_pb2.Django.GetProjectInfoRequest, _Mapping]] = ...) -> None: ...
class Response(_message.Message):
__slots__ = ("check__health", "check__geodjango_prereqs", "python__get_environment", "django__get_project_info", "error")
CHECK__HEALTH_FIELD_NUMBER: _ClassVar[int]
CHECK__GEODJANGO_PREREQS_FIELD_NUMBER: _ClassVar[int]
PYTHON__GET_ENVIRONMENT_FIELD_NUMBER: _ClassVar[int]
DJANGO__GET_PROJECT_INFO_FIELD_NUMBER: _ClassVar[int]
ERROR_FIELD_NUMBER: _ClassVar[int]
check__health: _commands_pb2.Check.HealthResponse
check__geodjango_prereqs: _commands_pb2.Check.GeoDjangoPrereqsResponse
python__get_environment: _commands_pb2.Python.GetEnvironmentResponse
django__get_project_info: _commands_pb2.Django.GetProjectInfoResponse
error: Error
def __init__(self, check__health: _Optional[_Union[_commands_pb2.Check.HealthResponse, _Mapping]] = ..., check__geodjango_prereqs: _Optional[_Union[_commands_pb2.Check.GeoDjangoPrereqsResponse, _Mapping]] = ..., python__get_environment: _Optional[_Union[_commands_pb2.Python.GetEnvironmentResponse, _Mapping]] = ..., django__get_project_info: _Optional[_Union[_commands_pb2.Django.GetProjectInfoResponse, _Mapping]] = ..., error: _Optional[_Union[Error, _Mapping]] = ...) -> None: ...
class Error(_message.Message):
__slots__ = ("code", "message", "traceback")
class Code(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = ()
UNKNOWN: _ClassVar[Error.Code]
INVALID_REQUEST: _ClassVar[Error.Code]
PYTHON_ERROR: _ClassVar[Error.Code]
DJANGO_ERROR: _ClassVar[Error.Code]
UNKNOWN: Error.Code
INVALID_REQUEST: Error.Code
PYTHON_ERROR: Error.Code
DJANGO_ERROR: Error.Code
CODE_FIELD_NUMBER: _ClassVar[int]
MESSAGE_FIELD_NUMBER: _ClassVar[int]
TRACEBACK_FIELD_NUMBER: _ClassVar[int]
code: Error.Code
message: str
traceback: str
def __init__(self, code: _Optional[_Union[Error.Code, str]] = ..., message: _Optional[str] = ..., traceback: _Optional[str] = ...) -> None: ...

View file

@ -1,62 +0,0 @@
# WARNING: This file is generated by protobuf. DO NOT EDIT!
# Any changes made to this file will be overwritten when the protobuf files are regenerated.
# Source: v1/python.proto
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: v1/python.proto
# Protobuf Python Version: 5.29.1
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
5,
29,
1,
'',
'v1/python.proto'
)
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fv1/python.proto\x12\x0e\x64jls.v1.python\"\x9c\x01\n\x06Python\x12\x1e\n\x02os\x18\x01 \x01(\x0b\x32\x12.djls.v1.python.Os\x12\"\n\x04site\x18\x02 \x01(\x0b\x32\x14.djls.v1.python.Site\x12 \n\x03sys\x18\x03 \x01(\x0b\x32\x13.djls.v1.python.Sys\x12,\n\tsysconfig\x18\x04 \x01(\x0b\x32\x19.djls.v1.python.Sysconfig\"f\n\x02Os\x12\x30\n\x07\x65nviron\x18\x01 \x03(\x0b\x32\x1f.djls.v1.python.Os.EnvironEntry\x1a.\n\x0c\x45nvironEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x86\x01\n\x04Site\x12\x34\n\x08packages\x18\x01 \x03(\x0b\x32\".djls.v1.python.Site.PackagesEntry\x1aH\n\rPackagesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.djls.v1.python.Package:\x02\x38\x01\"\xe0\x02\n\x03Sys\x12\x13\n\x0b\x64\x65\x62ug_build\x18\x01 \x01(\x08\x12\x10\n\x08\x64\x65v_mode\x18\x02 \x01(\x08\x12\x0f\n\x07is_venv\x18\x03 \x01(\x08\x12\x10\n\x08\x61\x62iflags\x18\x04 \x01(\t\x12\x13\n\x0b\x62\x61se_prefix\x18\x05 \x01(\t\x12\x18\n\x10\x64\x65\x66\x61ult_encoding\x18\x06 \x01(\t\x12\x12\n\nexecutable\x18\x07 \x01(\t\x12\x1b\n\x13\x66ilesystem_encoding\x18\x08 \x01(\t\x12\x1b\n\x13implementation_name\x18\t \x01(\t\x12\x10\n\x08platform\x18\n \x01(\t\x12\x0e\n\x06prefix\x18\x0b \x01(\t\x12\x1c\n\x14\x62uiltin_module_names\x18\x0c \x03(\t\x12\x11\n\tdll_paths\x18\r \x03(\t\x12\x0c\n\x04path\x18\x0e \x03(\t\x12\x31\n\x0cversion_info\x18\x0f \x01(\x0b\x32\x1b.djls.v1.python.VersionInfo\"~\n\x0bVersionInfo\x12\r\n\x05major\x18\x01 \x01(\r\x12\r\n\x05minor\x18\x02 \x01(\r\x12\r\n\x05micro\x18\x03 \x01(\r\x12\x32\n\x0creleaselevel\x18\x04 \x01(\x0e\x32\x1c.djls.v1.python.ReleaseLevel\x12\x0e\n\x06serial\x18\x05 \x01(\r\"\x96\x01\n\tSysconfig\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\t\x12\x0f\n\x07include\x18\x02 \x01(\t\x12\x13\n\x0bplatinclude\x18\x03 \x01(\t\x12\x0f\n\x07platlib\x18\x04 \x01(\t\x12\x12\n\nplatstdlib\x18\x05 \x01(\t\x12\x0f\n\x07purelib\x18\x06 \x01(\t\x12\x0f\n\x07scripts\x18\x07 \x01(\t\x12\x0e\n\x06stdlib\x18\x08 \x01(\t\"\x97\x02\n\x07Package\x12\x11\n\tdist_name\x18\x01 \x01(\t\x12\x14\n\x0c\x64ist_version\x18\x02 \x01(\t\x12\x1a\n\rdist_editable\x18\x03 \x01(\x08H\x00\x88\x01\x01\x12\x1e\n\x11\x64ist_entry_points\x18\x04 \x01(\tH\x01\x88\x01\x01\x12\x1a\n\rdist_location\x18\x05 \x01(\tH\x02\x88\x01\x01\x12\x15\n\rdist_requires\x18\x06 \x03(\t\x12!\n\x14\x64ist_requires_python\x18\x07 \x01(\tH\x03\x88\x01\x01\x42\x10\n\x0e_dist_editableB\x14\n\x12_dist_entry_pointsB\x10\n\x0e_dist_locationB\x17\n\x15_dist_requires_python*=\n\x0cReleaseLevel\x12\t\n\x05\x41LPHA\x10\x00\x12\x08\n\x04\x42\x45TA\x10\x01\x12\r\n\tCANDIDATE\x10\x02\x12\t\n\x05\x46INAL\x10\x03\x62\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'v1.python_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals['_OS_ENVIRONENTRY']._loaded_options = None
_globals['_OS_ENVIRONENTRY']._serialized_options = b'8\001'
_globals['_SITE_PACKAGESENTRY']._loaded_options = None
_globals['_SITE_PACKAGESENTRY']._serialized_options = b'8\001'
_globals['_RELEASELEVEL']._serialized_start=1353
_globals['_RELEASELEVEL']._serialized_end=1414
_globals['_PYTHON']._serialized_start=36
_globals['_PYTHON']._serialized_end=192
_globals['_OS']._serialized_start=194
_globals['_OS']._serialized_end=296
_globals['_OS_ENVIRONENTRY']._serialized_start=250
_globals['_OS_ENVIRONENTRY']._serialized_end=296
_globals['_SITE']._serialized_start=299
_globals['_SITE']._serialized_end=433
_globals['_SITE_PACKAGESENTRY']._serialized_start=361
_globals['_SITE_PACKAGESENTRY']._serialized_end=433
_globals['_SYS']._serialized_start=436
_globals['_SYS']._serialized_end=788
_globals['_VERSIONINFO']._serialized_start=790
_globals['_VERSIONINFO']._serialized_end=916
_globals['_SYSCONFIG']._serialized_start=919
_globals['_SYSCONFIG']._serialized_end=1069
_globals['_PACKAGE']._serialized_start=1072
_globals['_PACKAGE']._serialized_end=1351
# @@protoc_insertion_point(module_scope)

View file

@ -1,146 +0,0 @@
# WARNING: This file is generated by protobuf. DO NOT EDIT!
# Any changes made to this file will be overwritten when the protobuf files are regenerated.
# Source: v1/python.proto
from google.protobuf.internal import containers as _containers
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
DESCRIPTOR: _descriptor.FileDescriptor
class ReleaseLevel(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = ()
ALPHA: _ClassVar[ReleaseLevel]
BETA: _ClassVar[ReleaseLevel]
CANDIDATE: _ClassVar[ReleaseLevel]
FINAL: _ClassVar[ReleaseLevel]
ALPHA: ReleaseLevel
BETA: ReleaseLevel
CANDIDATE: ReleaseLevel
FINAL: ReleaseLevel
class Python(_message.Message):
__slots__ = ("os", "site", "sys", "sysconfig")
OS_FIELD_NUMBER: _ClassVar[int]
SITE_FIELD_NUMBER: _ClassVar[int]
SYS_FIELD_NUMBER: _ClassVar[int]
SYSCONFIG_FIELD_NUMBER: _ClassVar[int]
os: Os
site: Site
sys: Sys
sysconfig: Sysconfig
def __init__(self, os: _Optional[_Union[Os, _Mapping]] = ..., site: _Optional[_Union[Site, _Mapping]] = ..., sys: _Optional[_Union[Sys, _Mapping]] = ..., sysconfig: _Optional[_Union[Sysconfig, _Mapping]] = ...) -> None: ...
class Os(_message.Message):
__slots__ = ("environ",)
class EnvironEntry(_message.Message):
__slots__ = ("key", "value")
KEY_FIELD_NUMBER: _ClassVar[int]
VALUE_FIELD_NUMBER: _ClassVar[int]
key: str
value: str
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
ENVIRON_FIELD_NUMBER: _ClassVar[int]
environ: _containers.ScalarMap[str, str]
def __init__(self, environ: _Optional[_Mapping[str, str]] = ...) -> None: ...
class Site(_message.Message):
__slots__ = ("packages",)
class PackagesEntry(_message.Message):
__slots__ = ("key", "value")
KEY_FIELD_NUMBER: _ClassVar[int]
VALUE_FIELD_NUMBER: _ClassVar[int]
key: str
value: Package
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Package, _Mapping]] = ...) -> None: ...
PACKAGES_FIELD_NUMBER: _ClassVar[int]
packages: _containers.MessageMap[str, Package]
def __init__(self, packages: _Optional[_Mapping[str, Package]] = ...) -> None: ...
class Sys(_message.Message):
__slots__ = ("debug_build", "dev_mode", "is_venv", "abiflags", "base_prefix", "default_encoding", "executable", "filesystem_encoding", "implementation_name", "platform", "prefix", "builtin_module_names", "dll_paths", "path", "version_info")
DEBUG_BUILD_FIELD_NUMBER: _ClassVar[int]
DEV_MODE_FIELD_NUMBER: _ClassVar[int]
IS_VENV_FIELD_NUMBER: _ClassVar[int]
ABIFLAGS_FIELD_NUMBER: _ClassVar[int]
BASE_PREFIX_FIELD_NUMBER: _ClassVar[int]
DEFAULT_ENCODING_FIELD_NUMBER: _ClassVar[int]
EXECUTABLE_FIELD_NUMBER: _ClassVar[int]
FILESYSTEM_ENCODING_FIELD_NUMBER: _ClassVar[int]
IMPLEMENTATION_NAME_FIELD_NUMBER: _ClassVar[int]
PLATFORM_FIELD_NUMBER: _ClassVar[int]
PREFIX_FIELD_NUMBER: _ClassVar[int]
BUILTIN_MODULE_NAMES_FIELD_NUMBER: _ClassVar[int]
DLL_PATHS_FIELD_NUMBER: _ClassVar[int]
PATH_FIELD_NUMBER: _ClassVar[int]
VERSION_INFO_FIELD_NUMBER: _ClassVar[int]
debug_build: bool
dev_mode: bool
is_venv: bool
abiflags: str
base_prefix: str
default_encoding: str
executable: str
filesystem_encoding: str
implementation_name: str
platform: str
prefix: str
builtin_module_names: _containers.RepeatedScalarFieldContainer[str]
dll_paths: _containers.RepeatedScalarFieldContainer[str]
path: _containers.RepeatedScalarFieldContainer[str]
version_info: VersionInfo
def __init__(self, debug_build: bool = ..., dev_mode: bool = ..., is_venv: bool = ..., abiflags: _Optional[str] = ..., base_prefix: _Optional[str] = ..., default_encoding: _Optional[str] = ..., executable: _Optional[str] = ..., filesystem_encoding: _Optional[str] = ..., implementation_name: _Optional[str] = ..., platform: _Optional[str] = ..., prefix: _Optional[str] = ..., builtin_module_names: _Optional[_Iterable[str]] = ..., dll_paths: _Optional[_Iterable[str]] = ..., path: _Optional[_Iterable[str]] = ..., version_info: _Optional[_Union[VersionInfo, _Mapping]] = ...) -> None: ...
class VersionInfo(_message.Message):
__slots__ = ("major", "minor", "micro", "releaselevel", "serial")
MAJOR_FIELD_NUMBER: _ClassVar[int]
MINOR_FIELD_NUMBER: _ClassVar[int]
MICRO_FIELD_NUMBER: _ClassVar[int]
RELEASELEVEL_FIELD_NUMBER: _ClassVar[int]
SERIAL_FIELD_NUMBER: _ClassVar[int]
major: int
minor: int
micro: int
releaselevel: ReleaseLevel
serial: int
def __init__(self, major: _Optional[int] = ..., minor: _Optional[int] = ..., micro: _Optional[int] = ..., releaselevel: _Optional[_Union[ReleaseLevel, str]] = ..., serial: _Optional[int] = ...) -> None: ...
class Sysconfig(_message.Message):
__slots__ = ("data", "include", "platinclude", "platlib", "platstdlib", "purelib", "scripts", "stdlib")
DATA_FIELD_NUMBER: _ClassVar[int]
INCLUDE_FIELD_NUMBER: _ClassVar[int]
PLATINCLUDE_FIELD_NUMBER: _ClassVar[int]
PLATLIB_FIELD_NUMBER: _ClassVar[int]
PLATSTDLIB_FIELD_NUMBER: _ClassVar[int]
PURELIB_FIELD_NUMBER: _ClassVar[int]
SCRIPTS_FIELD_NUMBER: _ClassVar[int]
STDLIB_FIELD_NUMBER: _ClassVar[int]
data: str
include: str
platinclude: str
platlib: str
platstdlib: str
purelib: str
scripts: str
stdlib: str
def __init__(self, data: _Optional[str] = ..., include: _Optional[str] = ..., platinclude: _Optional[str] = ..., platlib: _Optional[str] = ..., platstdlib: _Optional[str] = ..., purelib: _Optional[str] = ..., scripts: _Optional[str] = ..., stdlib: _Optional[str] = ...) -> None: ...
class Package(_message.Message):
__slots__ = ("dist_name", "dist_version", "dist_editable", "dist_entry_points", "dist_location", "dist_requires", "dist_requires_python")
DIST_NAME_FIELD_NUMBER: _ClassVar[int]
DIST_VERSION_FIELD_NUMBER: _ClassVar[int]
DIST_EDITABLE_FIELD_NUMBER: _ClassVar[int]
DIST_ENTRY_POINTS_FIELD_NUMBER: _ClassVar[int]
DIST_LOCATION_FIELD_NUMBER: _ClassVar[int]
DIST_REQUIRES_FIELD_NUMBER: _ClassVar[int]
DIST_REQUIRES_PYTHON_FIELD_NUMBER: _ClassVar[int]
dist_name: str
dist_version: str
dist_editable: bool
dist_entry_points: str
dist_location: str
dist_requires: _containers.RepeatedScalarFieldContainer[str]
dist_requires_python: str
def __init__(self, dist_name: _Optional[str] = ..., dist_version: _Optional[str] = ..., dist_editable: bool = ..., dist_entry_points: _Optional[str] = ..., dist_location: _Optional[str] = ..., dist_requires: _Optional[_Iterable[str]] = ..., dist_requires_python: _Optional[str] = ...) -> None: ...

View file