blob: 1dcb1ccc094993cb22aa6c08029c7c931e7526a1 [file] [log] [blame]
epoger@google.comfd040112013-08-20 16:21:55 +00001#!/usr/bin/python
2
3# Copyright (c) 2013 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""
8Provides read access to buildbot's global_variables.json .
9"""
10
11import json
12import svn
13
14_global_vars = None
15
16class NoSuchGlobalVariable(KeyError):
17 pass
18
19def Get(var_name):
20 '''Return the value associated with this name in global_variables.json.
21 Raises NoSuchGlobalVariable if there is no variable with that name.'''
22 global _global_vars
23 if not _global_vars:
24 _global_vars = json.loads(svn.Cat('http://skia.googlecode.com/svn/'
25 'buildbot/site_config/'
26 'global_variables.json'))
27 try:
28 return _global_vars[var_name]['value']
29 except KeyError:
30 raise NoSuchGlobalVariable(var_name)