patch_modpython.py

changeset 15
f6ccc31d6e72
parent 13
1af94a91f439
child 45
9a18f4dbb493
equal deleted inserted replaced
14:092aa8fafa4e 15:f6ccc31d6e72
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 2
3 # Copyright (c) 2003-2010 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2003-2010 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 # This is a script to patch mod_python for eric4. 5 # This is a script to patch mod_python for eric5.
6 6
7 """ 7 """
8 Script to patch mod_python for usage with the eric4 IDE. 8 Script to patch mod_python for usage with the eric5 IDE.
9 """ 9 """
10 10
11 import sys 11 import sys
12 import os 12 import os
13 import shutil 13 import shutil
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:
151 except: 151 except:
152 print("""An internal error occured. Please report all the output of the program, 152 print("""An internal error occured. Please report all the output of the program,
153 including the following traceback, to eric-bugs@die-offenbachs.de. 153 including the following traceback, to eric-bugs@die-offenbachs.de.
154 """) 154 """)
155 raise 155 raise
156

eric ide

mercurial