32 print(" -h display this help message") |
32 print(" -h display this help message") |
33 print(" -d dir where Mod_python files are installed [default %s]" % \ |
33 print(" -d dir where Mod_python files are installed [default %s]" % \ |
34 (modDir)) |
34 (modDir)) |
35 print() |
35 print() |
36 print("This script patches the file apache.py of the Mod_python distribution") |
36 print("This script patches the file apache.py of the Mod_python distribution") |
37 print("so that it will work with the eric4 debugger instead of pdb.") |
37 print("so that it will work with the eric5 debugger instead of pdb.") |
38 print("Please see mod_python.html for more details.") |
38 print("Please see mod_python.html for more details.") |
39 print() |
39 print() |
40 |
40 |
41 sys.exit(rcode) |
41 sys.exit(rcode) |
42 |
42 |
89 |
89 |
90 sn = "apache.py" |
90 sn = "apache.py" |
91 s = open(sn, "w") |
91 s = open(sn, "w") |
92 for line in lines: |
92 for line in lines: |
93 if not pdbFound and line.startswith("import pdb"): |
93 if not pdbFound and line.startswith("import pdb"): |
94 s.write("import eric4.DebugClients.Python.eric4dbgstub as pdb\n") |
94 s.write("import eric5.DebugClients.Python.eric5dbgstub as pdb\n") |
95 pdbFound = True |
95 pdbFound = True |
96 else: |
96 else: |
97 s.write(line) |
97 s.write(line) |
98 if line.startswith("import eric4"): |
98 if line.startswith("import eric5"): |
99 ericFound = True |
99 ericFound = True |
100 |
100 |
101 if not ericFound: |
101 if not ericFound: |
102 s.write("\n") |
102 s.write("\n") |
103 s.write('def initDebugger(name):\n') |
103 s.write('def initDebugger(name):\n') |
104 s.write(' """\n') |
104 s.write(' """\n') |
105 s.write(' Initialize the debugger and set the script name to be reported \n') |
105 s.write(' Initialize the debugger and set the script name to be reported \n') |
106 s.write(' by the debugger. This is a patch for eric4.\n') |
106 s.write(' by the debugger. This is a patch for eric5.\n') |
107 s.write(' """\n') |
107 s.write(' """\n') |
108 s.write(' if not pdb.initDebugger("standard"):\n') |
108 s.write(' if not pdb.initDebugger("standard"):\n') |
109 s.write(' raise ImportError("Could not initialize debugger")\n') |
109 s.write(' raise ImportError("Could not initialize debugger")\n') |
110 s.write(' pdb.setScriptname(name)\n') |
110 s.write(' pdb.setScriptname(name)\n') |
111 s.write("\n") |
111 s.write("\n") |
112 s.close() |
112 s.close() |
113 |
113 |
114 if ericFound: |
114 if ericFound: |
115 print("Mod_python is already patched for eric4.") |
115 print("Mod_python is already patched for eric5.") |
116 os.remove(sn) |
116 os.remove(sn) |
117 else: |
117 else: |
118 try: |
118 try: |
119 py_compile.compile(sn) |
119 py_compile.compile(sn) |
120 except py_compile.PyCompileError as e: |
120 except py_compile.PyCompileError as e: |