Compare commits
3 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
05dbe51812 | |
|
|
4b78f01c48 | |
|
|
c96c1dd4f1 |
|
|
@ -0,0 +1,7 @@
|
|||
print("b")
|
||||
|
||||
def test():
|
||||
print("bbb")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("bb")
|
||||
|
|
@ -1 +1 @@
|
|||
returnreturnreturnreturncontinuebreak user_code/prog_joined.py:13continuenextstepnextnextnextnextbreak user_code/prog_joined.py:13continuenextstepnextnextwherenextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnextnext
|
||||
break user_code/prog_joined.py:13continuebreak user_code/prog_joined.py:15nextstepnextnextwherenextwherebreak b.py:1continuecontinuebreak b.py:1nextnextnextnextnextbreak b.py:1continuebreak b.py:4break b.py:7continuenextnextnextnextnextnextbreak b.py:6break b.py:7continuenextnextcontinuecontinuebreak b.py:1break b.py:7continuecontinue
|
||||
23
console.py
23
console.py
|
|
@ -6,6 +6,7 @@ import sys
|
|||
import weakref
|
||||
from threading import Event
|
||||
from threading import RLock
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
import queue
|
||||
|
|
@ -101,12 +102,24 @@ class Console(object):
|
|||
}
|
||||
|
||||
frame_data["console_history"] = self._console_history.contents
|
||||
frame_data["stdout"] = Path("user_code/stdout.txt").read_text().replace("""
|
||||
PYDEV DEBUGGER WARNING:
|
||||
sys.settrace() should not be used when the debugger is being used.
|
||||
This may cause the debugger to stop working correctly.
|
||||
If this is needed, please check:
|
||||
http://pydev.blogspot.com/2007/06/why-cant-pydev-debugger-work-with.html
|
||||
to see how to restore the debug tracing back correctly.
|
||||
Call Location:
|
||||
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/bdb.py", line 334, in set_trace
|
||||
sys.settrace(self.trace_dispatch)
|
||||
|
||||
""", "")
|
||||
self._frame_data.contents = frame_data
|
||||
# print("frame_data: " + str(frame_data))
|
||||
print("data: " + data)
|
||||
# print("data: " + data)
|
||||
if "(Pdb)" in data:
|
||||
self._output_ok.set()
|
||||
print("释放OK琐")
|
||||
# print("释放OK琐")
|
||||
|
||||
write = writeline
|
||||
|
||||
|
|
@ -117,12 +130,12 @@ class Console(object):
|
|||
self.pdb_not_busy.wait()
|
||||
self.input_queue.put(command)
|
||||
self._output_ok.clear()
|
||||
print("设置了command: " + command)
|
||||
# print("设置了command: " + command)
|
||||
|
||||
def get_frame_data(self):
|
||||
print("f 尝试获取琐")
|
||||
# print("f 尝试获取琐")
|
||||
self._output_ok.wait()
|
||||
print("f 获取到琐")
|
||||
# print("f 获取到琐")
|
||||
c = self._frame_data.contents
|
||||
return c
|
||||
|
||||
|
|
|
|||
47
main.htm
47
main.htm
|
|
@ -94,40 +94,13 @@
|
|||
$(function() {
|
||||
var $editor = $('#editor');
|
||||
var $debugger = $('#debugger');
|
||||
var editorText = "# coding: utf-8\n" +
|
||||
"import io\n" +
|
||||
"import os\n" +
|
||||
"import sys\n" +
|
||||
"from builtins import *\n" +
|
||||
"from io import *\n" +
|
||||
"\n" +
|
||||
"sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')\n" +
|
||||
"\n" +
|
||||
"class Solution:\n" +
|
||||
" # 包含注释的方法定义\n" +
|
||||
" def twoSum(self) -> str:\n" +
|
||||
" print(\"1111\")\n" +
|
||||
" self.step()\n" +
|
||||
" print(\"22222\")\n" +
|
||||
" return \"12313\"\n" +
|
||||
" def step(self):\n" +
|
||||
" # 获取路径下所有文件\n" +
|
||||
" result = os.popen(\"ls /Users/weiwang/PycharmProjects/leetcode | grep -v pyc\").read()\n" +
|
||||
" for l in result.split():\n" +
|
||||
" if (os.path.isfile(\"/Users/weiwang/PycharmProjects/leetcode/\" + l)):\n" +
|
||||
" print(\"---- /Users/weiwang/PycharmProjects/leetcode/\" + l)\n" +
|
||||
" print(os.popen(\"cat /Users/weiwang/PycharmProjects/leetcode/\" + l).read())\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"def _driver():\n" +
|
||||
" SEPARATOR = \"\\x1b\\x09\\x1d\"\n" +
|
||||
" f = open(\"user.out\", \"wb\", 0)\n" +
|
||||
" ret = Solution().twoSum()\n" +
|
||||
" out = str.encode(ret + '\\n')\n" +
|
||||
" f.write(out)\n" +
|
||||
" sys.stdout.write(SEPARATOR)\n" +
|
||||
"if __name__ == '__main__':\n" +
|
||||
" _driver()";
|
||||
var editorText = "print(\"b\")\n" +
|
||||
"\n" +
|
||||
"def test():\n" +
|
||||
" print(\"bbb\")\n" +
|
||||
" \n" +
|
||||
"if __name__ == \"__main__\":\n" +
|
||||
" print(\"bb\")";
|
||||
var currentLine = -1;
|
||||
|
||||
function updateEditor(text) {
|
||||
|
|
@ -157,7 +130,7 @@
|
|||
$locals.html(JSON.stringify(data.locals));
|
||||
// 取控制台输出
|
||||
var $console = $('#console');
|
||||
$console.html(data.console_history);
|
||||
$console.html(data.stdout);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -214,12 +187,12 @@
|
|||
|
||||
$debugger.find('#breakpoint').on('click', function() {
|
||||
var $breakLineNo = $('#breakLineNo');
|
||||
sendRequest('http://127.0.0.1:8079/run_command', {"command": "break user_code/prog_joined.py:" + $breakLineNo.val() + ""}, updateContent);
|
||||
sendRequest('http://127.0.0.1:8079/run_command', {"command": "break b.py:" + $breakLineNo.val() + ""}, updateContent);
|
||||
});
|
||||
|
||||
$debugger.find('#removebreakpoint').on('click', function() {
|
||||
var $breakLineNo = $('#breakLineNo');
|
||||
sendRequest('http://127.0.0.1:8079/run_command', {"command": "clear user_code/prog_joined.py:" + $breakLineNo.val() + ""}, updateContent);
|
||||
sendRequest('http://127.0.0.1:8079/run_command', {"command": "clear b.py:" + $breakLineNo.val() + ""}, updateContent);
|
||||
});
|
||||
|
||||
$debugger.find('#addExpression').on('click', function() {
|
||||
|
|
|
|||
25
server.py
25
server.py
|
|
@ -1,3 +1,4 @@
|
|||
import subprocess
|
||||
import time
|
||||
import traceback
|
||||
from threading import Thread
|
||||
|
|
@ -36,21 +37,22 @@ def frame_data():
|
|||
|
||||
def run_debugger():
|
||||
global pdb
|
||||
|
||||
from user_code.prog_joined import _driver
|
||||
|
||||
pdb.debug()
|
||||
_driver()
|
||||
import b
|
||||
try:
|
||||
b.main()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@app.route("/start")
|
||||
def start():
|
||||
# 输入输出重定向处理,启动pdb调试器以后台线程运行
|
||||
try:
|
||||
# Try to import and see if it throws any syntax error
|
||||
from user_code.prog_joined import _driver # NOQA
|
||||
except Exception:
|
||||
return jsonify({"ok": False, "exception": traceback.format_exc()})
|
||||
# # 输入输出重定向处理,启动pdb调试器以后台线程运行
|
||||
# try:
|
||||
# # Try to import and see if it throws any syntax error
|
||||
# from user_code.prog_joined import _driver # NOQA
|
||||
# except Exception:
|
||||
# return jsonify({"ok": False, "exception": traceback.format_exc()})
|
||||
|
||||
global console
|
||||
global pdb
|
||||
|
|
@ -110,3 +112,6 @@ def main():
|
|||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
## 测试
|
||||
|
|
@ -1,34 +1,11 @@
|
|||
# coding: utf-8
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
from builtins import *
|
||||
from io import *
|
||||
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||||
|
||||
class Solution:
|
||||
# 包含注释的方法定义
|
||||
def twoSum(self) -> str:
|
||||
print("1111")
|
||||
self.step()
|
||||
print("22222")
|
||||
return "12313"
|
||||
def step(self):
|
||||
# 获取路径下所有文件
|
||||
result = os.popen("ls /Users/weiwang/PycharmProjects/leetcode | grep -v pyc").read()
|
||||
for l in result.split():
|
||||
if (os.path.isfile("/Users/weiwang/PycharmProjects/leetcode/" + l)):
|
||||
print("---- /Users/weiwang/PycharmProjects/leetcode/" + l)
|
||||
print(os.popen("cat /Users/weiwang/PycharmProjects/leetcode/" + l).read())
|
||||
print("b")
|
||||
|
||||
|
||||
def test():
|
||||
print("bbb")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("bb")
|
||||
|
||||
|
||||
def _driver():
|
||||
SEPARATOR = "\x1b\x09\x1d"
|
||||
f = open("user.out", "wb", 0)
|
||||
ret = Solution().twoSum()
|
||||
out = str.encode(ret + '\n')
|
||||
f.write(out)
|
||||
sys.stdout.write(SEPARATOR)
|
||||
if __name__ == '__main__':
|
||||
_driver()
|
||||
1234
user_code/stdout.txt
1234
user_code/stdout.txt
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue