Skip to content

Commit 6cd960e

Browse files
committed
removed demjson dependency and moved over to Python 2.6
1 parent ee2ac6e commit 6cd960e

8 files changed

Lines changed: 13 additions & 2157 deletions

File tree

README

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ System architecture overview:
4343
The Online Python Tutor is implemented as a web application, with a
4444
JavaScript front-end making AJAX calls to a pure-Python back-end.
4545

46-
The back-end has been tested on an Apache server running Python 2.5
46+
The back-end has been tested on an Apache server running Python 2.6
4747
through CGI. Note that it will probably fail in subtle ways on other
4848
Python 2.X (and will DEFINITELY fail on Python 3.X). Peter Wentworth
4949
has create a port to Python 3.X, and hopefully we can eventually
@@ -97,8 +97,6 @@ The back-end resides in the cgi-bin/ sub-directory in this repository:
9797
grading back-end
9898
cgi-bin/pg_logger.py - the 'meat' of the back-end
9999
cgi-bin/pg_encoder.py - encodes Python data into JSON
100-
cgi-bin/demjson.py - 3rd-party JSON module, since Python 2.5
101-
doesn't have the built-in 'import json'
102100
cgi-bin/create_db.py - for optional sqlite query logging
103101
cgi-bin/db_common.py - for optional sqlite query logging
104102
cgi-bin/.htaccess - for Apache CGI execute permissions

cgi-bin/demjson.py

Lines changed: 0 additions & 2138 deletions
This file was deleted.

cgi-bin/load_question.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python2.5
1+
#!/usr/bin/python2.6
22

33
# Online Python Tutor
44
# https://github.com/pgbovine/OnlinePythonTutor/

cgi-bin/pg_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Python debugger imported via the bdb module), printing out the values
2929
# of all in-scope data structures after each executed instruction.
3030

31-
# Note that I've only tested this logger on Python 2.5, so it will
31+
# Note that I've only tested this logger on Python 2.6, so it will
3232
# probably fail in subtle ways on other Python 2.X (and will DEFINITELY
3333
# fail on Python 3.X).
3434

cgi-bin/web_exec.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python2.5
1+
#!/usr/bin/python2.6
22

33
# Online Python Tutor
44
# https://github.com/pgbovine/OnlinePythonTutor/
@@ -31,8 +31,8 @@
3131
#
3232
# Returns a complete JSON execution trace to the front-end.
3333
#
34-
# This version uses Python 2.5 on the MIT CSAIL servers.
35-
# (note that Python 2.4 doesn't work on CSAIL, but Python 2.5 does)
34+
# This version uses Python 2.6 on the MIT CSAIL servers.
35+
# (note that Python 2.4 doesn't work on CSAIL, but Python 2.6 does)
3636
#
3737
# If you want to run this script, then you'll need to change the
3838
# shebang line at the top of this file to point to your system's Python.
@@ -50,17 +50,15 @@
5050
import cgi
5151
import pg_logger
5252

53-
# Python 2.5 doesn't have a built-in json module, so I'm using a
54-
# 3rd-party module. I think you can do 'import json' in Python >= 2.6
55-
import demjson
53+
import json
5654

5755
if LOG_QUERIES:
5856
import os, time, db_common
5957

6058
def web_finalizer(output_lst):
6159
# use compactly=False to produce human-readable JSON,
6260
# except at the expense of being a LARGER download
63-
output_json = demjson.encode(output_lst, compactly=True)
61+
output_json = json.dumps(output_lst)
6462

6563
# query logging is optional
6664
if LOG_QUERIES:

cgi-bin/web_run_test.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python2.5
1+
#!/usr/bin/python2.6
22

33
# Online Python Tutor
44
# https://github.com/pgbovine/OnlinePythonTutor/
@@ -33,9 +33,7 @@
3333
import cgi
3434
import pg_logger
3535

36-
# Python 2.5 doesn't have a built-in json module, so I'm using a
37-
# 3rd-party module. I think you can do 'import json' in Python >= 2.6
38-
import demjson
36+
import json
3937

4038
user_trace = None # the FULL user trace (without any IDs, though)
4139
expect_trace_final_entry = None
@@ -67,7 +65,7 @@ def expect_script_finalizer(output_lst):
6765
# Crucial first line to make sure that Apache serves this data
6866
# correctly - DON'T FORGET THE EXTRA NEWLINES!!!:
6967
print "Content-type: text/plain; charset=iso-8859-1\n\n"
70-
output_json = demjson.encode(ret, compactly=True)
68+
output_json = json.dumps(ret)
7169
print output_json
7270

7371
else:

question.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202

203203
<p/>
204204
This application supports the core <a
205-
href="http://www.python.org/doc/2.5/">Python 2.5</a> language, with no
205+
href="http://docs.python.org/release/2.6/">Python 2.6</a> language, with no
206206
module imports or file I/O. It's meant to be used as a platform for
207207
creating programming tutorials, not for running or debugging
208208
production code.

tutor.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197

198198
<p/>
199199
This application supports the core <a
200-
href="http://www.python.org/doc/2.5/">Python 2.5</a> language, with no
200+
href="http://docs.python.org/release/2.6/">Python 2.6</a> language, with no
201201
module imports or file I/O. It's meant to be used as a platform for
202202
creating programming tutorials, not for running or debugging
203203
production code.

0 commit comments

Comments
 (0)