esm-tools / esm_version_checker

GNU General Public License v2.0
0 stars 0 forks source link

Cleanup doesn't work for directories #11

Closed pgierz closed 4 years ago

pgierz commented 4 years ago

When using the new command to clean up an installation to start from scratch, we fail when directories appear:

* Removing /pf/a/a270077/.local/lib/python3.6/site-packages/esm_environment
Traceback (most recent call last):
  File "/pf/a/a270077/.local/bin/esm_versions", line 11, in <module>
    load_entry_point('esm-version-checker==4.5.0', 'console_scripts', 'esm_versions')()
  File "/mnt/lustre02/work/ab0246/a270077/For_Aprita/.venv/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/mnt/lustre02/work/ab0246/a270077/For_Aprita/.venv/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/mnt/lustre02/work/ab0246/a270077/For_Aprita/.venv/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/mnt/lustre02/work/ab0246/a270077/For_Aprita/.venv/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/mnt/lustre02/work/ab0246/a270077/For_Aprita/.venv/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/mnt/lustre02/work/ab0246/a270077/For_Aprita/.venv/lib/python3.6/site-packages/esm_version_checker/cli.py", line 67, in nuke
    os.remove(esm_thing)
IsADirectoryError: [Errno 21] Is a directory: '/pf/a/a270077/.local/lib/python3.6/site-packages/esm_environment'

Solution is to use:

subprocess.run(["rm", "-rf", path])