| LEFT | RIGHT |
| (no file at all) | |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 | 2 |
| 3 # This Source Code is subject to the terms of the Mozilla Public License | 3 # This Source Code is subject to the terms of the Mozilla Public License |
| 4 # version 2.0 (the "License"). You can obtain a copy of the License at | 4 # version 2.0 (the "License"). You can obtain a copy of the License at |
| 5 # http://mozilla.org/MPL/2.0/. | 5 # http://mozilla.org/MPL/2.0/. |
| 6 | 6 |
| 7 import MySQLdb, hashlib, sys, os, re | 7 import MySQLdb, hashlib, sys, os, re |
| 8 from time import time | 8 from time import time |
| 9 from email.utils import parseaddr | 9 from email.utils import parseaddr |
| 10 from sitescripts.utils import get_config, get_template, setupStderr | 10 from sitescripts.utils import get_config, get_template, setupStderr |
| 11 from sitescripts.reports.utils import getReports, getReportSubscriptions, calcul
ateReportSecret, getDigestPath | 11 from sitescripts.reports.utils import getReports, getReportSubscriptions, calcul
ateReportSecret, getDigestPath, getUserUsefulnessScore |
| 12 import sitescripts.subscriptions.subscriptionParser as subscriptionParser | 12 import sitescripts.subscriptions.subscriptionParser as subscriptionParser |
| 13 | 13 |
| 14 def updateDigests(dir): | 14 def updateDigests(dir): |
| 15 global currentTime | 15 global currentTime |
| 16 | 16 |
| 17 subs = subscriptionParser.readSubscriptions() | 17 subs = subscriptionParser.readSubscriptions() |
| 18 defname, defemail = parseaddr(get_config().get('reports', 'defaultSubscription
Recipient')) | 18 defname, defemail = parseaddr(get_config().get('reports', 'defaultSubscription
Recipient')) |
| 19 | 19 |
| 20 subscriptions = {} | 20 subscriptions = {} |
| 21 emails = {} | 21 emails = {} |
| 22 emails[defemail] = [] | 22 emails[defemail] = [] |
| 23 for subscription in subs.values(): | 23 for subscription in subs.values(): |
| 24 for title, url, complete in subscription.variants: | 24 for title, url, complete in subscription.variants: |
| 25 subscriptions[url] = subscription | 25 subscriptions[url] = subscription |
| 26 name, email = parseaddr(subscription.email) | 26 name, email = parseaddr(subscription.email) |
| 27 if email != '': | 27 if email != '': |
| 28 emails[email] = [] | 28 emails[email] = [] |
| 29 | 29 |
| 30 startTime = currentTime - get_config().getint('reports', 'digestDays') * 24*60
*60 | 30 startTime = currentTime - get_config().getint('reports', 'digestDays') * 24*60
*60 |
| 31 for dbreport in getReports(startTime): | 31 for dbreport in getReports(startTime): |
| 32 report = { | 32 report = { |
| 33 'guid': dbreport['guid'], | 33 'guid': dbreport['guid'], |
| 34 'status': dbreport['status'], | 34 'status': dbreport['status'], |
| 35 'url': get_config().get('reports', 'urlRoot') + dbreport['guid'] + '#secre
t=' + calculateReportSecret(dbreport['guid']), | 35 'url': get_config().get('reports', 'urlRoot') + dbreport['guid'] + '#secre
t=' + calculateReportSecret(dbreport['guid']), |
| 36 'site': dbreport['site'], | 36 'site': dbreport['site'], |
| 37 'comment': dbreport['comment'], | 37 'comment': dbreport['comment'], |
| 38 'type': dbreport['type'], | 38 'type': dbreport['type'], |
| 39 'subscriptions': [], | 39 'subscriptions': [], |
| 40 'contact': dbreport['contact'], | 40 'contact': dbreport['contact'], |
| 41 'score': getUserUsefulnessScore(dbreport['contact']), |
| 41 'hasscreenshot': dbreport['hasscreenshot'], | 42 'hasscreenshot': dbreport['hasscreenshot'], |
| 42 'knownIssues': dbreport['knownissues'], | 43 'knownIssues': dbreport['knownissues'], |
| 43 'time': dbreport['ctime'], | 44 'time': dbreport['ctime'], |
| 44 } | 45 } |
| 45 | 46 |
| 46 recipients = set() | 47 recipients = set() |
| 47 reportSubscriptions = getReportSubscriptions(dbreport['guid']) | 48 reportSubscriptions = getReportSubscriptions(dbreport['guid']) |
| 48 | 49 |
| 49 if dbreport['type'] == 'false positive' or dbreport['type'] == 'false negati
ve': | 50 if dbreport['type'] == 'false positive' or dbreport['type'] == 'false negati
ve': |
| 50 for subscription in reportSubscriptions: | 51 for subscription in reportSubscriptions: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 sub = { | 85 sub = { |
| 85 'name': subscription.name, | 86 'name': subscription.name, |
| 86 'type': subscription.type | 87 'type': subscription.type |
| 87 } | 88 } |
| 88 return sub | 89 return sub |
| 89 | 90 |
| 90 if __name__ == '__main__': | 91 if __name__ == '__main__': |
| 91 setupStderr() | 92 setupStderr() |
| 92 currentTime = time() | 93 currentTime = time() |
| 93 updateDigests(get_config().get('reports', 'digestPath')) | 94 updateDigests(get_config().get('reports', 'digestPath')) |
| LEFT | RIGHT |