Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/reports/utils.py

Issue 29544668: Noissue - Indicate that the dump field is binary to avoid database warnings about bad UTF-8 encoding (Closed) Base URL: https://hg.adblockplus.org/sitescripts/
Patch Set: Created Sept. 14, 2017, 12:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 del reportData['screenshot'] 90 del reportData['screenshot']
91 knownIssues = len(reportData.get('knownIssues', [])) 91 knownIssues = len(reportData.get('knownIssues', []))
92 contact = getUserId(reportData.get('email', None)) if reportData.get('email' , None) else None 92 contact = getUserId(reportData.get('email', None)) if reportData.get('email' , None) else None
93 dumpstr = marshal.dumps(reportData) 93 dumpstr = marshal.dumps(reportData)
94 94
95 if contact != None and isNew: 95 if contact != None and isNew:
96 executeQuery(cursor, 'INSERT INTO #PFX#users (id, reports) VALUES (%s, 1 ) ON DUPLICATE KEY UPDATE reports = reports + 1', contact) 96 executeQuery(cursor, 'INSERT INTO #PFX#users (id, reports) VALUES (%s, 1 ) ON DUPLICATE KEY UPDATE reports = reports + 1', contact)
97 executeQuery(cursor, 97 executeQuery(cursor,
98 '''INSERT INTO #PFX#reports (guid, type, ctime, site, comment, status, contact, hasscreenshot, knownissues, dump) 98 '''INSERT INTO #PFX#reports (guid, type, ctime, site, comment, status, contact, hasscreenshot, knownissues, dump)
99 VALUES (%(guid)s, %(type)s, FROM_UNIXTIME(%(ctime)s), %(site)s, %(comment)s, %(status)s, %(contact)s, 99 VALUES (%(guid)s, %(type)s, FROM_UNIXTIME(%(ctime)s), %(site)s, %(comment)s, %(status)s, %(contact)s,
100 %(hasscreenshot)s, %(knownissues)s, %(dump)s) ON DUPLICATE KEY 100 %(hasscreenshot)s, %(knownissues)s, _binary %(dump)s) ON DUPLIC ATE KEY
101 UPDATE type = %(type)s, site = %(site)s, comment = %(comment)s, status = %(status)s, 101 UPDATE type = %(type)s, site = %(site)s, comment = %(comment)s, status = %(status)s,
102 hasscreenshot = %(hasscreenshot)s, knownissues = %(knownissues) s, dump = %(dump)s''', 102 hasscreenshot = %(hasscreenshot)s, knownissues = %(knownissues) s, dump = _binary %(dump)s''',
103 {'guid': guid, 'type': reportData.get('type', None), 'ctime': r eportData['time'], 'site': reportData.get('siteName', None), 103 {'guid': guid, 'type': reportData.get('type', None), 'ctime': r eportData['time'], 'site': reportData.get('siteName', None),
104 'comment': reportData.get('comment', None), 'status': reportDa ta.get('status', None), 'contact': contact, 104 'comment': reportData.get('comment', None), 'status': reportDa ta.get('status', None), 'contact': contact,
105 'hasscreenshot': reportData.get('hasscreenshot', 0), 'knowniss ues': knownIssues, 'dump': dumpstr}) 105 'hasscreenshot': reportData.get('hasscreenshot', 0), 'knowniss ues': knownIssues, 'dump': dumpstr})
106 if len(reportData['subscriptions']) > 0: 106 if len(reportData['subscriptions']) > 0:
107 for sn in reportData['subscriptions']: 107 for sn in reportData['subscriptions']:
108 executeQuery(cursor, 'SELECT id FROM #PFX#subscriptions WHERE url = %s', sn['id']) 108 executeQuery(cursor, 'SELECT id FROM #PFX#subscriptions WHERE url = %s', sn['id'])
109 id = cursor.fetchone() 109 id = cursor.fetchone()
110 if id != None: 110 if id != None:
111 def filterMatch(f): 111 def filterMatch(f):
112 return any(u == sn['id'] for u in f.get('subscriptions', []) ) 112 return any(u == sn['id'] for u in f.get('subscriptions', []) )
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 if os.name == 'nt': 272 if os.name == 'nt':
273 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_un icode=True, charset='utf8', named_pipe=True) 273 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_un icode=True, charset='utf8', named_pipe=True)
274 else: 274 else:
275 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_un icode=True, charset='utf8') 275 return MySQLdb.connect(user=dbuser, passwd=dbpasswd, db=database, use_un icode=True, charset='utf8')
276 276
277 277
278 def executeQuery(cursor, query, args=None): 278 def executeQuery(cursor, query, args=None):
279 tablePrefix = get_config().get('reports', 'dbprefix') 279 tablePrefix = get_config().get('reports', 'dbprefix')
280 query = re.sub(r'#PFX#', tablePrefix, query) 280 query = re.sub(r'#PFX#', tablePrefix, query)
281 cursor.execute(query, args) 281 cursor.execute(query, args)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld