Mercurial > treepkg
annotate contrib/sawmill/web/details.py @ 470:a4bf8280ed0b
sawmill: Sort treepkgs in overview by description
author | Sascha Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 10 Sep 2010 09:30:48 +0000 |
parents | 7fd8af79e652 |
children | d8012571f9e1 |
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 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
46 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
47 def check_loaded(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
48 if not self.loaded: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
49 f = open(self.status_file) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
50 try: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
51 for line in f: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
52 m = STATUS_LINE.match(line) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
53 if not m: continue |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
54 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
|
55 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
56 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
|
57 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
|
58 elif key == 'stop': self.stop = _create_time(value) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
59 finally: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
60 f.close() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
61 self.loaded = True |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
62 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
63 def get_build_status(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
64 self.check_loaded() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
65 return self.status |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
66 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
67 def get_build_start(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
68 self.check_loaded() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
69 return self.start |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
70 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
71 def get_build_stop(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
72 self.check_loaded() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
73 return self.stop |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
74 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
75 def log_path(self, log): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
76 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
|
77 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
|
78 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
79 def get_build_logs(self): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
80 oj = os.path.join |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
81 if self.logs is None: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
82 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
|
83 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
|
84 self.logs = [] |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
85 else: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
86 self.logs =[(_pretty_log_name(f), self.log_path(f)) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
87 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
|
88 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
|
89 return self.logs |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
90 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
91 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
|
92 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
|
93 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
|
94 build_logs = property(get_build_logs) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
95 |
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 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
|
98 items = [] |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
99 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
100 tracks_path = os.path.join(path, "tracks") |
467
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
101 if os.path.isdir(track_path): |
7fd8af79e652
check if tracks directory exists before walking it.
Sascha Teichmann <teichmann@intevation.de>
parents:
463
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 items.append(TrackItem(treepkg, track, revision, status_file)) |
452
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
113 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
114 return items |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
115 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
116 def __description_header(treepkg): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
117 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
|
118 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
|
119 xml = None |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
120 try: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
121 xml = open(treepkg_xml, "rb") |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
122 dom = etree.parse(xml) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
123 finally: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
124 if xml: xml.close() |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
125 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 return description, header |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
130 return "unknown", "" |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
131 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
132 def index(req, treepkg=''): |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
133 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
|
134 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
135 found = None |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 found = dp |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
140 break |
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 if not found: |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
143 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
|
144 return "requested TreePkg not found" |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
145 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
146 description, header = __description_header(found) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
147 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
148 track_items = __scan_track_items(treepkg, found) |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
149 |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
150 req.content_type = 'text/html;charset=utf-8' |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
151 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
|
152 template.run({ |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
153 'base_dir': BASE_DIR, |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
154 'description': description, |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
155 'header': header, |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
156 'track_items': track_items |
333232953771
Initial check-in of sawmill a simple mod_python based
Sascha Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
157 }) |