Mercurial > treepkg
annotate contrib/sawmill/web/details.py @ 474:a8f77807d710
sawmill: create links for tag builds
author | Sascha Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 10 Sep 2010 14:18:07 +0000 |
parents | d8012571f9e1 |
children | 28aa6ac933fb |
rev | line source |
---|---|
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 # -*- coding: UTF-8 -*- |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 # |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 # Copyright (C) 2010 by Intevation GmbH |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 # Authors: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 # Sascha L. Teichmann <sascha.teichmann@intevation.de> |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 # |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 # This program is free software under the GPL (>=v2) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 # Read the file COPYING coming with the software for details. |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 from mod_python import apache, psp, util |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
12 import os |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
13 import re |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 import datetime |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 import time |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 from lxml import etree |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
18 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 BASE_DIR = "treepkgs" |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 TREEPKG_DIR = os.path.join(os.path.dirname(__file__), BASE_DIR) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
23 STATUS_LINE = re.compile(r"^([^:]+):(.+)") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
24 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 UNDER_SCORE = re.compile(r"_+(\w)") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
26 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 def _create_time(s, format="%Y-%m-%d %H:%M:%S"): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
28 return datetime.datetime(*(time.strptime(s, format)[0:6])) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
29 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 def _pretty_log_name(log): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 log = log.replace(".txt", "").replace(".gz", "").capitalize() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 return UNDER_SCORE.sub(lambda x: " %s" % x.group(1).upper(), log) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
34 class TrackItem(object): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
35 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
36 def __init__(self, treepkg, track, revision, status_file): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
37 self.treepkg = treepkg |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
38 self.track = track |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
39 self.revision = revision |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
40 self.status_file = status_file |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
41 self.loaded = False |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
42 self.status = None |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
43 self.start = None |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
44 self.stop = None |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
45 self.logs = None |
474
a8f77807d710
sawmill: create links for tag builds
Sascha Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
46 self.tags = None |
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
47 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
48 def check_loaded(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
49 if not self.loaded: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
50 f = open(self.status_file) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
51 try: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
52 for line in f: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
53 m = STATUS_LINE.match(line) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
54 if not m: continue |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
55 key, value = [x.strip() for x in m.groups()] |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
56 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
57 if key == 'status': self.status = value |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
58 elif key == 'start': self.start = _create_time(value) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
59 elif key == 'stop': self.stop = _create_time(value) |
474
a8f77807d710
sawmill: create links for tag builds
Sascha Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
60 elif key == 'tags': self.tags = value |
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
61 finally: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
62 f.close() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
63 self.loaded = True |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
64 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
65 def get_build_status(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
66 self.check_loaded() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
67 return self.status |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
68 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
69 def get_build_start(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
70 self.check_loaded() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
71 return self.start |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
72 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
73 def get_build_stop(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
74 self.check_loaded() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
75 return self.stop |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
76 |
474
a8f77807d710
sawmill: create links for tag builds
Sascha Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
77 def get_tags(self): |
a8f77807d710
sawmill: create links for tag builds
Sascha Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
78 self.check_loaded() |
a8f77807d710
sawmill: create links for tag builds
Sascha Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
79 return self.tags |
a8f77807d710
sawmill: create links for tag builds
Sascha Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
80 |
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
81 def log_path(self, log): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
82 return "%s/tracks/%s/pkg/%s/log/%s" % ( |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
83 self.treepkg, self.track, self.revision, log) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
84 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
85 def get_build_logs(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
86 oj = os.path.join |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
87 if self.logs is None: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
88 log_dir = oj(os.path.dirname(self.status_file), "log") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
89 if not os.path.isdir(log_dir): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
90 self.logs = [] |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
91 else: |
473
d8012571f9e1
sawmill: removed trailing whitespace
Sascha Teichmann <teichmann@intevation.de>
parents:
467
diff
changeset
|
92 self.logs =[(_pretty_log_name(f), self.log_path(f)) |
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
93 for f in os.listdir(log_dir) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
94 if os.path.isfile(oj(log_dir, f)) and f.find("txt") >= 0] |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
95 return self.logs |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
96 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
97 build_status = property(get_build_status) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
98 build_start = property(get_build_start) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
99 build_stop = property(get_build_stop) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
100 build_logs = property(get_build_logs) |
474
a8f77807d710
sawmill: create links for tag builds
Sascha Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
101 build_tags = property(get_tags) |
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
102 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
103 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
104 def __scan_track_items(treepkg, path): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
105 items = [] |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
106 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
107 tracks_path = os.path.join(path, "tracks") |
474
a8f77807d710
sawmill: create links for tag builds
Sascha Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
108 if os.path.isdir(tracks_path): |
467
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
109 for track in os.listdir(tracks_path): |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
110 track_path = os.path.join(tracks_path, track) |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
111 if not os.path.isdir(track_path): continue |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
112 revisions_path = os.path.join(track_path, "pkg") |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
113 if not os.path.isdir(revisions_path): continue |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
114 for revision in os.listdir(revisions_path): |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
115 revision_path = os.path.join(revisions_path, revision) |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
116 if not os.path.isdir(revision_path): continue |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
117 status_file = os.path.join(revision_path, "status") |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
118 if not os.path.isfile(status_file): continue |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
119 items.append(TrackItem(treepkg, track, revision, status_file)) |
473
d8012571f9e1
sawmill: removed trailing whitespace
Sascha Teichmann <teichmann@intevation.de>
parents:
467
diff
changeset
|
120 |
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
121 return items |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
122 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
123 def __description_header(treepkg): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
124 treepkg_xml = os.path.join(treepkg, "treepkg.xml") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
125 if os.path.isfile(treepkg_xml): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
126 xml = None |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
127 try: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
128 xml = open(treepkg_xml, "rb") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
129 dom = etree.parse(xml) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
130 finally: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
131 if xml: xml.close() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
132 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
133 description = ''.join(dom.xpath("//description/text()")) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
134 header = ''.join([etree.tostring(x, encoding="UTF-8", method="html") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
135 for x in dom.xpath("//header/*")]) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
136 return description, header |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
137 return "unknown", "" |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
138 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
139 def index(req, treepkg=''): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
140 if not treepkg: util.redirect(req, "index.py") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
141 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
142 found = None |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
143 for d in os.listdir(TREEPKG_DIR): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
144 dp = os.path.join(TREEPKG_DIR, d) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
145 if os.path.isdir(dp) and d == treepkg: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
146 found = dp |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
147 break |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
148 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
149 if not found: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
150 req.status = apache.HTTP_NOT_FOUND |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
151 return "requested TreePkg not found" |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
152 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
153 description, header = __description_header(found) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
154 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
155 track_items = __scan_track_items(treepkg, found) |
473
d8012571f9e1
sawmill: removed trailing whitespace
Sascha Teichmann <teichmann@intevation.de>
parents:
467
diff
changeset
|
156 |
d8012571f9e1
sawmill: removed trailing whitespace
Sascha Teichmann <teichmann@intevation.de>
parents:
467
diff
changeset
|
157 req.content_type = 'text/html;charset=utf-8' |
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
158 template = psp.PSP(req, filename='templates/details.html') |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
159 template.run({ |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
160 'base_dir': BASE_DIR, |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
161 'description': description, |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
162 'header': header, |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
163 'track_items': track_items |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
164 }) |