osclib/staging-api: lazy-load all config values to allow for placement in remote config.
This commit is contained in:
parent
d30db7eb1d
commit
e3168d6c34
@ -67,16 +67,7 @@ class StagingAPI(object):
|
|||||||
self.project = project
|
self.project = project
|
||||||
|
|
||||||
# Store some prefix / data used in the code.
|
# Store some prefix / data used in the code.
|
||||||
self.cstaging = conf.config[project]['staging']
|
|
||||||
self.cstaging_group = conf.config[project]['staging-group']
|
|
||||||
self.cstaging_archs = conf.config[project]['staging-archs'].split()
|
|
||||||
self.cstaging_dvd_archs = conf.config[project]['staging-dvd-archs'].split()
|
|
||||||
self._cstaging_nocleanup = None
|
self._cstaging_nocleanup = None
|
||||||
self.crings = conf.config[project]['rings']
|
|
||||||
self.cnonfree = conf.config[project]['nonfree']
|
|
||||||
self.crebuild = conf.config[project]['rebuild']
|
|
||||||
self.cproduct = conf.config[project]['product']
|
|
||||||
self.copenqa = conf.config[project]['openqa']
|
|
||||||
self.user = conf.get_apiurl_usr(apiurl)
|
self.user = conf.get_apiurl_usr(apiurl)
|
||||||
self.delreq_review = conf.config[project]['delreq-review']
|
self.delreq_review = conf.config[project]['delreq-review']
|
||||||
self.main_repo = conf.config[project]['main-repo']
|
self.main_repo = conf.config[project]['main-repo']
|
||||||
@ -99,6 +90,24 @@ class StagingAPI(object):
|
|||||||
|
|
||||||
Cache.init()
|
Cache.init()
|
||||||
|
|
||||||
|
def __getattr__(self, attr):
|
||||||
|
"""Lazy-load all config values to allow for placement in remote config."""
|
||||||
|
if attr.startswith('c'):
|
||||||
|
# Drop 'c' prefix and change to config key format.
|
||||||
|
key = attr[1:].replace('_', '-')
|
||||||
|
|
||||||
|
# This will intentionally cause error if key does not exists.
|
||||||
|
value = conf.config[self.project][key]
|
||||||
|
if key.endswith('archs'):
|
||||||
|
value = value.split()
|
||||||
|
|
||||||
|
# This code will only be called for the first access.
|
||||||
|
setattr(self, attr, value)
|
||||||
|
return value
|
||||||
|
|
||||||
|
# Raise AttributeError like normal.
|
||||||
|
return self.__getattribute__(attr)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cstaging_nocleanup(self):
|
def cstaging_nocleanup(self):
|
||||||
"""Lazy-load value to allow for placement in remote config."""
|
"""Lazy-load value to allow for placement in remote config."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user