Also reload when the settings file changes.

Fix for #360
This commit is contained in:
Alexis Metaireau 2012-06-10 00:24:26 +02:00
commit ed8b8bc27e
2 changed files with 41 additions and 12 deletions

View file

@ -4,6 +4,7 @@ import re
import pytz
import shutil
import logging
from collections import defaultdict
from codecs import open as _open
from datetime import datetime
@ -221,9 +222,9 @@ def files_changed(path, extensions):
"""Return the last time files have been modified"""
for root, dirs, files in os.walk(path):
dirs[:] = [x for x in dirs if x[0] != '.']
for file in files:
if any(file.endswith(ext) for ext in extensions):
yield os.stat(os.path.join(root, file)).st_mtime
for f in files:
if any(f.endswith(ext) for ext in extensions):
yield os.stat(os.path.join(root, f)).st_mtime
global LAST_MTIME
mtime = max(file_times(path))
@ -233,6 +234,21 @@ def files_changed(path, extensions):
return False
FILENAMES_MTIMES = defaultdict(int)
def file_changed(filename):
mtime = os.stat(filename).st_mtime
if FILENAMES_MTIMES[filename] == 0:
FILENAMES_MTIMES[filename] = mtime
return False
else:
if mtime > FILENAMES_MTIMES[filename]:
FILENAMES_MTIMES[filename] = mtime
return True
return False
def set_date_tzinfo(d, tz_name=None):
""" Date without tzinfo shoudbe utc.
This function set the right tz to date that aren't utc and don't have