in pygenie/jobs/running.py [0:0]
def get_from_info(info_key, info_section, update_if_running=False):
"""
Get info_key from info dict.
If the info_key is not present in the info dict, will get info_section from
Genie.
If update_if_running=True, then will go get info_section from Genie even if
the info_key is present in the info dict.
"""
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
"""Wraps func."""
self = args[0]
if info_key not in self.info:
self._update_info(info_section)
elif update_if_running:
# don't get status unless have to to limit HTTP requests
status = (self.status or 'INIT').upper()
if status in RUNNING_STATUSES:
self._update_info(info_section)
return self.info.get(info_key)
return wrapper
return decorator