fix web debugger, close #1629
This commit is contained in:
@@ -6,6 +6,7 @@ import gluon.validators
|
|||||||
import code
|
import code
|
||||||
from gluon.debug import communicate, web_debugger, dbg_debugger
|
from gluon.debug import communicate, web_debugger, dbg_debugger
|
||||||
from gluon._compat import thread
|
from gluon._compat import thread
|
||||||
|
from gluon.fileutils import open_file
|
||||||
import pydoc
|
import pydoc
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ def interact():
|
|||||||
if filename:
|
if filename:
|
||||||
# prevent IOError 2 on some circuntances (EAFP instead of os.access)
|
# prevent IOError 2 on some circuntances (EAFP instead of os.access)
|
||||||
try:
|
try:
|
||||||
lines = open(filename).readlines()
|
lines = open_file(filename, 'r').readlines()
|
||||||
except:
|
except:
|
||||||
lines = ""
|
lines = ""
|
||||||
lines = dict([(i + 1, l) for (i, l) in enumerate(
|
lines = dict([(i + 1, l) for (i, l) in enumerate(
|
||||||
|
|||||||
+1
-1
@@ -637,7 +637,7 @@ def run_controller_in(controller, function, environment):
|
|||||||
web2py_error=badf)
|
web2py_error=badf)
|
||||||
code = "%s\nresponse._vars=response._caller(%s)" % (code, function)
|
code = "%s\nresponse._vars=response._caller(%s)" % (code, function)
|
||||||
layer = "%s:%s" % (filename, function)
|
layer = "%s:%s" % (filename, function)
|
||||||
ccode = getcfs(layer, filename, lambda: compile2(code, layer))
|
ccode = getcfs(layer, filename, lambda: compile2(code, filename))
|
||||||
|
|
||||||
restricted(ccode, environment, layer=filename)
|
restricted(ccode, environment, layer=filename)
|
||||||
response = environment["response"]
|
response = environment["response"]
|
||||||
|
|||||||
+13
-13
@@ -89,7 +89,7 @@ def communicate(command=None):
|
|||||||
|
|
||||||
# New debugger implementation using dbg and a web UI
|
# New debugger implementation using dbg and a web UI
|
||||||
|
|
||||||
import gluon.contrib.dbg as dbg
|
import gluon.contrib.dbg as c_dbg
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
|
|
||||||
interact_lock = RLock()
|
interact_lock = RLock()
|
||||||
@@ -109,11 +109,11 @@ def check_interaction(fn):
|
|||||||
return check_fn
|
return check_fn
|
||||||
|
|
||||||
|
|
||||||
class WebDebugger(dbg.Frontend):
|
class WebDebugger(c_dbg.Frontend):
|
||||||
"""Qdb web2py interface"""
|
"""Qdb web2py interface"""
|
||||||
|
|
||||||
def __init__(self, pipe, completekey='tab', stdin=None, stdout=None):
|
def __init__(self, pipe, completekey='tab', stdin=None, stdout=None):
|
||||||
dbg.Frontend.__init__(self, pipe)
|
c_dbg.Frontend.__init__(self, pipe)
|
||||||
self.clear_interaction()
|
self.clear_interaction()
|
||||||
|
|
||||||
def clear_interaction(self):
|
def clear_interaction(self):
|
||||||
@@ -128,7 +128,7 @@ class WebDebugger(dbg.Frontend):
|
|||||||
run_lock.acquire()
|
run_lock.acquire()
|
||||||
try:
|
try:
|
||||||
while self.pipe.poll():
|
while self.pipe.poll():
|
||||||
dbg.Frontend.run(self)
|
c_dbg.Frontend.run(self)
|
||||||
finally:
|
finally:
|
||||||
run_lock.release()
|
run_lock.release()
|
||||||
|
|
||||||
@@ -149,23 +149,23 @@ class WebDebugger(dbg.Frontend):
|
|||||||
|
|
||||||
@check_interaction
|
@check_interaction
|
||||||
def do_continue(self):
|
def do_continue(self):
|
||||||
dbg.Frontend.do_continue(self)
|
c_dbg.Frontend.do_continue(self)
|
||||||
|
|
||||||
@check_interaction
|
@check_interaction
|
||||||
def do_step(self):
|
def do_step(self):
|
||||||
dbg.Frontend.do_step(self)
|
c_dbg.Frontend.do_step(self)
|
||||||
|
|
||||||
@check_interaction
|
@check_interaction
|
||||||
def do_return(self):
|
def do_return(self):
|
||||||
dbg.Frontend.do_return(self)
|
c_dbg.Frontend.do_return(self)
|
||||||
|
|
||||||
@check_interaction
|
@check_interaction
|
||||||
def do_next(self):
|
def do_next(self):
|
||||||
dbg.Frontend.do_next(self)
|
c_dbg.Frontend.do_next(self)
|
||||||
|
|
||||||
@check_interaction
|
@check_interaction
|
||||||
def do_quit(self):
|
def do_quit(self):
|
||||||
dbg.Frontend.do_quit(self)
|
c_dbg.Frontend.do_quit(self)
|
||||||
|
|
||||||
def do_exec(self, statement):
|
def do_exec(self, statement):
|
||||||
interact_lock.acquire()
|
interact_lock.acquire()
|
||||||
@@ -175,18 +175,18 @@ class WebDebugger(dbg.Frontend):
|
|||||||
# avoid spurious interaction notifications:
|
# avoid spurious interaction notifications:
|
||||||
self.set_burst(2)
|
self.set_burst(2)
|
||||||
# execute the statement in the remote debugger:
|
# execute the statement in the remote debugger:
|
||||||
return dbg.Frontend.do_exec(self, statement)
|
return c_dbg.Frontend.do_exec(self, statement)
|
||||||
finally:
|
finally:
|
||||||
interact_lock.release()
|
interact_lock.release()
|
||||||
|
|
||||||
# create the connection between threads:
|
# create the connection between threads:
|
||||||
|
|
||||||
parent_queue, child_queue = Queue.Queue(), Queue.Queue()
|
parent_queue, child_queue = Queue.Queue(), Queue.Queue()
|
||||||
front_conn = dbg.QueuePipe("parent", parent_queue, child_queue)
|
front_conn = c_dbg.QueuePipe("parent", parent_queue, child_queue)
|
||||||
child_conn = dbg.QueuePipe("child", child_queue, parent_queue)
|
child_conn = c_dbg.QueuePipe("child", child_queue, parent_queue)
|
||||||
|
|
||||||
web_debugger = WebDebugger(front_conn) # frontend
|
web_debugger = WebDebugger(front_conn) # frontend
|
||||||
dbg_debugger = dbg.Qdb(pipe=child_conn, redirect_stdio=False, skip=None) # backend
|
dbg_debugger = c_dbg.Qdb(pipe=child_conn, redirect_stdio=False, skip=None) # backend
|
||||||
dbg = dbg_debugger
|
dbg = dbg_debugger
|
||||||
|
|
||||||
# enable getting context (stack, globals/locals) at interaction
|
# enable getting context (stack, globals/locals) at interaction
|
||||||
|
|||||||
Reference in New Issue
Block a user