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

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

Issue 29350318: Issue 4382 - Use new syntax to catch exceptions in sitescripts (Closed)
Patch Set: Created Aug. 30, 2016, 1:28 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
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-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return urllib.quote(value.encode('utf-8'), '') 239 return urllib.quote(value.encode('utf-8'), '')
240 240
241 241
242 def _urlopen(url, attempts=3): 242 def _urlopen(url, attempts=3):
243 """ 243 """
244 Tries to open a particular URL, retries on failure. 244 Tries to open a particular URL, retries on failure.
245 """ 245 """
246 for i in range(attempts): 246 for i in range(attempts):
247 try: 247 try:
248 return urllib.urlopen(url) 248 return urllib.urlopen(url)
249 except IOError, e: 249 except IOError as e:
250 error = e 250 error = e
251 time.sleep(5) 251 time.sleep(5)
252 raise error 252 raise error
253 253
254 254
255 def _getMozillaDownloadLink(galleryID): 255 def _getMozillaDownloadLink(galleryID):
256 """ 256 """
257 gets download link for a Gecko add-on from the Mozilla Addons site 257 gets download link for a Gecko add-on from the Mozilla Addons site
258 """ 258 """
259 url = 'https://services.addons.mozilla.org/en-US/firefox/api/1/addon/%s' % _ urlencode(galleryID) 259 url = 'https://services.addons.mozilla.org/en-US/firefox/api/1/addon/%s' % _ urlencode(galleryID)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 if not extensions: 371 if not extensions:
372 return 372 return
373 373
374 updates = {} 374 updates = {}
375 for extension in extensions: 375 for extension in extensions:
376 updates[extension['basename']] = { 376 updates[extension['basename']] = {
377 'url': extension['updateURL'], 377 'url': extension['updateURL'],
378 'version': extension['version'] 378 'version': extension['version']
379 } 379 }
380 writeLibabpUpdateManifest(path, updates) 380 writeLibabpUpdateManifest(path, updates)
OLDNEW
« no previous file with comments | « sitescripts/extensions/bin/createNightlies.py ('k') | sitescripts/reports/bin/parseNewReports.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld