| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 }) | 428 }) |
| 429 | 429 |
| 430 request = urllib2.Request(upload_url, data=data) | 430 request = urllib2.Request(upload_url, data=data) |
| 431 request.add_header('Content-Type', content_type) | 431 request.add_header('Content-Type', content_type) |
| 432 request.add_header('Authorization', 'JWT ' + token) | 432 request.add_header('Authorization', 'JWT ' + token) |
| 433 request.get_method = lambda: 'PUT' | 433 request.get_method = lambda: 'PUT' |
| 434 | 434 |
| 435 try: | 435 try: |
| 436 urllib2.urlopen(request).close() | 436 urllib2.urlopen(request).close() |
| 437 except urllib2.HTTPError as e: | 437 except urllib2.HTTPError as e: |
| 438 logging.error(e.read()) | 438 try: |
| 439 e.close() | 439 logging.error(e.read()) |
|
Sebastian Noack
2016/09/13 15:28:06
Generally, you should use try-finally (or with sta
Wladimir Palant
2016/09/13 15:45:19
And here I was hoping that we could avoid obfuscat
| |
| 440 finally: | |
| 441 e.close() | |
| 440 raise | 442 raise |
| 441 | 443 |
| 442 def uploadToChromeWebStore(self): | 444 def uploadToChromeWebStore(self): |
| 443 # Google APIs use HTTP error codes with error message in body. So we add | 445 # Google APIs use HTTP error codes with error message in body. So we add |
| 444 # the response body to the HTTPError to get more meaningful error messag es. | 446 # the response body to the HTTPError to get more meaningful error messag es. |
| 445 | 447 |
| 446 class HTTPErrorBodyHandler(urllib2.HTTPDefaultErrorHandler): | 448 class HTTPErrorBodyHandler(urllib2.HTTPDefaultErrorHandler): |
| 447 def http_error_default(self, req, fp, code, msg, hdrs): | 449 def http_error_default(self, req, fp, code, msg, hdrs): |
| 448 raise urllib2.HTTPError(req.get_full_url(), code, '%s\n%s' % (ms g, fp.read()), hdrs, fp) | 450 raise urllib2.HTTPError(req.get_full_url(), code, '%s\n%s' % (ms g, fp.read()), hdrs, fp) |
| 449 | 451 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 except Exception, ex: | 581 except Exception, ex: |
| 580 logging.error('The build for %s failed:', repo) | 582 logging.error('The build for %s failed:', repo) |
| 581 logging.exception(ex) | 583 logging.exception(ex) |
| 582 | 584 |
| 583 file = open(nightlyConfigFile, 'wb') | 585 file = open(nightlyConfigFile, 'wb') |
| 584 nightlyConfig.write(file) | 586 nightlyConfig.write(file) |
| 585 | 587 |
| 586 | 588 |
| 587 if __name__ == '__main__': | 589 if __name__ == '__main__': |
| 588 main() | 590 main() |
| LEFT | RIGHT |