Archiv nach Schlagworten: visualisierung

Gource und Dokuwiki – Bearbeitungen visualisieren

In Anlehnung an den französischen Blogeintrag von Wolverine will ich hier einmal auf deutsch erklären, wie man die Änderungen aus einem Dokuwiki mit Gource unter Ubuntu visualisiert.

Zunächst installiert man, sofern noch nicht vorhanden, Gource:

 Bash |  copy |? 
1
sudo aptitude install gource

Anschließend muss das folgende Python-Script in eine Datei verfrachtet werden und ausführbar gemacht werden. Es dient dazu die *.changes$-Dateien vom Dokuwiki in ein für Gource lesbares Format zu bringen.

 Python |  copy |? 
01
#!/usr/bin/python
02
 
03
"""
04
This program parse logs of a dokuwiki
05
and tranform them for gource (a log viewer)
06
http://code.google.com/p/gource/
07
 
08
developped by WolverineX02
09
site : http://wolverinex02.blogspot.com
10
 
11
"""
12
 
13
import os.path
14
import getopt
15
import sys
16
import re
17
 
18
 
19
def listdirectory2(path):
20
        """list all the files like *.changes, read them and output them in gource's log syntax
21
        """
22
        for root, dirs, files in os.walk(path):
23
                for i in files:
24
                        if (re.search('\.changes$', i)):
25
                                fichier = os.path.join(root, i)
26
                                myfile = open(fichier, 'r')
27
                                for line in myfile.readlines():
28
                                        mots = line.split()
29
                                        if len(mots)>=5:
30
                                                resultat = mots[0] + "|"
31
                                                resultat += mots[4] + "|"
32
                                                resultat += translate(mots[2]) + "|"
33
                                                resultat += fichier
34
                                                print resultat
35
                                        elif len(mots)==4:
36
                                                resultat = mots[0] + "|Anonymous|"
37
                                                resultat += translate(mots[2]) + "|"
38
                                                resultat += fichier
39
                                                print resultat
40
                                myfile.close()
41
 
42
def translate(mot):
43
        """translate the dokuwiki vocabulary to the gource one
44
        C -> A
45
        E -> M
46
        other -> M
47
        """
48
        if mot == "C":
49
                return "A"
50
        elif mot == "E":
51
                return "M"
52
        else:
53
                return "M"
54
 
55
def main(argv):
56
        """principal function
57
        """
58
        try:
59
                opts, args = getopt.getopt(argv, "hd:", ["help", "dokuwiki="])
60
        except getopt.GetoptError:
61
                usage()
62
                sys.exit(2)
63
        for opt, arg in opts:
64
                if opt in ("-h","--help"):
65
                        usage()
66
                        sys.exit()
67
                elif opt in ("-d","--dokuwiki"):
68
                        print listdirectory2(arg)
69
 
70
 
71
def usage():
72
        """this function will display how to use this script
73
        """
74
        print "This script will output change logs of a dokuwiki"
75
        print "in a friendly way for gource"
76
        print "how to use it :"
77
        print "python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log"
78
        print "and then :"
79
        print "gource --log-format custom dokusort.log --stop-position 1.0 \ "
80
        print "--stop-on-idle --file-idle-time 10000000"
81
        print "---"
82
        print "-h : help "
83
        print "-d : meta directory of your dokuwiki"
84
 
85
 
86
#print listdirectory2(sys.argv[1])
87
 
88
if __name__ == "__main__":
89
        main(sys.argv[1:])

Nachdem man nun die Pythondatei (Bsp.name hier: doku2gource.py) hat, führt man folgenden Befehl aus:

 Bash |  copy |? 
1
python doku2gource.py -d ~/public_html/dokuwiki/ | sort > dokusort.log

Es ensteht die erwähnte für Gource brauchbare Logdatei. Diese wird nun wiederum an Gource weitergegeben und mit ffmpeg eine Videodatei erstellt:

 Bash |  copy |? 
1
gource --log-format custom dokusort.log --stop-position 1.0 --stop-on-idle --file-idle-time 10000000 --output-ppm-stream - | ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec mpeg4 gource.mp4

Das wars schon. Hier noch mal die mir nützlichen Links:

http://wolverinex02.blogspot.com/2010/05/gource-et-dokuwiki.html
http://code.google.com/p/gource/wiki/Videos