Fix os.chown call on Windows (#563)

This commit is contained in:
Johan von Forstner
2017-07-18 11:42:30 +02:00
committed by Raphael Michel
parent 83df4451e6
commit 921834c917

View File

@@ -44,7 +44,10 @@ else:
SECRET_KEY = get_random_string(50, chars)
with open(SECRET_FILE, 'w') as f:
os.chmod(SECRET_FILE, 0o600)
os.chown(SECRET_FILE, os.getuid(), os.getgid())
try:
os.chown(SECRET_FILE, os.getuid(), os.getgid())
except AttributeError:
pass # os.chown is not available on Windows
f.write(SECRET_KEY)
# Adjustable settings