Describe the bug
Start in windows fails on machine where pymongo-inmemory was already running in the past
To Reproduce
Steps to reproduce the behavior:
Create a python app with pymongo-inmemory:0.2.0. Make sure to use venv
Run it, make sure that the pymongo downloads and run the mongo server
Stop it
Run it again
You get a permission error
Expected behavior
The second run works
Logs
On the second run, you get a "permission denied" from line 245 in init.py of the pymongo_inmemory/downloader.
The reason is that py
Context:
OS: Windows 10 64bit
Version of pymongo_inmemory 0.2.0
Version of mongo you are downloading 4.4.0
On the second run, you get a "permission denied" from line 245 in init.py of the pymongo_inmemory/downloader.
The reason is that pymongo-inmemory attempts to delete the 'bin' folder, but there is a permission denied on the files that are there.
This is because of the commands in line 88 that change the permission of the files.
Workaround:
Before starting pymongo-inmemory, perform the following code:
if os.path.exists("/.cache/bin"):
recursive_chmod(
"/.cache/bin",
stat.S_IRUSR |
stat.S_IWUSR |
stat.S_IXUSR |
stat.S_IRGRP |
stat.S_IWGRP |
stat.S_IXGRP |
stat.S_IROTH |
stat.S_IWOTH |
stat.S_IXOTH
)
def recursive_chmod(directory, mode):
for root, dirs, files in os.walk(directory):
for file in files:
os.chmod(os.path.join(root, file), mode)
for subdir in dirs:
recursive_chmod(os.path.join(root, subdir), mode)
os.chmod(directory, mode)
Describe the bug Start in windows fails on machine where pymongo-inmemory was already running in the past
To Reproduce Steps to reproduce the behavior:
Expected behavior The second run works
Logs On the second run, you get a "permission denied" from line 245 in init.py of the pymongo_inmemory/downloader. The reason is that py
Context:
On the second run, you get a "permission denied" from line 245 in init.py of the pymongo_inmemory/downloader. The reason is that pymongo-inmemory attempts to delete the 'bin' folder, but there is a permission denied on the files that are there. This is because of the commands in line 88 that change the permission of the files.
Workaround: Before starting pymongo-inmemory, perform the following code: if os.path.exists("/.cache/bin"): recursive_chmod( "/.cache/bin", stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH )
def recursive_chmod(directory, mode): for root, dirs, files in os.walk(directory): for file in files: os.chmod(os.path.join(root, file), mode) for subdir in dirs: recursive_chmod(os.path.join(root, subdir), mode) os.chmod(directory, mode)