mirror of
https://github.com/iritmaximus/compilers.git
synced 2026-10-12 19:13:35 +03:00
complete wipe, moving to rust
This commit is contained in:
@@ -1 +0,0 @@
|
||||
3.12.7
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
FROM alpine:3.23 AS builder
|
||||
|
||||
RUN apk update
|
||||
RUN apk add --no-cache build-base git
|
||||
RUN apk add --no-cache cmake cmake-doc cmake-extras pkgconf
|
||||
RUN apk add --no-cache clang
|
||||
|
||||
ENV CC=/usr/bin/clang
|
||||
ENV CXX=/usr/bin/clang
|
||||
|
||||
WORKDIR /usr/src/compiler
|
||||
|
||||
COPY compiler .
|
||||
|
||||
RUN rm -rf build
|
||||
|
||||
|
||||
RUN mkdir build/ && cd build && cmake .. && make -j8
|
||||
|
||||
|
||||
FROM python:3.12-alpine3.21 AS runner
|
||||
|
||||
RUN pip install --no-cache-dir poetry==2.0.0
|
||||
RUN apk add --no-cache bash binutils
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
COPY pyproject.toml poetry.lock ./
|
||||
RUN poetry install --no-root --no-cache
|
||||
|
||||
COPY --from=builder /usr/src/compiler/build/compilers_compiler ./compilers_compiler
|
||||
COPY . .
|
||||
|
||||
RUN poetry install --no-cache && ./check.sh
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# Setting PYTHONUNBUFFERED forces print() to flush even if stdout is not a TTY.
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
CMD ["./compiler.sh", "serve", "--host=0.0.0.0"]
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "${0}")"
|
||||
poetry run mypy .
|
||||
poetry run pytest -vv tests/
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
exec poetry -C "$(dirname "${0}")" run main "$@"
|
||||
@@ -1 +0,0 @@
|
||||
build
|
||||
@@ -1,18 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(compilers_compiler CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# creates compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
set(SOURCES
|
||||
src/main.cpp
|
||||
)
|
||||
|
||||
add_library(compilers_compiler_lib ${SOURCES})
|
||||
add_executable(compilers_compiler src/main.cpp)
|
||||
|
||||
target_include_directories(compilers_compiler PRIVATE include)
|
||||
target_include_directories(compilers_compiler_lib PRIVATE include)
|
||||
target_link_libraries(compilers_compiler compilers_compiler_lib -static-libgcc -static-libstdc++)
|
||||
@@ -1,13 +0,0 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 3) {
|
||||
std::cout << "Incorrect arg count :(" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << argv[1] << argv[2] << std::endl;
|
||||
std::cout << "Hello world!" << std::endl;
|
||||
|
||||
std::ofstream result_file(argv[2]);
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
[mypy]
|
||||
disallow_untyped_defs = True
|
||||
disallow_untyped_calls = True
|
||||
Generated
-173
@@ -1,173 +0,0 @@
|
||||
# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "autopep8"
|
||||
version = "2.3.1"
|
||||
description = "A tool that automatically formats Python code to conform to the PEP 8 style guide"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "autopep8-2.3.1-py2.py3-none-any.whl", hash = "sha256:a203fe0fcad7939987422140ab17a930f684763bf7335bdb6709991dd7ef6c2d"},
|
||||
{file = "autopep8-2.3.1.tar.gz", hash = "sha256:8d6c87eba648fdcfc83e29b788910b8643171c395d9c4bcf115ece035b9c9dda"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
pycodestyle = ">=2.12.0"
|
||||
|
||||
[[package]]
|
||||
name = "colorama"
|
||||
version = "0.4.6"
|
||||
description = "Cross-platform colored terminal text."
|
||||
optional = false
|
||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
||||
files = [
|
||||
{file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
|
||||
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "2.0.0"
|
||||
description = "brain-dead simple config-ini parsing"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"},
|
||||
{file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mypy"
|
||||
version = "1.13.0"
|
||||
description = "Optional static typing for Python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "mypy-1.13.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6607e0f1dd1fb7f0aca14d936d13fd19eba5e17e1cd2a14f808fa5f8f6d8f60a"},
|
||||
{file = "mypy-1.13.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8a21be69bd26fa81b1f80a61ee7ab05b076c674d9b18fb56239d72e21d9f4c80"},
|
||||
{file = "mypy-1.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b2353a44d2179846a096e25691d54d59904559f4232519d420d64da6828a3a7"},
|
||||
{file = "mypy-1.13.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0730d1c6a2739d4511dc4253f8274cdd140c55c32dfb0a4cf8b7a43f40abfa6f"},
|
||||
{file = "mypy-1.13.0-cp310-cp310-win_amd64.whl", hash = "sha256:c5fc54dbb712ff5e5a0fca797e6e0aa25726c7e72c6a5850cfd2adbc1eb0a372"},
|
||||
{file = "mypy-1.13.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:581665e6f3a8a9078f28d5502f4c334c0c8d802ef55ea0e7276a6e409bc0d82d"},
|
||||
{file = "mypy-1.13.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3ddb5b9bf82e05cc9a627e84707b528e5c7caaa1c55c69e175abb15a761cec2d"},
|
||||
{file = "mypy-1.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:20c7ee0bc0d5a9595c46f38beb04201f2620065a93755704e141fcac9f59db2b"},
|
||||
{file = "mypy-1.13.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3790ded76f0b34bc9c8ba4def8f919dd6a46db0f5a6610fb994fe8efdd447f73"},
|
||||
{file = "mypy-1.13.0-cp311-cp311-win_amd64.whl", hash = "sha256:51f869f4b6b538229c1d1bcc1dd7d119817206e2bc54e8e374b3dfa202defcca"},
|
||||
{file = "mypy-1.13.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:5c7051a3461ae84dfb5dd15eff5094640c61c5f22257c8b766794e6dd85e72d5"},
|
||||
{file = "mypy-1.13.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:39bb21c69a5d6342f4ce526e4584bc5c197fd20a60d14a8624d8743fffb9472e"},
|
||||
{file = "mypy-1.13.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:164f28cb9d6367439031f4c81e84d3ccaa1e19232d9d05d37cb0bd880d3f93c2"},
|
||||
{file = "mypy-1.13.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a4c1bfcdbce96ff5d96fc9b08e3831acb30dc44ab02671eca5953eadad07d6d0"},
|
||||
{file = "mypy-1.13.0-cp312-cp312-win_amd64.whl", hash = "sha256:a0affb3a79a256b4183ba09811e3577c5163ed06685e4d4b46429a271ba174d2"},
|
||||
{file = "mypy-1.13.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a7b44178c9760ce1a43f544e595d35ed61ac2c3de306599fa59b38a6048e1aa7"},
|
||||
{file = "mypy-1.13.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5d5092efb8516d08440e36626f0153b5006d4088c1d663d88bf79625af3d1d62"},
|
||||
{file = "mypy-1.13.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:de2904956dac40ced10931ac967ae63c5089bd498542194b436eb097a9f77bc8"},
|
||||
{file = "mypy-1.13.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:7bfd8836970d33c2105562650656b6846149374dc8ed77d98424b40b09340ba7"},
|
||||
{file = "mypy-1.13.0-cp313-cp313-win_amd64.whl", hash = "sha256:9f73dba9ec77acb86457a8fc04b5239822df0c14a082564737833d2963677dbc"},
|
||||
{file = "mypy-1.13.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:100fac22ce82925f676a734af0db922ecfea991e1d7ec0ceb1e115ebe501301a"},
|
||||
{file = "mypy-1.13.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7bcb0bb7f42a978bb323a7c88f1081d1b5dee77ca86f4100735a6f541299d8fb"},
|
||||
{file = "mypy-1.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bde31fc887c213e223bbfc34328070996061b0833b0a4cfec53745ed61f3519b"},
|
||||
{file = "mypy-1.13.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:07de989f89786f62b937851295ed62e51774722e5444a27cecca993fc3f9cd74"},
|
||||
{file = "mypy-1.13.0-cp38-cp38-win_amd64.whl", hash = "sha256:4bde84334fbe19bad704b3f5b78c4abd35ff1026f8ba72b29de70dda0916beb6"},
|
||||
{file = "mypy-1.13.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0246bcb1b5de7f08f2826451abd947bf656945209b140d16ed317f65a17dc7dc"},
|
||||
{file = "mypy-1.13.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7f5b7deae912cf8b77e990b9280f170381fdfbddf61b4ef80927edd813163732"},
|
||||
{file = "mypy-1.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7029881ec6ffb8bc233a4fa364736789582c738217b133f1b55967115288a2bc"},
|
||||
{file = "mypy-1.13.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3e38b980e5681f28f033f3be86b099a247b13c491f14bb8b1e1e134d23bb599d"},
|
||||
{file = "mypy-1.13.0-cp39-cp39-win_amd64.whl", hash = "sha256:a6789be98a2017c912ae6ccb77ea553bbaf13d27605d2ca20a76dfbced631b24"},
|
||||
{file = "mypy-1.13.0-py3-none-any.whl", hash = "sha256:9c250883f9fd81d212e0952c92dbfcc96fc237f4b7c92f56ac81fd48460b3e5a"},
|
||||
{file = "mypy-1.13.0.tar.gz", hash = "sha256:0291a61b6fbf3e6673e3405cfcc0e7650bebc7939659fdca2702958038bd835e"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
mypy-extensions = ">=1.0.0"
|
||||
typing-extensions = ">=4.6.0"
|
||||
|
||||
[package.extras]
|
||||
dmypy = ["psutil (>=4.0)"]
|
||||
faster-cache = ["orjson"]
|
||||
install-types = ["pip"]
|
||||
mypyc = ["setuptools (>=50)"]
|
||||
reports = ["lxml"]
|
||||
|
||||
[[package]]
|
||||
name = "mypy-extensions"
|
||||
version = "1.0.0"
|
||||
description = "Type system extensions for programs checked with the mypy type checker."
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
files = [
|
||||
{file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"},
|
||||
{file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "packaging"
|
||||
version = "24.2"
|
||||
description = "Core utilities for Python packages"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"},
|
||||
{file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pluggy"
|
||||
version = "1.5.0"
|
||||
description = "plugin and hook calling mechanisms for python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"},
|
||||
{file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
dev = ["pre-commit", "tox"]
|
||||
testing = ["pytest", "pytest-benchmark"]
|
||||
|
||||
[[package]]
|
||||
name = "pycodestyle"
|
||||
version = "2.12.1"
|
||||
description = "Python style guide checker"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pycodestyle-2.12.1-py2.py3-none-any.whl", hash = "sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3"},
|
||||
{file = "pycodestyle-2.12.1.tar.gz", hash = "sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest"
|
||||
version = "8.3.3"
|
||||
description = "pytest: simple powerful testing with Python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2"},
|
||||
{file = "pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
||||
iniconfig = "*"
|
||||
packaging = "*"
|
||||
pluggy = ">=1.5,<2"
|
||||
|
||||
[package.extras]
|
||||
dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
|
||||
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
version = "4.12.2"
|
||||
description = "Backported and Experimental Type Hints for Python 3.8+"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"},
|
||||
{file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"},
|
||||
]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.12"
|
||||
content-hash = "b3bb39fa5b66f0bdb5a3c762a81c8fc01c30b0103c4ff37a063e4f2e32af0a6f"
|
||||
@@ -1,31 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "compilers-project"
|
||||
version = "0.0.0"
|
||||
description = ""
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
packages = [{include = "compiler", from = "python-src", format = ["sdist"]}]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.12"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
autopep8 = "^2.3.1"
|
||||
mypy = "^1.13.0"
|
||||
pytest = "^8.3.3"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
main = "compiler.__main__:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
pythonpath = "src"
|
||||
addopts = [
|
||||
"--import-mode=importlib",
|
||||
]
|
||||
|
||||
[virtualenvs]
|
||||
prefer-active-python = true
|
||||
@@ -1,128 +0,0 @@
|
||||
from base64 import b64encode
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from socketserver import ForkingTCPServer, StreamRequestHandler
|
||||
from traceback import format_exception
|
||||
from typing import Any
|
||||
import subprocess
|
||||
|
||||
def call_compiler(source_code: str) -> bytes:
|
||||
# *** TODO ***
|
||||
# Call your compiler here and return the compiled executable.
|
||||
# Raise an exception on compilation error.
|
||||
# *** TODO ***
|
||||
print("Compiling:", "./compilers_compiler", source_code)
|
||||
import uuid
|
||||
|
||||
# Give the compiler a file to write the result to
|
||||
filename = "compile-result-" + str(uuid.uuid4())
|
||||
response = subprocess.run(["./compilers_compiler", source_code, filename], check=True, capture_output=True).stdout
|
||||
print(response)
|
||||
|
||||
try:
|
||||
# Read the updated file and fetch compiler result
|
||||
with open(filename,"rb") as file_content:
|
||||
content = file_content.read()
|
||||
print(content)
|
||||
|
||||
except FileNotFoundError as e:
|
||||
print("File not found", filename, e)
|
||||
content = b""
|
||||
|
||||
|
||||
return content
|
||||
|
||||
|
||||
def main() -> int:
|
||||
# === Option parsing ===
|
||||
command: str | None = None
|
||||
input_file: str | None = None
|
||||
output_file: str | None = None
|
||||
host = "127.0.0.1"
|
||||
port = 3000
|
||||
for arg in sys.argv[1:]:
|
||||
if (m := re.fullmatch(r'--output=(.+)', arg)) is not None:
|
||||
output_file = m[1]
|
||||
elif (m := re.fullmatch(r'--host=(.+)', arg)) is not None:
|
||||
host = m[1]
|
||||
elif (m := re.fullmatch(r'--port=(.+)', arg)) is not None:
|
||||
port = int(m[1])
|
||||
elif arg.startswith('-'):
|
||||
raise Exception(f"Unknown argument: {arg}")
|
||||
elif command is None:
|
||||
command = arg
|
||||
elif input_file is None:
|
||||
input_file = arg
|
||||
else:
|
||||
raise Exception("Multiple input files not supported")
|
||||
|
||||
valid_commands = ['compile', 'serve']
|
||||
if command is None:
|
||||
print(f"Error: command argument missing. Valid commands: {', '.join(valid_commands)}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if command not in valid_commands:
|
||||
print(f"Error: unknown command: {command}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
def read_source_code() -> str:
|
||||
if input_file is not None:
|
||||
with open(input_file) as f:
|
||||
return f.read()
|
||||
else:
|
||||
return sys.stdin.read()
|
||||
|
||||
# === Command implementations ===
|
||||
|
||||
if command == 'compile':
|
||||
source_code = read_source_code()
|
||||
if output_file is None:
|
||||
raise Exception("Output file flag --output=... required")
|
||||
executable = call_compiler(source_code)
|
||||
with open(output_file, 'wb') as f:
|
||||
f.write(executable)
|
||||
elif command == 'serve':
|
||||
try:
|
||||
run_server(host, port)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
return 0
|
||||
|
||||
|
||||
def run_server(host: str, port: int) -> None:
|
||||
class Server(ForkingTCPServer):
|
||||
allow_reuse_address = True
|
||||
request_queue_size = 32
|
||||
|
||||
class Handler(StreamRequestHandler):
|
||||
def handle(self) -> None:
|
||||
print("Got a request?")
|
||||
result: dict[str, Any] = {}
|
||||
try:
|
||||
input_str = self.rfile.read().decode()
|
||||
print("INPUTSTR:", input_str)
|
||||
input = json.loads(input_str)
|
||||
print("JSONINPUT", input)
|
||||
if input["command"] == "compile":
|
||||
source_code = input["code"]
|
||||
executable = call_compiler(source_code)
|
||||
result["program"] = b64encode(executable).decode()
|
||||
elif input["command"] == "ping":
|
||||
pass
|
||||
else:
|
||||
result["error"] = "Unknown command: " + input['command']
|
||||
except Exception as e:
|
||||
print("ERROR!!", e)
|
||||
result["error"] = "".join(format_exception(e))
|
||||
result_str = json.dumps(result)
|
||||
print(result_str)
|
||||
self.request.sendall(str.encode(result_str))
|
||||
|
||||
print(f"Starting TCP server at {host}:{port}")
|
||||
with Server((host, port), Handler) as server:
|
||||
server.serve_forever()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
# This test file only exists so you can check that the test runner works.
|
||||
# You can delete it after writing your first real test.
|
||||
def test_dummy() -> None:
|
||||
assert 1 + 1 == 2
|
||||
Reference in New Issue
Block a user