Switch to unified view

a/scripts/create-allura-sitemap.py b/scripts/create-allura-sitemap.py
1
"""
1
"""
2
Generate Allura sitemap xml files.
2
Generate Allura sitemap xml files.
3
4
This takes a while to run on a prod-sized data set. There are a couple of
5
things that would make it faster, if we need/want to.
6
7
1. Monkeypatch forgetracker.model.ticket.Globals.bin_count to skip the
8
   refresh (Solr search) and just return zero for everything, since we don't
9
   need bin counts for the sitemap.
10
11
2. Use multiprocessing to distribute the offsets to n subprocesses.
3
"""
12
"""
4
13
5
import os, sys
14
import os, sys
6
from datetime import datetime
15
from datetime import datetime
7
from jinja2 import Template
16
from jinja2 import Template
17
18
import pylons, webob
8
from pylons import c
19
from pylons import c
9
20
10
from allura import model as M
21
from allura import model as M
11
from allura.lib import security
22
from allura.lib import security
12
from ming.orm import session, ThreadLocalORMSession
23
from ming.orm import session, ThreadLocalORMSession
...
...
39
    {% endfor %}
50
    {% endfor %}
40
</urlset>
51
</urlset>
41
"""
52
"""
42
53
43
def main(options, args):
54
def main(options, args):
55
    # This script will indirectly call app.sidebar_menu() for every app in
56
    # every project. Some of the sidebar_menu methods expect the
57
    # pylons.request threadlocal object to be present. So, we're faking it.
58
    #
59
    # The fact that this isn't a 'real' request doesn't matter for the
60
    # purposes of the sitemap.
61
    pylons.request._push_object(webob.Request.blank('/'))
62
44
    output_path = options.output_dir
63
    output_path = options.output_dir
45
    if os.path.exists(output_path):
64
    if os.path.exists(output_path):
46
        sys.exit('Error: %s directory already exists.' % output_path)
65
        sys.exit('Error: %s directory already exists.' % output_path)
47
    try:
66
    try:
48
        os.mkdir(output_path)
67
        os.mkdir(output_path)