~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to services/serveservice

  • Committer: William Grant
  • Date: 2010-07-28 04:13:05 UTC
  • mfrom: (1801.1.2 die-cjson-die)
  • Revision ID: grantw@unimelb.edu.au-20100728041305-xwypm3cn1l1mnki1
Port from cjson to (simple)json.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import StringIO
26
26
from optparse import OptionParser
27
27
 
28
 
import cjson
 
28
try:
 
29
    import json
 
30
except ImportError:
 
31
    import simplejson as json
29
32
 
30
33
from ivle import zip as zipmod
31
34
import ivle.conf.app.server
40
43
def throw_error(message, extra={}):
41
44
    error = {'error': message}
42
45
    error.update(extra)
43
 
    print cjson.encode(error)
 
46
    print json.dumps(error)
44
47
    sys.exit(0)
45
48
 
46
49
parser = OptionParser()
138
141
    zipfile = StringIO.StringIO()
139
142
    zipmod.make_zip(zipbasepath, paths, zipfile)
140
143
 
141
 
    print cjson.encode({'type': zip_mimetype,
142
 
                        'name': zipfilename.decode('utf-8')})
 
144
    print json.dumps({'type': zip_mimetype,
 
145
                      'name': zipfilename.decode('utf-8')})
143
146
 
144
147
    stream = zipfile
145
148
    stream.seek(0)
146
149
else:
147
150
 
148
 
    print cjson.encode({'type': determine_file_type(filename),
149
 
                        'name': os.path.basename(filename).decode('utf-8')})
 
151
    print json.dumps({'type': determine_file_type(filename),
 
152
                      'name': os.path.basename(filename).decode('utf-8')})
150
153
    stream = open(filename)
151
 
    
 
154
 
152
155
next = stream.read(1024)
153
156
while next:
154
157
    sys.stdout.write(next)