~ubuntu-branches/ubuntu/karmic/eric/karmic

« back to all changes in this revision

Viewing changes to eric/patch_modpython.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2008-01-28 18:02:25 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080128180225-6nrox6yrworh2c4v
Tags: 4.0.4-1ubuntu1
* Add python-qt3 to build-depends becuase that's where Ubuntu puts 
  pyqtconfig
* Change maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
# Copyright (c) 2003-2007 Detlev Offenbach <detlev@die-offenbachs.de>
4
4
#
5
 
# This is a  script to patch Mod_python for eric3. 
 
5
# This is a  script to patch mod_python for eric4. 
6
6
 
7
7
"""
8
 
Script to patch mod_python for usage with the eric3 IDE.
 
8
Script to patch mod_python for usage with the eric4 IDE.
9
9
"""
10
10
 
11
11
import sys
30
30
    print "    %s [-h] [-d dir]" % (progName)
31
31
    print "where:"
32
32
    print "    -h             display this help message"
33
 
    print "    -d dir         where Mod_python files are installed [default %s]" % (modDir)
 
33
    print "    -d dir         where Mod_python files are installed [default %s]" % \
 
34
        (modDir)
34
35
    print
35
36
    print "This script patches the file apache.py of the Mod_python distribution"
36
 
    print "so that it will work with the eric3 debugger instead of pdb."
 
37
    print "so that it will work with the eric4 debugger instead of pdb."
37
38
    print "Please see mod_python.html for more details."
38
39
    print
39
40
 
72
73
        elif opt == "-d":
73
74
            global modDir
74
75
            modDir = arg
75
 
            
 
76
    
76
77
    try:
77
 
        f = open(os.path.join(modDir, "apache.py"), "r")
 
78
        filename = os.path.join(modDir, "apache.py")
 
79
        f = open(filename, "r")
78
80
    except:
79
 
        print "The file %s does not exist. Aborting."
 
81
        print "The file %s does not exist. Aborting." % filename
80
82
        sys.exit(1)
81
 
        
 
83
    
82
84
    lines = f.readlines()
83
85
    f.close()
84
86
    
85
 
    pdbFound = 0
86
 
    ericFound = 0
 
87
    pdbFound = False
 
88
    ericFound = False
87
89
    
88
90
    sn = "apache.py"
89
91
    s = open(sn, "w")
90
92
    for line in lines:
91
93
        if not pdbFound and line.startswith("import pdb"):
92
 
            s.write("import eric3.DebugClients.Python.eric3dbgstub as pdb\n")
93
 
            pdbFound = 1
 
94
            s.write("import eric4.DebugClients.Python.eric4dbgstub as pdb\n")
 
95
            pdbFound = True
94
96
        else:
95
97
            s.write(line)
96
 
            if line.startswith("import eric3"):
97
 
                ericFound = 1
98
 
                
 
98
            if line.startswith("import eric4"):
 
99
                ericFound = True
 
100
    
99
101
    if not ericFound:
100
102
        s.write("\n")
101
103
        s.write('def initDebugger(name):\n')
102
104
        s.write('    """\n')
103
105
        s.write('    Initialize the debugger and set the script name to be reported \n')
104
 
        s.write('    by the debugger. This is a patch for eric3.\n')
 
106
        s.write('    by the debugger. This is a patch for eric4.\n')
105
107
        s.write('    """\n')
106
 
        s.write('    if not pdb.initDebugger("noqt"):\n')
 
108
        s.write('    if not pdb.initDebugger("standard"):\n')
107
109
        s.write('        raise ImportError("Could not initialize debugger")\n')
108
110
        s.write('    pdb.setScriptname(name)\n')
109
111
        s.write("\n")
110
112
    s.close()
111
113
    
112
114
    if ericFound:
113
 
        print "Mod_python is already patched for eric3."
 
115
        print "Mod_python is already patched for eric4."
114
116
        os.remove(sn)
115
117
    else:
116
118
        try:
120
122
            print e
121
123
            os.remove(sn)
122
124
            sys.exit(1)
123
 
            
 
125
        except SyntaxError, e:
 
126
            print "Error compiling %s. Aborting" % sn
 
127
            print e
 
128
            os.remove(sn)
 
129
            sys.exit(1)
 
130
        
124
131
        shutil.copy(os.path.join(modDir, "apache.py"),
125
132
                    os.path.join(modDir, "apache.py.orig"))
126
133
        shutil.copy(sn, modDir)