Index: tools/buildbot_globals.py |
=================================================================== |
--- tools/buildbot_globals.py (revision 12387) |
+++ tools/buildbot_globals.py (working copy) |
@@ -13,17 +13,37 @@ |
_global_vars = None |
+ |
+GLOBAL_VARS_JSON_URL = ('http://skia.googlecode.com/svn/buildbot/site_config/' |
epoger
2013/12/02 18:36:28
Personally, I would write it this way so the URL w
borenet
2013/12/02 20:22:24
Done.
|
+ 'global_variables.json') |
+ |
+ |
+class GlobalVarsRetrievalError(Exception): |
epoger
2013/12/02 18:36:28
Please add docstrings giving a brief description o
borenet
2013/12/02 20:22:24
Done.
|
+ pass |
+ |
+ |
+class JsonDecodeError(Exception): |
rmistry
2013/12/02 14:57:12
simplejson has a JSONDecodeError. Also, I wonder i
borenet
2013/12/02 16:26:29
Probably a good decision in the long run. All I c
rmistry
2013/12/02 16:28:24
Makes sense.
|
+ pass |
+ |
+ |
class NoSuchGlobalVariable(KeyError): |
pass |
+ |
def Get(var_name): |
'''Return the value associated with this name in global_variables.json. |
Raises NoSuchGlobalVariable if there is no variable with that name.''' |
global _global_vars |
if not _global_vars: |
- _global_vars = json.loads(svn.Cat('http://skia.googlecode.com/svn/' |
- 'buildbot/site_config/' |
- 'global_variables.json')) |
+ try: |
+ global_vars_text = svn.Cat(GLOBAL_VARS_JSON_URL) |
+ except Exception: |
epoger
2013/12/02 18:36:28
TL;DR : this is fine. :-)
I wondered what the pro
borenet
2013/12/02 20:22:24
Yeah, I guess this isn't ideal, but losing the sta
|
+ raise GlobalVarsRetrievalError('Failed to retrieve %s.' % |
+ GLOBAL_VARS_JSON_URL) |
+ try: |
+ _global_vars = json.loads(global_vars_text) |
+ except ValueError as e: |
+ raise JsonDecodeError(e.message + '\n' + global_vars_text) |
try: |
return _global_vars[var_name]['value'] |
except KeyError: |