4 from report
import Report
5 from version
import Version
6 from component
import Component
8 UBUNTU_STABLE
= 'intrepid'
11 class WebReport(object):
12 def __init__(self
, filename
):
13 self
.report
= Report()
14 self
.out
= open(filename
, 'w')
17 self
.out
.write('<html>')
18 self
.out
.write('''<style type="text/css">
28 td.dunno { background: #aaa; }
29 td.sync { background: #fcaf3e; }
30 td.uptodate { background: #8ae234; }
31 td.needsync { background: #3465a4; }
32 thead tr { background: #555753; color: white; }
35 self
.out
.write('<body>')
36 self
.out
.write('<h1>Telepathy components</h1>')
37 self
.out
.write('<table>')
40 self
.out
.write('<thead>')
41 self
.out
.write('<tr>')
42 self
.out
.write('<th>Component</th>')
43 self
.out
.write('<th>Upstream</th>')
44 self
.out
.write('<th>Debian Sid</th>')
45 self
.out
.write('<th>Debian Experimental</th>')
46 self
.out
.write('<th>Ubuntu Jaunty</th>')
47 self
.out
.write('<th>JHBuild</th>')
48 if Component
.ppa_enabled():
49 self
.out
.write('<th>Ubuntu Stable (+PPA)</th>')
50 self
.out
.write('</tr>')
51 self
.out
.write('</thead>')
53 self
.out
.write('<tbody>')
54 for component
in self
.report
.components
:
55 self
.out
.write('<tr>')
56 self
.out
.write('<th>%s</th>' % component
)
57 self
.out
.write('<td class="uptodate">%s</td>' % component
.upstream
)
59 # biggest Debian version
60 debian_ver
= max(component
.debian
.get('unstable'), component
.debian
.get('experimental'))
62 for distro
, distro_version
in (
63 ('debian', 'unstable'),
64 ('debian', 'experimental'),
65 ('ubuntu', UBUNTU_DEV
),
66 ('jhbuild', 'trunk')):
67 version_number
= getattr(component
, distro
).get(distro_version
)
68 if distro
== 'ubuntu' and debian_ver
== component
.upstream
and version_number
< debian_ver
:
69 # Need to sync Ubuntu package on Debian
71 elif distro
== 'ubuntu' and debian_ver
< component
.upstream
and version_number
== debian_ver
:
72 # Ubuntu package is sync with Debian but not with upstream
74 elif version_number
< component
.upstream
:
79 self
.out
.write('<td class="%s">%s</td>' % (status
, version_number
))
81 if Component
.ppa_enabled():
82 # add Ubuntu stable + PPA
83 ubuntu_stable_ver
= max(component
.ubuntu
.get(UBUNTU_STABLE
), component
.ppa
.get(UBUNTU_STABLE
))
84 if ubuntu_stable_ver
== component
.upstream
:
86 elif ubuntu_stable_ver
== component
.ubuntu
.get(UBUNTU_DEV
):
87 # sync with Ubuntu dev but not with upstream
89 elif component
.ubuntu
.get(UBUNTU_DEV
) == component
.upstream
:
90 # need to sync with Ubuntu dev
95 self
.out
.write('<td class="%s">%s</td>' % (status
, ubuntu_stable_ver
))
97 self
.out
.write('</tr>')
98 self
.out
.write('</tbody>')
99 self
.out
.write('</table>')
102 self
.out
.write('<br/><br/>')
103 self
.out
.write('<table>')
104 self
.out
.write('<thead>')
105 self
.out
.write('<tr><th>Legend</th></tr>')
106 self
.out
.write('</thead>')
107 self
.out
.write('<tr><td class="uptodate">Up to date</td><td>Package is up to date with upstream</td></tr>')
108 self
.out
.write('<tr><td class="needsync">Need Sync</td><td>Package just have to be synced to be up to date</td></tr>')
109 self
.out
.write('<tr><td class="sync">Sync</td><td>Package is synced but not up to date with upstream</td></tr>')
110 self
.out
.write('</table>')
112 self
.out
.write('<p><center>Generated: %s</center></p>' % datetime
.datetime
.utcnow().strftime('%d-%m-%y %H:%M:%S %z'))
113 self
.out
.write('</body>')
114 self
.out
.write('</html>')
117 if __name__
== '__main__':
118 web
= WebReport(sys
.argv
[1])