patch_modpython.py

changeset 12
1d8dd9706f46
parent 0
de9c2efb9d02
child 13
1af94a91f439
equal deleted inserted replaced
11:b0996e4a289e 12:1d8dd9706f46
24 24
25 rcode is the return code passed back to the calling process. 25 rcode is the return code passed back to the calling process.
26 """ 26 """
27 global progName, modDir 27 global progName, modDir
28 28
29 print "Usage:" 29 print("Usage:")
30 print " %s [-h] [-d dir]" % (progName) 30 print(" %s [-h] [-d dir]" % (progName))
31 print "where:" 31 print("where:")
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 eric4 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
43 43
44 def initGlobals(): 44 def initGlobals():
76 76
77 try: 77 try:
78 filename = os.path.join(modDir, "apache.py") 78 filename = os.path.join(modDir, "apache.py")
79 f = open(filename, "r") 79 f = open(filename, "r")
80 except EnvironmentError: 80 except EnvironmentError:
81 print "The file %s does not exist. Aborting." % filename 81 print("The file %s does not exist. Aborting." % filename)
82 sys.exit(1) 82 sys.exit(1)
83 83
84 lines = f.readlines() 84 lines = f.readlines()
85 f.close() 85 f.close()
86 86
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 eric4.")
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, e: 120 except py_compile.PyCompileError as e:
121 print "Error compiling %s. Aborting" % sn 121 print("Error compiling %s. Aborting" % sn)
122 print e 122 print(e)
123 os.remove(sn) 123 os.remove(sn)
124 sys.exit(1) 124 sys.exit(1)
125 except SyntaxError, e: 125 except SyntaxError as e:
126 print "Error compiling %s. Aborting" % sn 126 print("Error compiling %s. Aborting" % sn)
127 print e 127 print(e)
128 os.remove(sn) 128 os.remove(sn)
129 sys.exit(1) 129 sys.exit(1)
130 130
131 shutil.copy(os.path.join(modDir, "apache.py"), 131 shutil.copy(os.path.join(modDir, "apache.py"),
132 os.path.join(modDir, "apache.py.orig")) 132 os.path.join(modDir, "apache.py.orig"))
137 os.remove("%sc" % sn) 137 os.remove("%sc" % sn)
138 if os.path.exists("%so" % sn): 138 if os.path.exists("%so" % sn):
139 shutil.copy("%so" % sn, modDir) 139 shutil.copy("%so" % sn, modDir)
140 os.remove("%so" % sn) 140 os.remove("%so" % sn)
141 141
142 print "Mod_python patched successfully." 142 print("Mod_python patched successfully.")
143 print "Unpatched file copied to %s." % os.path.join(modDir, "apache.py.orig") 143 print("Unpatched file copied to %s." % os.path.join(modDir, "apache.py.orig"))
144 144
145 145
146 if __name__ == "__main__": 146 if __name__ == "__main__":
147 try: 147 try:
148 main(sys.argv) 148 main(sys.argv)
149 except SystemExit: 149 except SystemExit:
150 raise 150 raise
151 except: 151 except:
152 print \ 152 print("""An internal error occured. Please report all the output of the program,
153 """An internal error occured. Please report all the output of the program,
154 including the following traceback, to eric-bugs@die-offenbachs.de. 153 including the following traceback, to eric-bugs@die-offenbachs.de.
155 """ 154 """)
156 raise 155 raise
157 156

eric ide

mercurial