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

« back to all changes in this revision

Viewing changes to services/svnlogservice

  • 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:
28
28
import sys
29
29
import locale
30
30
 
31
 
import cjson
 
31
try:
 
32
    import json
 
33
except ImportError:
 
34
    import simplejson as json
 
35
 
32
36
import pysvn
33
37
 
 
38
import ivle.conf
34
39
import ivle.svn
35
40
 
36
41
# Set locale to UTF-8
37
42
locale.setlocale(locale.LC_CTYPE, "en_US.UTF-8")
38
43
 
39
44
try:
40
 
    client = pysvn.Client()
 
45
    client = ivle.svn.create_auth_svn_client(username=ivle.conf.login,
 
46
                                             password=ivle.conf.svn_pass)
41
47
    client.exception_style = 1
42
48
    logs = client.log(os.path.join('/home', sys.argv[1].decode('utf-8')),
43
49
                      discover_changed_paths=True)
44
 
    print cjson.encode({'logs': [{'revno': log.revision.number,
45
 
                                  'author': log.author.decode('utf-8'),
46
 
                                  'message': log.message.decode('utf-8'),
47
 
                                  'date': log.date,
48
 
                                  'paths': [(p.path.decode('utf-8'), p.action)
49
 
                                            for p in log.changed_paths]}
50
 
                                 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]})
51
57
except pysvn.ClientError, e:
52
58
    error = e[0]
53
59
 
66
72
    except IndexError:
67
73
        pass
68
74
 
69
 
    print cjson.encode({'error': error})
 
75
    print json.dumps({'error': error})