| Index: sitescripts/reports/bin/processReports.py |
| =================================================================== |
| --- a/sitescripts/reports/bin/processReports.py |
| +++ b/sitescripts/reports/bin/processReports.py |
| @@ -1,5 +1,5 @@ |
| -# coding: utf-8 |
| - |
| +# coding: utf-8 |
| + |
| # This file is part of the Adblock Plus web scripts, |
| # Copyright (C) 2006-2014 Eyeo GmbH |
| # |
| @@ -14,36 +14,36 @@ |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| - |
| -import MySQLdb, hashlib, sys, os, re |
| -from time import time |
| -from email.utils import parseaddr |
| -from sitescripts.utils import get_config, get_template, setupStderr |
| -from sitescripts.reports.utils import getReport, saveReport, get_db, executeQuery |
| - |
| -def getReports(): |
| - count = 1000 |
| - offset = 0 |
| - while True: |
| - cursor = get_db().cursor(MySQLdb.cursors.DictCursor) |
| - executeQuery(cursor, |
| - '''SELECT guid FROM #PFX#reports WHERE hasscreenshot > 0 LIMIT %s OFFSET %s''', |
| - (count, offset)) |
| - rows = cursor.fetchall() |
| - cursor.close() |
| - if len(rows) == 0: |
| - break |
| - for row in rows: |
| - yield row |
| - offset += len(rows) |
| - |
| -def processReports(): |
| - for report in getReports(): |
| - guid = report.get('guid', None) |
| - reportData = getReport(guid) |
| - if 'screenshot' in reportData: |
| - saveReport(guid, reportData) |
| - |
| -if __name__ == '__main__': |
| - setupStderr() |
| - processReports() |
| + |
| +import MySQLdb, hashlib, sys, os, re |
| +from time import time |
| +from email.utils import parseaddr |
| +from sitescripts.utils import get_config, get_template, setupStderr |
| +from sitescripts.reports.utils import getReport, saveReport, get_db, executeQuery |
| + |
| +def getReports(): |
| + count = 1000 |
| + offset = 0 |
| + while True: |
| + cursor = get_db().cursor(MySQLdb.cursors.DictCursor) |
| + executeQuery(cursor, |
| + '''SELECT guid FROM #PFX#reports WHERE hasscreenshot > 0 LIMIT %s OFFSET %s''', |
| + (count, offset)) |
| + rows = cursor.fetchall() |
| + cursor.close() |
| + if len(rows) == 0: |
| + break |
| + for row in rows: |
| + yield row |
| + offset += len(rows) |
| + |
| +def processReports(): |
| + for report in getReports(): |
| + guid = report.get('guid', None) |
| + reportData = getReport(guid) |
| + if 'screenshot' in reportData: |
| + saveReport(guid, reportData) |
| + |
| +if __name__ == '__main__': |
| + setupStderr() |
| + processReports() |