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

« back to all changes in this revision

Viewing changes to services/serveservice

  • Committer: William Grant
  • Date: 2010-07-30 11:52:23 UTC
  • Revision ID: grantw@unimelb.edu.au-20100730115223-bcyxqpefhp514ra8
Tags: 1.0.2
ReleaseĀ 1.0.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
def determine_file_type(filename):
38
38
    filetype = mimetypes.guess_type(filename)[0]
39
39
    if filetype is None:
40
 
         filetype = ivle.mimetypes.DEFAULT_MIMETYPE
 
40
        filetype = ivle.mimetypes.DEFAULT_MIMETYPE
41
41
    return filetype
42
42
 
43
43
def throw_error(message, extra={}):
142
142
    zipmod.make_zip(zipbasepath, paths, zipfile)
143
143
 
144
144
    print json.dumps({'type': zip_mimetype,
145
 
                      'name': zipfilename.decode('utf-8')})
 
145
                      'name': zipfilename.decode('utf-8'),
 
146
                      'size': len(zipfile.getvalue()),
 
147
                      })
146
148
 
147
149
    stream = zipfile
148
150
    stream.seek(0)
149
151
else:
150
152
 
151
153
    print json.dumps({'type': determine_file_type(filename),
152
 
                      'name': os.path.basename(filename).decode('utf-8')})
 
154
                      'name': os.path.basename(filename).decode('utf-8'),
 
155
                      'size': os.path.getsize(filename),
 
156
                      })
153
157
    stream = open(filename)
154
158
 
155
159
next = stream.read(1024)