def start(username, password, host='127.0.0.1', port=26200, server_type='zope'): global auth_str, debug_server, connection if debug_server is not None: raise RuntimeError, 'The debug server is already running' # Create the debug server. if server_type == 'zope': from ZopeScriptDebugServer import ZopeScriptDebugServer ds = ZopeScriptDebugServer() elif server_type == 'basic': ds = DebugServer() else: raise ValueError, 'Unknown debug server type: %s' % server_type connection = DebuggerConnection(ds) connection.allowEnvChanges() # Allow changing of sys.path, etc. # Create an authentication string. auth_str = base64.encodestring('%s:%s' % (username, password)).strip() debug_server = ds server = TaskingTCPServer((host, port), DebugRequestHandler) port = int(server.socket.getsockname()[1]) # Provide a hard breakpoint hook. Use it like this: # if hasattr(sys, 'breakpoint'): sys.breakpoint() sys.breakpoint = debug_server.set_trace sys.debugger_control = debug_server sys.boa_debugger = debug_server def serve_forever(server): while 1: server.handle_request() def startDaemon(target, args=()): t = threading.Thread(target=target, args=args) t.setDaemon(1) t.start() startDaemon(serve_forever, (server, )) #startDaemon(debug_server.servicerThread) print >> sys.stderr, "Debug server listening on %s:%s" % tuple( server.socket.getsockname()[:2]) try: import atexit except ImportError: pass else: atexit.register(server.socket.close)
def start(username, password, host='127.0.0.1', port=26200, server_type='zope'): global auth_str, debug_server, connection if debug_server is not None: raise RuntimeError, 'The debug server is already running' # Create the debug server. if server_type == 'zope': from ZopeScriptDebugServer import ZopeScriptDebugServer ds = ZopeScriptDebugServer() elif server_type == 'basic': ds = DebugServer() else: raise ValueError, 'Unknown debug server type: %s' % server_type connection = DebuggerConnection(ds) connection.allowEnvChanges() # Allow changing of sys.path, etc. # Create an authentication string. auth_str = base64.encodestring('%s:%s' % (username, password)).strip() debug_server = ds server = TaskingTCPServer((host, port), DebugRequestHandler) port = int(server.socket.getsockname()[1]) # Provide a hard breakpoint hook. Use it like this: # if hasattr(sys, 'breakpoint'): sys.breakpoint() sys.breakpoint = debug_server.set_trace sys.debugger_control = debug_server sys.boa_debugger = debug_server def serve_forever(server): while 1: server.handle_request() def startDaemon(target, args=()): t = threading.Thread(target=target, args=args) t.setDaemon(1) t.start() startDaemon(serve_forever, (server,)) #startDaemon(debug_server.servicerThread) print >> sys.stderr, "Debug server listening on %s:%s" % tuple( server.socket.getsockname()[:2]) try: import atexit except ImportError: pass else: atexit.register(server.socket.close)
def main(args=None): global auth_str, debug_server, connection, serving # Create the debug server. if args is None: args = sys.argv[1:] if args and "--zope" in args: from ZopeScriptDebugServer import ZopeScriptDebugServer debug_server = ZopeScriptDebugServer() else: debug_server = DebugServer() connection = DebuggerConnection(debug_server) connection.allowEnvChanges() # Allow changing of sys.path, etc. # Create an authentication string, always 40 characters. auth_str = sha.new(str(random.random())).hexdigest() # port is 0 to allocate any port. server = TaskingTCPServer(("", 0), DebugRequestHandler) port = int(server.socket.getsockname()[1]) # Tell the client what port to connect to and the auth string to send. sys.stdout.write("%010d %s%s" % (port, auth_str, os.linesep)) sys.stdout.flush() # Provide a hard breakpoint hook. Use it like this: # if hasattr(sys, 'breakpoint'): sys.breakpoint() sys.breakpoint = debug_server.set_trace sys.debugger_control = debug_server sys.boa_debugger = debug_server def serve_forever(server): while 1: server.handle_request() def startDaemon(target, args=()): t = threading.Thread(target=target, args=args) t.setDaemon(1) t.start() startDaemon(serve_forever, (server,)) startDaemon(streamFlushThread) startDaemon(debug_server.servicerThread) # Serve until the stdin pipe closes. # print 'serving until stdin returns EOF' # sys.stdin.read() while serving: time.sleep(0.1) sys.exit(0)
def main(args=None): global auth_str, debug_server, connection, serving # Create the debug server. if args is None: args = sys.argv[1:] if args and '--zope' in args: from ZopeScriptDebugServer import ZopeScriptDebugServer debug_server = ZopeScriptDebugServer() else: debug_server = DebugServer() connection = DebuggerConnection(debug_server) connection.allowEnvChanges() # Allow changing of sys.path, etc. # Create an authentication string, always 40 characters. auth_str = sha.new(str(random.random())).hexdigest() # port is 0 to allocate any port. server = TaskingTCPServer(('', 0), DebugRequestHandler) port = int(server.socket.getsockname()[1]) # Tell the client what port to connect to and the auth string to send. sys.stdout.write('%010d %s%s' % (port, auth_str, os.linesep)) sys.stdout.flush() # Provide a hard breakpoint hook. Use it like this: # if hasattr(sys, 'breakpoint'): sys.breakpoint() sys.breakpoint = debug_server.set_trace sys.debugger_control = debug_server sys.boa_debugger = debug_server def serve_forever(server): while 1: server.handle_request() def startDaemon(target, args=()): t = threading.Thread(target=target, args=args) t.setDaemon(1) t.start() startDaemon(serve_forever, (server, )) startDaemon(streamFlushThread) startDaemon(debug_server.servicerThread) # Serve until the stdin pipe closes. #print 'serving until stdin returns EOF' #sys.stdin.read() while serving: time.sleep(0.1) sys.exit(0)