1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
#!/usr/bin/python
# Copyright (C) 2012 Felix Geyer <debfx@ubuntu.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or (at your option)
# version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from launchpadlib.launchpad import Launchpad
from collections import defaultdict
import sys
import urllib2
import StringIO
import gzip
import datetime
import psycopg2, psycopg2.extensions
from kubuntuweb import *
conn = pgsqlConnect()
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()
launchpad = Launchpad.login_anonymously("kubuntu-buildstatus", "production", lpTmpDir())
ubuntu = launchpad.distributions["ubuntu"]
archive = ubuntu.main_archive
series = ubuntu.current_series
prev_series = series.parent_series
packages = parsePackageList()
archs = []
for arch in series.architectures_collection:
archs.append(arch.architecture_tag)
if "amd64" in archs:
archs.insert(0, archs.pop(archs.index("amd64")))
if "i386" in archs:
archs.insert(0, archs.pop(archs.index("i386")))
def get_http_gzip(url):
f = urllib2.urlopen(url)
compresseddata = f.read()
compressedstream = StringIO.StringIO(compresseddata)
gzipper = gzip.GzipFile(fileobj=compressedstream)
return gzipper.read()
def parse_buildlog(url):
data = get_http_gzip(url)
if "dpkg-gensymbols: warning: some symbols or patterns disappeared in the symbols file" in data:
return "symbols_missing"
elif "dpkg-gensymbols: warning: some new symbols appeared in the symbols file" in data:
return "symbols_new"
else:
return "ok"
result = defaultdict(lambda: defaultdict(defaultdict))
for package in packages:
sources = archive.getPublishedSources(distro_series=series, exact_match=True, pocket="Release", source_name=package)
try:
sources[0]
except IndexError:
print >> sys.stderr, "Package not found: " + package
continue
builds = sources[0].getBuilds()
version = sources[0].source_package_version
# workaround for packages that are copied over from the last series
try:
builds[0]
except IndexError:
sources = archive.getPublishedSources(distro_series=prev_series, exact_match=True, pocket="Release", source_name=package)
builds = sources[0].getBuilds()
version = sources[0].source_package_version
result[package]["version"] = version
for build in builds:
if build.buildstate == "Successfully built":
result[package][build.arch_tag]["buildstate"] = "success"
cur.execute("SELECT status FROM kubuntu_buildstatus WHERE build_link = %s", (build.self_link,))
row = cur.fetchone()
if row:
result[package][build.arch_tag]["symbols"] = row[0]
else:
symbols_status = parse_buildlog(build.build_log_url)
cur.execute("DELETE FROM kubuntu_buildstatus WHERE package = %s AND arch = %s", (package, build.arch_tag))
cur.execute("INSERT INTO kubuntu_buildstatus (build_link, package, arch, status) VALUES (%s, %s, %s, %s)", (build.self_link, package, build.arch_tag, symbols_status))
result[package][build.arch_tag]["symbols"] = symbols_status
elif build.buildstate == "Needs building" or build.buildstate == "Dependency wait" or build.buildstate == "Currently building":
result[package][build.arch_tag]["buildstate"] = "waiting"
else:
result[package][build.arch_tag]["buildstate"] = "failed"
result[package][build.arch_tag]["buildstate_long"] = build.buildstate
result[package][build.arch_tag]["link"] = build.web_link
result[package][build.arch_tag]["log"] = build.build_log_url
cur.execute("SELECT package, status, status_verbose, upstream_version, upstream_url FROM kubuntu_dehs")
for record in cur:
package = record[0]
result[package]["watch"]["status"] = record[1]
result[package]["watch"]["status_verbose"] = record[2]
result[package]["watch"]["upstream_version"] = record[3]
result[package]["watch"]["upstream_url"] = record[4]
print """
<html>
<head>
<title>Kubuntu build status</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="kubuntu-buildstatus.css" />
</head>
<body>
<h1 id="top">Kubuntu build status</h1>
<table class="grid">
<thead><tr>
<th>Package</th>
<th>Version</th>
"""
for arch in archs:
print "<th>%s</th>" % (arch,)
print """
<th>watch</th>
</tr></thead>
<tbody>
"""
i = 0
for package in packages:
if not package in result:
continue
if (i % 2) == 0:
trclass = "even"
else:
trclass = "odd"
i = i + 1
print '<tr class="%s" style="text-align: center;">\n' % (trclass,)
print '<td><a href="https://launchpad.net/ubuntu/+source/%s">%s</a></td>\n' % (package, package)
print '<td><a href="https://launchpad.net/ubuntu/+source/%s/%s">%s</a></td>\n' % (package, result[package]["version"], result[package]["version"])
for arch in archs:
if not "buildstate" in result[package][arch]:
print '<td> </td>\n'
continue
if result[package][arch]["buildstate"] == "waiting":
tdclass = "BUILDWAITING"
state = result[package][arch]["buildstate_long"]
elif result[package][arch]["buildstate"] == "failed":
tdclass = "BUILDFAILED"
state = result[package][arch]["buildstate_long"]
else:
if result[package][arch]["symbols"] == "symbols_missing":
state = "Missing symbols"
tdclass = "BUILDSYMBOLSMISSING"
elif result[package][arch]["symbols"] == "symbols_new":
state = "New symbols"
tdclass = "BUILDSYMBOLSNEW"
else:
tdclass = "BUILDSUCCESS"
state = "Successful"
print '<td class="%s"><a href="%s">%s</a></td>\n' % (tdclass, result[package][arch]["link"], state)
tdclass = ""
tdtext = "-"
if "watch" in result[package]:
status = result[package]["watch"]["status"]
if status == "outdated":
tdclass = "BUILDSYMBOLSMISSING"
tdtext = "<a href=\"%s\">%s</a>" % (result[package]["watch"]["upstream_url"], result[package]["watch"]["upstream_version"])
elif (status == "up_to_date") or (status == "newer"):
tdtext = result[package]["watch"]["upstream_version"]
statusVerbose = result[package]["watch"]["status_verbose"]
else:
statusVerbose = "not checked"
print '<td class="%s" title="%s">%s</td>\n' % (tdclass, statusVerbose, tdtext)
print '</tr>\n'
print """
</tbody>
</table>
"""
print "<br/><div>Last updated on %s</div>\n" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
print """
</body>
</html>
"""
# kate: space-indent on; indent-width 4; replace-tabs on; indent-mode python; remove-trailing-space on;
|