Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory creation #17

Open
dirkzerwas opened this issue Jun 5, 2024 · 1 comment
Open

Directory creation #17

dirkzerwas opened this issue Jun 5, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@dirkzerwas
Copy link
Collaborator

Hi @apricePhy,

I would like to suggest to change the logic in main.py:
if nor os.path.exists(output_directory):
os.makedirs(output_directory)

to:
if os.path.exists(output_directory):
print(output_directory+" exists, will be removed and recreated")
try:
shutil.rmtree(output_directory)
except OSError as e:
print("Output directory already exists, but cannot be removed")
print("Error : %s - %s." % (e.filename, e.strerror))
os.makedirs(output_directory)

This ensures a clean directory at the start, if we keep the "old" without cleaning, there might be intereference with old files (eg the KKMCee-default links etc which could lead to behaviour hard to debug.

@dirkzerwas dirkzerwas added the enhancement New feature or request label Jun 5, 2024
@dirkzerwas
Copy link
Collaborator Author

dirkzerwas commented Jun 5, 2024

Hi @apricePhy,

correction (my bad):

  • the output directory existence is ok
  • it's the "process" directory that could be clean, so it should be the second part:
if os.path.exists(generator_directory):
        print(generator_directory+" exists, will be removed and recreated")
    try:
        shutil.rmtree(generator_directory)
    except OSError as e:
        print("Output directory already exists, but cannot be removed")
        print("Error : %s - %s." % (e.filename, e.strerror))
os.makedirs(generator_directory)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants