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

« back to all changes in this revision

Viewing changes to services/serveservice

  • Committer: William Grant
  • Date: 2010-07-27 12:09:13 UTC
  • mto: This revision was merged to the branch mainline in revision 1826.
  • Revision ID: grantw@unimelb.edu.au-20100727120913-v0kfnwxzbiwrjnue
(simple)json always returns a unicode when decoding, while cjson returned a str where possible. This makes cPickle unhappy, so convert back to a str.

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)