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

« back to all changes in this revision

Viewing changes to services/diffservice

  • Committer: Matt Giuca
  • Date: 2010-07-20 12:16:51 UTC
  • mto: This revision was merged to the branch mainline in revision 1818.
  • Revision ID: matt.giuca@gmail.com-20100720121651-rgeeztj6jn1tsrou
Submit page: No longer disables the radio button for closed projects.
Displays them in red rather than grey (grey implies disabled, red implies caution).
Added notice that the deadline has passed, but submission can still be done with a penalty.

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
29
30
 
30
31
import cjson
31
32
import pysvn
32
33
 
 
34
import ivle.conf
33
35
import ivle.svn
34
36
 
 
37
# Set locale to UTF-8
 
38
locale.setlocale(locale.LC_CTYPE, "en_US.UTF-8")
35
39
 
36
40
# Default revisions
37
41
revs = [pysvn.Revision(x) for x in [pysvn.opt_revision_kind.base,
45
49
 
46
50
# Attempt to get the diff for these revisons
47
51
try:
48
 
    svnclient = pysvn.Client()
 
52
    svnclient = ivle.svn.create_auth_svn_client(username=ivle.conf.login,
 
53
                                                password=ivle.conf.svn_pass)
49
54
    svnclient.exception_style = 1
50
55
    diff = svnclient.diff
51
 
    diff_text = diff( '/tmp/svndiff',
 
56
 
 
57
    # pysvn's diff tempfile behaviour changes with Subversion 1.6.x.
 
58
    # < 1.6 wants a filename, >= 1.6 wants a directory.
 
59
    if pysvn.svn_version > (1, 6):
 
60
        tmp_path = '/tmp'
 
61
    else:
 
62
        tmp_path = '/tmp/svndiff'
 
63
 
 
64
    diff_text = diff(tmp_path,
52
65
        os.path.join('/home', sys.argv[1]),
53
66
        revision1=revs[0],
54
67
        revision2=revs[1]
55
68
    )
56
 
    print cjson.encode({'diff': diff_text})
 
69
    print cjson.encode({'diff': diff_text.decode('utf-8')})
57
70
except pysvn.ClientError, e:
58
71
    error = e[0]
59
72
 
60
73
    try:
61
74
        code = e[1][0][1]
62
75
        # See subversion/include/svn_error_codes.h.
 
76
        # 150000: ERR_ENTRY_NOT_FOUND
63
77
        # 155007: WC_NOT_DIRECTORY.
64
78
        # 160013: FS_NOT_FOUND
65
79
        # 200005: UNVERSIONED_RESOURCE
66
 
        if code in (155007, 160013, 200005):
 
80
        if code in (150000, 155007, 160013, 200005):
67
81
            error = 'notfound'
68
82
        else:
69
83
            error = '%s (code %d)' % (error, code)