def check_auto_update(self):
"""
Check for updates to a DER object that auto-updates from a file.
"""
if self.filename is None:
return
try:
filename = self.filename
timestamp = os.stat(self.filename).st_mtime
if self.timestamp is None or self.timestamp < timestamp:
logger.debug("Updating %s, timestamp %s",
filename, rpki.sundial.datetime.fromtimestamp(timestamp))
f = open(filename, "rb")
value = f.read()
f.close()
self.clear()
if looks_like_PEM(value):
self._set_PEM(value)
else:
self.DER = value
self.filename = filename
self.timestamp = timestamp
except (IOError, OSError), e:
now = rpki.sundial.now()
if self.lastfail is None or now > self.lastfail + self.failure_threshold:
logger.warning("Could not auto_update %r (last failure %s): %s", self, self.lastfail, e)
self.lastfail = now
else:
self.lastfail = None
评论列表
文章目录