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

« back to all changes in this revision

Viewing changes to services/svnlogservice

  • Committer: William Grant
  • Date: 2009-02-25 23:04:11 UTC
  • Revision ID: grantw@unimelb.edu.au-20090225230411-lbdyl32ir0m3d59b
Make all of the services executable.

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