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

« back to all changes in this revision

Viewing changes to services/svnlogservice

  • Committer: William Grant
  • Date: 2009-06-24 10:47:38 UTC
  • mfrom: (1288 trunk)
  • mto: (1281.1.8 aufsless)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: grantw@unimelb.edu.au-20090624104738-ezgfy17mjzwz09i3
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

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