From 1effffab2a161898dd916a14e92546990c970184 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 1 Mar 2011 17:09:27 -0500 Subject: Make it able to start, stop, and monitor tor networks. still very rough. --- lib/templating.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/templating.py') diff --git a/lib/templating.py b/lib/templating.py index 1fe3465..cc1463a 100644 --- a/lib/templating.py +++ b/lib/templating.py @@ -128,6 +128,7 @@ class IncluderDict(_DictWrapper): def __init__(self, parent, includePath=(".",)): _DictWrapper.__init__(self, parent) self._includePath = includePath + self._st_mtime = 0 def _getitem(self, key): if not key.startswith("include:"): @@ -136,16 +137,25 @@ class IncluderDict(_DictWrapper): filename = key[len("include:"):] if os.path.isabs(filename): with open(filename, 'r') as f: + stat = os.fstat(f.fileno()) + if stat.st_mtime > self._st_mtime: + self._st_mtime = stat.st_mtime return f.read() for elt in self._includePath: fullname = os.path.join(elt, filename) if os.path.exists(fullname): with open(fullname, 'r') as f: + stat = os.fstat(f.fileno()) + if stat.st_mtime > self._st_mtime: + self._st_mtime = stat.st_mtime return f.read() raise KeyError(key) + def getUpdateTime(self): + return self._st_mtime + class _BetterTemplate(string.Template): idpattern = r'[a-z0-9:_/\.\-]+' -- cgit v1.2.3