]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - www/pages/builds.py
10 from web
.info
import Info
14 size
= os
.path
.getsize(file)
15 suffixes
= [("B",2**10), ("K",2**20), ("M",2**30), ("G",2**40), ("T",2**50)]
16 for suf
, lim
in suffixes
:
20 return "%s%s" % (round(size
/float(lim
/2**10),2), suf
)
24 def __init__(self
, path
, basedir
, url
):
26 self
.basedir
= basedir
27 self
.url
= os
.path
.join(url
, path
[len(basedir
)+1:])
30 f
= open("%s/.buildinfo" % path
)
31 self
.info
= f
.readlines()
35 return "<Build %s>" % self
.path
37 def __cmp__(self
, other
):
38 return cmp(float(other
.get("date")), float(self
.get("date")))
41 key
= key
.upper() + "="
42 for line
in self
.info
:
43 if line
.startswith(key
):
44 return line
.split("=")[1].rstrip("\n")
49 return self
.get("hostname")
53 return self
.get("release")
57 return time
.strftime("%Y-%m-%d %H:%M", time
.localtime(float(self
.get("date"))))
61 return self
.get("arch")
65 if not self
.get("duration") or self
.get("duration") == "":
67 return time
.strftime("%H:%M", time
.gmtime(float(self
.get("duration"))))
71 return self
.get("iso")
75 path
= "%s/packages_%s" % (self
.path
, self
.arch
,)
76 if not os
.path
.exists(path
):
78 return os
.listdir(path
)
82 dir = "/srv/www/ipfire.org/pxe"
83 for iso
in os
.listdir(dir):
85 if not iso
.endswith(".iso"):
87 if os
.readlink(os
.path
.join(dir, iso
)) == os
.path
.join(self
.path
, self
.iso
):
92 class Content(web
.Content
):
94 web
.Content
.__init
__(self
)
97 for location
in info
["nightly_builds"]:
98 # Only process correctly configured locations
99 if not location
.has_key("path") or not location
.has_key("url"):
102 # Continue if path does not exist
103 if not os
.path
.exists(location
["path"]):
106 for (dir, subdirs
, files
) in os
.walk(location
["path"]):
107 if not os
.path
.exists("%s/.buildinfo" % dir):
109 self
.builds
.append(Build(dir, location
["path"], location
["url"]))
112 def __call__(self
, lang
):
113 today
= time
.strftime("%A, %Y-%m-%d", time
.localtime())
116 ret
= """<h3>Nightly builds</h3>
122 <th>Host & Date</th>
128 # if there are no builds
130 ret
+= """<tr class="headline"><td colspan="6">There are currently no builds available.</td></tr>"""
133 for build
in self
.builds
:
135 day
= time
.strftime("%A, %Y-%m-%d", time
.localtime(float(build
.get("date"))))
138 ret
+= """<tr class="headline"><td colspan="5">Today</td></tr>"""
140 ret
+= """<tr class="headline"><td colspan="5"> <br /> <br />%s</td></tr>""" % day
143 ret
+= """<tr class="build">
144 <td><a href="%s" target="_blank">""" % build
.url
147 ret
+= """<img src="/images/icons/ipfire.png" alt="IPFire" /></a></td>"""
149 ret
+= """<img src="/images/icons/ipfire_sw.png" alt="IPFire" /></a></td>"""
153 <strong>%(release)s</strong> (%(arch)s) %(pxe)s<br />
154 <a href="%(url)s/%(iso)s">%(iso)s</a> %(size_iso)s</td>
157 %(date)s [%(duration)sh]</td>
158 <td class="packages">%(num_packages)s <a href="%(url)s/packages_%(arch)s/" target="_blank">[PAKS]</a></td>
159 </tr>""" % { "release" : build
.release
,
160 "hostname" : build
.hostname
,
163 "duration" : build
.duration
,
166 "size_iso" : size(os
.path
.join(build
.path
, build
.iso
)),
167 "num_packages" : len(build
.packages
),
178 page
.content
= Content()
179 page
.sidebar
= web
.elements
.DevelopmentSidebar()
181 ### Disabled because it looks awful
182 #page.javascript = web.javascript.Javascript(jquery=1)
183 #page.javascript.jquery_plugin("alternate")
184 #page.javascript.write("""
185 # <script type="text/javascript">
187 # $("#builds tbody tr.build").alternate({odd:'odd', even:'even'});