OLD | NEW |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 if re.search(r'\btest\b', report['comment'], re.IGNORECASE): | 158 if re.search(r'\btest\b', report['comment'], re.IGNORECASE): |
159 weight -= 0.5 | 159 weight -= 0.5 |
160 elif re.search(r'\S', report['comment']): | 160 elif re.search(r'\S', report['comment']): |
161 weight += 0.5 | 161 weight += 0.5 |
162 if report['contact'] != None: | 162 if report['contact'] != None: |
163 weight += getUserUsefulnessScore(report['contact']) | 163 weight += getUserUsefulnessScore(report['contact']) |
164 | 164 |
165 weight += (report['ctime'] - startTime) / (currentTime - startTime) * 0.2 | 165 weight += (report['ctime'] - startTime) / (currentTime - startTime) * 0.2 |
166 return weight | 166 return weight |
167 | 167 |
| 168 |
168 if __name__ == '__main__': | 169 if __name__ == '__main__': |
169 setupStderr() | 170 setupStderr() |
170 | 171 |
171 if len(sys.argv) < 2: | 172 if len(sys.argv) < 2: |
172 raise Exception('No interval specified') | 173 raise Exception('No interval specified') |
173 | 174 |
174 interval = sys.argv[1] | 175 interval = sys.argv[1] |
175 if not (interval in ['all', 'week', 'day']): | 176 if not (interval in ['all', 'week', 'day']): |
176 raise Exception('Invalid interval') | 177 raise Exception('Invalid interval') |
177 | 178 |
178 if interval == 'week' and len(sys.argv) < 3: | 179 if interval == 'week' and len(sys.argv) < 3: |
179 raise Exception('No weekday specified') | 180 raise Exception('No weekday specified') |
180 weekDay = int(sys.argv[2]) if interval == 'week' else -1 | 181 weekDay = int(sys.argv[2]) if interval == 'week' else -1 |
181 | 182 |
182 currentTime = time() | 183 currentTime = time() |
183 startTime = 0 | 184 startTime = 0 |
184 if interval == 'week': | 185 if interval == 'week': |
185 startTime = currentTime - 7 * 24 * 60 * 60 | 186 startTime = currentTime - 7 * 24 * 60 * 60 |
186 elif interval == 'day': | 187 elif interval == 'day': |
187 startTime = currentTime - 24 * 60 * 60 | 188 startTime = currentTime - 24 * 60 * 60 |
188 | 189 |
189 fakeSubscription = {'url': 'https://fake.adblockplus.org', 'name': get_confi
g().get('reports', 'defaultSubscriptionName'), 'email': get_config().get('report
s', 'defaultSubscriptionRecipient')} | 190 fakeSubscription = {'url': 'https://fake.adblockplus.org', 'name': get_confi
g().get('reports', 'defaultSubscriptionName'), 'email': get_config().get('report
s', 'defaultSubscriptionRecipient')} |
190 subscriptions, subscriptionList = loadSubscriptions() | 191 subscriptions, subscriptionList = loadSubscriptions() |
191 subscriptionList.append(fakeSubscription) | 192 subscriptionList.append(fakeSubscription) |
192 reports = scanReports() | 193 reports = scanReports() |
193 sendNotifications(reports) | 194 sendNotifications(reports) |
OLD | NEW |