~ursinha/+junk/putting-stuff-together

« back to all changes in this revision

Viewing changes to desktop/desktop-bugs.py

  • Committer: Ursula Junque
  • Date: 2011-08-15 06:09:05 UTC
  • Revision ID: ursinha@canonical.com-20110815060905-3zk371h7w3x6uvr5
Refactoring the code to use templates

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    datafile = open(home + page, 'w')
23
23
    templatefile = open(template, 'r')
24
24
 
25
 
    for line in templatefile:
26
 
        if line.strip() == "<!-- *** Title Space *** -->":
27
 
            datafile.write("Desktop Team Bugs Summary Page")
28
 
        elif line.strip() == "<!-- *** Title *** -->":
29
 
            datafile.write(title)
30
 
        elif line.strip() == "<!-- *** Table Header Space *** -->":
31
 
            datafile.write("<th></th><th>Bug Number</th><th colspan=\"2\">Summary</th><th>Importance</th><th>Status</th><th>Users affected</th><th>Duplicates</th><th>Heat</th><th>Assignee</th>")
 
25
    statuses = ['New', 'Incomplete', 'Confirmed', 'Triaged', 'In Progress',
 
26
        'Fix Committed']
 
27
    importances = ['High', 'Critical', 'Medium', 'Low', 'Undecided']
 
28
 
 
29
    report = dict(
 
30
        title="Desktop Team Bugs Summary Page",
 
31
        page_title=page_title,
 
32
 
32
33
        elif line.strip() == "<!-- *** Table Body Space *** -->":
33
34
            for software in packages:
34
35
                source_package = ubuntu.getSourcePackage(name=software)
35
 
                for task in source_package.searchTasks(created_since=since_when, status=['New', 'Incomplete', 'Confirmed', 'Triaged', 'In Progress', 'Fix Committed'], importance=['High','Critical','Medium','Low','Undecided'], order_by='-heat'):
 
36
                tasks = source_package.searchTasks(created_since=since_when,
 
37
                    status=statuses, importance=importances, order_by='-heat')
 
38
                for task in tasks:
36
39
                    if "(Ubuntu)" in task.bug_target_display_name:
37
 
                        if (task.importance == 'High' or task.importance == 'Critical') or (task.bug.heat > min_heat and task.bug.users_affected_count_with_dupes >= min_users_affected):
 
40
                        importance = task.importance
 
41
                        if ((importance == 'High' or importance == 'Critical')
 
42
                            or (task.bug.heat > min_heat and
 
43
                                task.bug.users_affected_count_with_dupes >= min_users_affected):
38
44
                            try:
39
 
                                table_row = "<tr>"
40
 
                                table_row += "<td class=\"icon right\"><span alt=\"(undecided)\" title=\"Undecided\" class=\"sprite bug-%s\">&nbsp;</span></td>" % (task.importance.encode('utf-8').lower())
41
 
                          
42
 
                                table_row += "<td class=\"amount\">%s</td>" % task.bug.id
43
 
                                try:
44
 
                                    table_row += "<td><a href='http://launchpad.net/bugs/%s'>%s</a></td>" % (task.bug.id, task.bug.title.encode('utf-8'))
 
45
                                table_row = 
 
46
        <tr>
 
47
            <td class='icon right'>
 
48
                <span alt='(undecided)' title='Undecided' class='sprite-bug-${task.importance.lower()}'>
 
49
                    &nbsp;
 
50
                </span>
 
51
            </td>
 
52
            <td class='amount'>${task.bug.id}</td>
 
53
            <td>
 
54
                <a href='http://launchpad.net/bugs/${task.bug.id}'>${task.bug.title.encode('utf-8')}</a>
 
55
            </td>
45
56
                                except:
46
57
                                    table_row += "<td><a href='http://launchpad.net/bugs/%s'>Can't decode title</a></td>" % (task.bug.id)
47
58
                                table_row += "<td align=\"right\" style=\"padding-right: 5px\"></td>"
100
111
for p in team.getBugSubscriberPackages():
101
112
    desktop_packages.append(p.name)
102
113
 
103
 
#list of individual packages. 
104
 
other_packages = ['gwibber', 'telepathy-butterfly', 'telepathy-gabble', 'telepathy-haze', 'telepathy-idle', 'network-manager', 'lightdm', 'network-manager-applet', 'libreoffice', 'language-selector', 'deja-dup', 'couchdb-glib', 'evolution-couchdb', 'banshee', 'jockey']
 
114
#list of individual packages.
 
115
other_packages = ['gwibber', 'telepathy-butterfly', 'telepathy-gabble',
 
116
    'telepathy-haze', 'telepathy-idle', 'network-manager', 'lightdm',
 
117
    'network-manager-applet', 'libreoffice', 'language-selector', 'deja-dup',
 
118
    'couchdb-glib', 'evolution-couchdb', 'banshee', 'jockey']
105
119
compiz = ['compiz']
106
120
mozilla = ['thunderbird', 'firefox']
107
 
unity = ['unity', 'nux', 'unity-place-applications', 'unity-place-files', 'libunity']
108
 
zeitgeist = ['zeitgeist', 'libzeitgeist', 'zeitgeist-filesystem', 'zeitgeist-sharp', 'zeitgeist-datasources', 'sezen', 'gnome-activity-journal', 'zeitgeist-extensions']
 
121
unity = ['unity', 'nux', 'unity-place-applications', 'unity-place-files',
 
122
    'libunity']
 
123
zeitgeist = ['zeitgeist', 'libzeitgeist', 'zeitgeist-filesystem',
 
124
    'zeitgeist-sharp', 'zeitgeist-datasources', 'sezen',
 
125
    'gnome-activity-journal', 'zeitgeist-extensions']
109
126
unity2d = ['unity-2d']
110
 
development = ['intltool', 'gettext', 'autoconf', 'automake', 'pkg-config', 'libtool']
111
 
indicators = ['indicator-application', 'indicator-appmenu', 'indicator-applet', 'indicator-sound', 'libindicate', 'evolution-indicator', 'indicator-datetime', 'indicator-me', 'indicator-messages', 'indicator-session']
 
127
development = ['intltool', 'gettext', 'autoconf', 'automake', 'pkg-config',
 
128
    'libtool']
 
129
indicators = ['indicator-application', 'indicator-appmenu', 'indicator-applet',
 
130
    'indicator-sound', 'libindicate', 'evolution-indicator',
 
131
    'indicator-datetime', 'indicator-me', 'indicator-messages',
 
132
    'indicator-session']
112
133
software_center = ['software-center']
113
134
 
 
135
class Page:
 
136
    def __init__(self, filename, title, packages,
 
137
        min_users_affected_count_with_dupes=10, min_heat=50,
 
138
        since_when='2011-01-01'):
 
139
        self.filename = filename
 
140
        self.min_users_affected_count_with_dupes = (
 
141
            min_users_affected_count_with_dupes)
 
142
        self.min_heat = min_heat
 
143
        self.since_when = since_when
 
144
        self.title = title
 
145
        self.packages = packages
 
146
 
 
147
    def write_report(self):
 
148
 
 
149
 
 
150
 
114
151
# (page, min_users_affected_count_with_dupes, min_heat, since_when, title, packages)
115
 
setup_page('index.html', 10, 50, '2011-01-01', 'Desktop Team Bugs Summary Page', desktop_packages)
116
 
setup_page('other-packages.html', 10, 50, '2011-01-01', 'Bugs in Other Packages', other_packages)
117
 
setup_page('mozilla-bugs.html', 10, 50, '2011-01-01', 'Bugs in Mozilla Packages', mozilla)
118
 
setup_page('compiz-bugs.html', 10, 50, '2011-01-01', 'Bugs in Compiz', compiz)
119
 
setup_page('unity-bugs.html', 10, 50, '2011-01-01','Bugs in Unity', unity)
120
 
setup_page('unity2d-bugs.html', 10, 50, '2011-01-01', 'Bugs in Unity 2D', unity2d)
121
 
setup_page('zeitgeist-bugs.html', 8, 50, '2011-01-01', 'Bugs in Zeitgeist', zeitgeist)
122
 
setup_page('development-bugs.html', 2, 10, '2011-01-01', 'Bugs in Development Packages', development)
123
 
setup_page('software-center-bugs.html', 8, 50, '2007-01-01', 'Bugs in Software Center', software_center)
124
 
setup_page('indicators-bugs.html', 10, 50, '2011-01-01', 'Bugs in Indicators Packages', indicators)
 
152
index = Page('index.html', 'Desktop Team Bugs Summary Page', desktop_packages)
 
153
index.write_report()
 
154
 
 
155
other = Page('other-packages.html', 'Bugs in Other Packages', other_packages)
 
156
other.write_report()
 
157
 
 
158
mozilla = Page('mozilla-bugs.html', 'Bugs in Mozilla Packages', mozilla)
 
159
mozilla.write_report()
 
160
 
 
161
compiz = Page('compiz-bugs.html', 'Bugs in Compiz', compiz)
 
162
compiz.write_report()
 
163
 
 
164
unity = Page('unity-bugs.html', 'Bugs in Unity', unity)
 
165
unity.write_report()
 
166
 
 
167
unity2d = Page('unity2d-bugs.html', 'Bugs in Unity 2D', unity2d)
 
168
unity2d.write_report()
 
169
 
 
170
zeitgeist = Page('zeitgeist-bugs.html', 'Bugs in Zeitgeist', zeitgeist, 8, 50)
 
171
zeitgeist.write_report()
 
172
 
 
173
development = Page('development-bugs.html', 'Bugs in Development Packages',
 
174
    development, 2, 10)
 
175
development.write_report()
 
176
 
 
177
software_center = Page('software-center-bugs.html', 'Bugs in Software Center',
 
178
    software_center, 8, 50, '2007-01-01')
 
179
software_center.write_report()
 
180
 
 
181
indicators = Page('indicators-bugs.html', 'Bugs in Indicators Packages',
 
182
    indicators)
 
183
indicators.write_report()
 
184
 
125
185
 
126
186
#Top Ten Worst Bugs Report
127
187