I have a program (written in Python3.6, transformed into an .exe for Windows using cx_Freeze) that uses a lock-file to mark whether a user-login is currently in use, to allow the use of the same login across multiple computers while avoiding possible database corruptions.
The file is created right after the user login is confirmed (and deleted when the user logs out):
lockfile = os.path.join(user_dir, ".locked")
with open(lockfile, "w") as _:
os.utime(lockfile)
On my Windows7 Professional machine, this works fine. It also works fine on my local Windows10 test machine.
Now, I have a client on a remote location who is trying to use the program. And apparently, they consistently get a Permission Error: [Errno 13] Permission denied: '<user_dir>\.locked'
. (Their path seems valid, and the program has no problem creating the user_dir, or writing a config.ini
file to it, so writing privileges on the directory should not be the issue.)
Do some Windows versions maybe have trouble with files starting with a dot? Could using an underscore etc. instead help?
The client uses Windows10 (Enterprise) Version 1809 (Build 17763.379).
(It's hard to debug from here, and as I have to recompile the installer after every change, it would be nice to have an idea if this even makes sense... Any other thoughts about potential sources of the problem are welcome, as well!)
Apparently, it really was the starting dot colliding with some (but not all) Windows versions. I created a new version where the file is named "_locked" and it works fine now.