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

« back to all changes in this revision

Viewing changes to scripts/svnlogservice

Changed new-style config file to a hierarchical one with nice shiny new names.
Note that this will break the previous revision's config files. Hopefully you
didn't just put IVLE into production off this branch in the past 30 minutes !!

Upgraded both compatibility layers (setup/configure.py and conf.py) to use the
new format (they both now contain a dict mapping the legacy names to the new
path names).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
# IVLE - Informatics Virtual Learning Environment
4
 
# Copyright (C) 2008 The University of Melbourne
5
 
#
6
 
# This program is free software; you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation; either version 2 of the License, or
9
 
# (at your option) any later version.
10
 
#
11
 
# This program is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program; if not, write to the Free Software
18
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 
20
 
# Script: logservice
21
 
# Author: William Grant
22
 
# Date:   08/07/2008
23
 
 
24
 
# A CGI script for viewing a Subversion log. Used by the svnlog app.
25
 
 
26
 
import os
27
 
import time
28
 
import pysvn
29
 
 
30
 
from common import cgirequest
31
 
 
32
 
req = cgirequest.CGIRequest()
33
 
req.install_error_handler()
34
 
req.content_type = "text/html"
35
 
 
36
 
req.write('<h1>Subversion Log</h1>\n')
37
 
 
38
 
 
39
 
def pretty_time(epochtime):
40
 
    return time.asctime(time.localtime(epochtime))
41
 
 
42
 
def pretty_path(path):
43
 
    return '%s %s' % (path['action'], path['path'])
44
 
 
45
 
def pretty_paths(paths):
46
 
    output = '<ul>'
47
 
    for path in paths:
48
 
        output += '<li>' + pretty_path(path) + '</li>'
49
 
    output += '</ul>'
50
 
    return output
51
 
 
52
 
def pretty_log(log):
53
 
    return '''
54
 
<div class="svnlogentry">
55
 
        <div class="svnloginfo">
56
 
                Revision <strong>%d</strong> by <strong>%s</strong> on <strong>%s</strong>
57
 
        </div>
58
 
        <pre>%s</pre>
59
 
        <hr size="1"/>
60
 
        <h2>Changed paths:</h2>
61
 
        <div class="svnlogpathlist">
62
 
        %s
63
 
        </div>
64
 
</div>''' % (log.revision.number, log.author, pretty_time(log.date),
65
 
             log.message, pretty_paths(log.changed_paths))
66
 
 
67
 
try:
68
 
    client = pysvn.Client()
69
 
    logs = client.log(os.path.join('/home', req.path), discover_changed_paths=True)
70
 
    [req.write(pretty_log(log)) for log in logs]
71
 
except pysvn.ClientError, e:
72
 
    req.write('<p><b>Error:</b></p>\n')
73
 
    req.write('<pre>%s</pre>\n' % cgi.escape(str(e)))