def _is_var_ready(self, cycle, var):
"""
Checks if the variable var is ready for the given forecast hour by comparing its
filetime to the timestamp given by the forecast hour. If the filetime is newer
(later) then the variable is ready.
:param cycle: which cycle are we working with (UTC)
:param var: the variable identifier
:return: true if the variable is ready
"""
# find last-modified time of file in UTC timezone
url = self._remote_var_url(cycle.hour, var)
r = requests.head(url)
if r.status_code != 200:
raise ValueError('Cannot find variable %s for hour %d at url %s' % (var, cycle.hour, url))
last_modif = self._parse_header_timestamp(r.headers['Last-Modified'])
return last_modif > cycle
评论列表
文章目录