| OLD | NEW |
| 1 # Copyright (c) 2009, Google Inc. All rights reserved. | 1 # Copyright (c) 2009, Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 def _fetch_file(self, url_base, file_name): | 114 def _fetch_file(self, url_base, file_name): |
| 115 # It seems this can return None if the url redirects and then returns 40
4. | 115 # It seems this can return None if the url redirects and then returns 40
4. |
| 116 # FIXME: This could use Web instead of using urllib2 directly. | 116 # FIXME: This could use Web instead of using urllib2 directly. |
| 117 result = urllib2.urlopen("%s/%s" % (url_base, file_name)) | 117 result = urllib2.urlopen("%s/%s" % (url_base, file_name)) |
| 118 if not result: | 118 if not result: |
| 119 return None | 119 return None |
| 120 # urlopen returns a file-like object which sometimes works fine with str
() | 120 # urlopen returns a file-like object which sometimes works fine with str
() |
| 121 # but sometimes is a addinfourl object. In either case calling read() i
s correct. | 121 # but sometimes is a addinfourl object. In either case calling read() i
s correct. |
| 122 return result.read() | 122 return result.read() |
| 123 |
| 124 |
| 125 def current_build_link(host): |
| 126 """Returns a link to the current job if running on buildbot, or None.""" |
| 127 master_name = host.environ.get('BUILDBOT_MASTERNAME') |
| 128 builder_name = host.environ.get('BUILDBOT_BUILDERNAME') |
| 129 build_number = host.environ.get('BUILDBOT_BUILDNUMBER') |
| 130 if not (master_name and builder_name and build_number): |
| 131 return None |
| 132 return 'https://build.chromium.org/p/%s/builders/%s/builds/%s' % (master_nam
e, builder_name, build_number) |
| OLD | NEW |