Reputation: 2913
this is particularly at this line:
filesys = os.listdir(settings.CAPTCHA_ROOT)
it happens when trying to read or write to a directory.
any ideas why it would do this only under Windows?
edit ---------------------------------------
def __clean_captchas(self, offset=3600):
"""docstring for __clean_captchas"""
filesys = os.listdir(settings.CAPTCHA_ROOT)
offset = datetime.datetime.now() - datetime.timedelta(seconds=offset)
for file in filesys:
d = datetime.datetime.fromtimestamp(os.stat(settings.CAPTCHA_ROOT+file).st_ctime) ...
if d < offset:
os.remove(settings.CAPTCHA_ROOT+file)
Upvotes: 0
Views: 2359
Reputation: 22238
Your settings.CAPTCHA_ROOT is incorrect.
For portable paths you should avoid slashes and backslashes and use os.path.join
function instead, smth. like this:
import os
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
CAPTHA_ROOT = os.path.join(PROJECT_PATH,'some','sub','folders')
Upvotes: 2
Reputation: 222973
If you specify the directory as a constant string, and you're writing the path using backslashes instead of forward slashes, you need to use raw strings. e.g.,
CAPTCHA_ROOT = r'D:\captcha'
Upvotes: 0