annotate tests/maketestwiki.py @ 315:830cf8bdcf24

implemented 'make pagepacks', updated underlay imported from: moin--main--1.5--patch-319
author Thomas Waldmann <tw@waldmann-edv.de>
date Tue, 13 Dec 2005 22:54:31 +0000
parents
children f308f9478d51
rev   line source
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
2 """
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
3 MoinMoin - make a test wiki
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
4
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
5 Usage:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
6
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
7 maketestwiki.py
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
8
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
9 @copyright: 2005 by Thomas Waldmann
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
10 @license: GNU GPL, see COPYING for details.
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
11 """
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
12
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
13 import os, sys, shutil, errno, tarfile
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
14
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
15 moinpath = os.path.join(os.path.dirname(sys.argv[0]), os.pardir)
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
16 sys.path.insert(0, os.path.abspath(moinpath))
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
17
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
18 WIKI = os.path.abspath('testwiki')
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
19 SHARE = os.path.abspath('wiki')
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
20
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
21 def removeTestWiki():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
22 print 'removing old wiki ...'
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
23 for dir in ['data', 'underlay']:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
24 try:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
25 shutil.rmtree(os.path.join(WIKI, dir))
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
26 except OSError, err:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
27 if err.errno != errno.ENOENT:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
28 raise
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
29
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
30 def copyData():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
31 print 'copying data ...'
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
32 src = os.path.join(SHARE, 'data')
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
33 dst = os.path.join(WIKI, 'data')
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
34 shutil.copytree(src, dst)
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
35 # Remove arch-ids dirs
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
36 for path, dirs, files in os.walk(dst):
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
37 for dir in dirs[:]:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
38 if dir == '.arch-ids':
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
39 shutil.rmtree(os.path.join(path, dir))
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
40 dirs.remove(dir)
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
41
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
42
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
43 def untarUnderlay():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
44 print 'untaring underlay ...'
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
45 tar = tarfile.open(os.path.join(SHARE, 'underlay.tar.bz2'), mode='r:bz2')
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
46 for member in tar:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
47 tar.extract(member, WIKI)
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
48 tar.close()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
49
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
50
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
51 def run():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
52 removeTestWiki()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
53 copyData()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
54 untarUnderlay()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
55
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
56 if __name__ == '__main__':
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
57 run()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
58