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

« back to all changes in this revision

Viewing changes to services/svnlogservice

  • Committer: David Coles
  • Date: 2010-07-28 10:52:48 UTC
  • mfrom: (1791.2.10 mediahandlers)
  • Revision ID: coles.david@gmail.com-20100728105248-zvbn9g72v1nsskvd
A series of HTML5 based media handlers using the <audio> and <video> tags.  
This replaces the previous page that just showed a download link (which is 
already available on the menu).

Also solves issue where media files were downloaded by the client twice (once 
in an AJAX request intended only for text).

Known issues:
    * Bug #588285: External BHO will not be able to play media due to not
      having IVLE cookie.
    * Bug #610745: Does not correctly preview revisions
    * Bug #610780: Ogg media does not work in Chromium

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import os
28
28
import sys
29
 
 
30
 
import cjson
 
29
import locale
 
30
 
 
31
try:
 
32
    import json
 
33
except ImportError:
 
34
    import simplejson as json
 
35
 
31
36
import pysvn
32
37
 
 
38
import ivle.conf
33
39
import ivle.svn
34
40
 
 
41
# Set locale to UTF-8
 
42
locale.setlocale(locale.LC_CTYPE, "en_US.UTF-8")
 
43
 
35
44
try:
36
 
    client = pysvn.Client()
 
45
    client = ivle.svn.create_auth_svn_client(username=ivle.conf.login,
 
46
                                             password=ivle.conf.svn_pass)
37
47
    client.exception_style = 1
38
 
    logs = client.log(os.path.join('/home', sys.argv[1]),
 
48
    logs = client.log(os.path.join('/home', sys.argv[1].decode('utf-8')),
39
49
                      discover_changed_paths=True)
40
 
    print cjson.encode({'logs': [{'revno': log.revision.number,
41
 
                                  'author': log.author,
42
 
                                  'message': log.message,
43
 
                                  'date': log.date,
44
 
                                  'paths': [(p.path, p.action)
45
 
                                            for p in log.changed_paths]}
46
 
                                 for log in logs]})
 
50
    print json.dumps({'logs': [{'revno': log.revision.number,
 
51
                                'author': log.author.decode('utf-8'),
 
52
                                'message': log.message.decode('utf-8'),
 
53
                                'date': log.date,
 
54
                                'paths': [(p.path.decode('utf-8'), p.action)
 
55
                                          for p in log.changed_paths]}
 
56
                               for log in logs]})
47
57
except pysvn.ClientError, e:
48
58
    error = e[0]
49
59
 
50
60
    try:
51
61
        code = e[1][0][1]
52
62
        # See subversion/include/svn_error_codes.h.
 
63
        # 150000: ERR_ENTRY_NOT_FOUND
53
64
        # 155007: WC_NOT_DIRECTORY.
54
65
        # 160006: FS_NO_SUCH_REVISION
55
66
        # 160013: FS_NOT_FOUND
56
67
        # 200005: UNVERSIONED_RESOURCE
57
 
        if code in (155007, 160006, 160013, 200005):
 
68
        if code in (150000, 155007, 160006, 160013, 200005):
58
69
            error = 'notfound'
59
70
        else:
60
71
            error = '%s (code %d)' % (error, code)
61
72
    except IndexError:
62
73
        pass
63
74
 
64
 
    print cjson.encode({'error': error})
 
75
    print json.dumps({'error': error})