Skip to content

Commit 591599d

Browse files
authored
Merge pull request #25 from charlie-sans/dev
version 2.1 update!
2 parents d7dad43 + 76d1467 commit 591599d

File tree

2,353 files changed

+12556
-36722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,353 files changed

+12556
-36722
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ coderunner-web/obj
1010
coderunner_tools/coderunner-build/target
1111
runner/lib/main.build
1212
runner/lib/main.dist
13-
runner/lib/main.onefile-build
13+
runner/lib/main.onefile-build
14+
web/bin
15+
output

runner/lib/main.py renamed to .history/runner/lib/main_20240902100900.py

File renamed without changes.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import asyncio
2+
import os
3+
from config import config
4+
try:
5+
import websockets
6+
except ImportError:
7+
print("Websockets not installed. Running 'pip install websockets' to install it")
8+
os.system("pip install websockets")
9+
import websockets
10+
import pexpect
11+
import subprocess
12+
import re
13+
import sys
14+
15+
from debug import de_bug
16+
import PMSsystem
17+
18+
19+
20+
21+
conf = config()
22+
23+
password = conf.passwd
24+
25+
if not os.path.exists(conf.DIRECTORY):
26+
os.makedirs(conf.DIRECTORY)
27+
28+
os.chdir(conf.DIRECTORY)
29+
30+
if len(sys.argv) > 1:
31+
skip_next = False
32+
for idx, i in enumerate(sys.argv[1:]):
33+
if skip_next == True:
34+
skip_next = False
35+
continue
36+
match i:
37+
case "-p":
38+
password = sys.argv[idx+2]
39+
skip_next = True
40+
case "--password":
41+
password = sys.argv[idx+2]
42+
skip_next = True
43+
case _:
44+
print("Unknown argument", i)
45+
46+
async def analyze_code(code):
47+
# Write code to a temporary file
48+
with tempfile.NamedTemporaryFile(delete=False, suffix=".py") as tmp:
49+
tmp_path = tmp.name
50+
tmp.write(code.encode('utf-8'))
51+
tmp.flush()
52+
53+
# Run pyright as a subprocess
54+
result = subprocess.run(['pyright', tmp_path, '--outputjson'], capture_output=True, text=True)
55+
56+
# Delete the temporary file
57+
os.unlink(tmp_path)
58+
59+
# Parse pyright's JSON output
60+
if result.stdout:
61+
output = json.loads(result.stdout)
62+
diagnostics = output.get('generalDiagnostics', [])
63+
return json.dumps(diagnostics)
64+
else:
65+
return json.dumps({'Success': 'No output from pyright'})
66+
67+
async def PythonLSP(websocket, path):
68+
async for message in websocket:
69+
code = message
70+
diagnostics = await analyze_code(code)
71+
await websocket.send(diagnostics)
72+
73+
74+
75+
async def handler(websocket, path):
76+
print(websocket, path)
77+
match path:
78+
79+
case "/PMS":
80+
await PMSsystem.PMS(websocket, path)
81+
case "/code":
82+
await PMSsystem. Write_code_Buffer (websocket, path)
83+
84+
case _: await websocket.send("Invalid path")
85+
86+
87+
88+
89+
ws_server = websockets.serve(handler, conf.WS_HOST, conf.WS_PORT)
90+
print("CodeRunner Server version 2.0")
91+
print("TEST SERVER: Things may break")
92+
print("Server started at port", conf.WS_PORT)
93+
print("Relay started at address ws://localhost:5000/")
94+
if password != "":
95+
print("Using password authentication\nPassword:", repr(password))
96+
print("Press Ctrl+C to stop the server")
97+
if password != "":
98+
import threading # I am definitly **Not** putting this here because I am too lazy to go to the top of the file. - Carson Coder
99+
print(f"\nAuth Proxy Starting at ws://{conf.passwd_proxy_host}:{conf.passwd_proxy_port}/")
100+
threading.Thread(target=auth_proxy.main, args=(f"ws://localhost:{conf.WS_PORT}",password)).start()
101+
asyncio.get_event_loop().run_until_complete(ws_server)
102+
asyncio.get_event_loop().run_forever()

Code-Tools/Cargo.lock

Lines changed: 0 additions & 96 deletions
This file was deleted.

Code-Tools/Cargo.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.

Code-Tools/target/.rustc_info.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

Code-Tools/target/CACHEDIR.TAG

Lines changed: 0 additions & 3 deletions
This file was deleted.

Code-Tools/target/debug/.fingerprint/Code-Tools-245e91562dc50003/bin-Code-Tools.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
Binary file not shown.

Code-Tools/target/debug/.fingerprint/Code-Tools-245e91562dc50003/invoked.timestamp

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)