csdms / babelizer

Transform BMI-wrapped models into Python packages
https://babelizer.readthedocs.io
MIT License
4 stars 3 forks source link

post_gen_project.py hook fails on Linux #6

Closed mdpiper closed 6 years ago

mdpiper commented 6 years ago

The post_gen_project.py hook fails on line 99

clean_folder(LIB_DIRECTORY, keep=keep)

on Linux. This issue doesn't occur on macOS.

To reproduce, use the plugin.yaml file from pymt_hydrotrend and call bmi-render:

bmi-render plugin.yaml .

The full stack trace:

reading template from http://github.com/mcflugen/cookiecutter-bmi-wrap
Traceback (most recent call last):
  File "/tmp/tmp4gc5ae5h.py", line 90, in <module>
    clean_folder(LIB_DIRECTORY, keep=keep)
  File "/tmp/tmp4gc5ae5h.py", line 38, in clean_folder
    folderpath.rmdir()
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/pathlib.py", line 1290, in rmdir
    self._accessor.rmdir(self)
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/pathlib.py", line 387, in wrapped
    return strfunc(str(pathobj), *args)
OSError: [Errno 39] Directory not empty: '/home/mpiper/tmp/pymt_hydrotrend/pymt_hydrotrend/lib'
Stopping generation because post_gen_project hook script didn't exit successfully
Traceback (most recent call last):
  File "/home/csdms/anaconda3/envs/wrap/bin/bmi-render", line 11, in <module>
    load_entry_point('bmi-wrap', 'console_scripts', 'bmi-render')()
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/mpiper/projects/bmi_wrap/bmi_wrap/cli/main_render.py", line 250, in main
    clobber=clobber,
  File "/home/mpiper/projects/bmi_wrap/bmi_wrap/cli/main_render.py", line 316, in render_plugin_repo
    overwrite_if_exists=clobber,
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/cookiecutter/main.py", line 94, in cookiecutter
    output_dir=output_dir
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/cookiecutter/generate.py", line 376, in generate_files
    delete_project_on_failure
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/cookiecutter/generate.py", line 236, in _run_hook_from_repo_dir
    run_hook(hook_name, project_dir, context)
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/cookiecutter/hooks.py", line 144, in run_hook
    run_script_with_context(script, project_dir, context)
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/cookiecutter/hooks.py", line 128, in run_script_with_context
    run_script(temp.name, cwd)
  File "/home/csdms/anaconda3/envs/wrap/lib/python3.6/site-packages/cookiecutter/hooks.py", line 91, in run_script
    'Hook script failed (exit status: {})'.format(exit_status)
cookiecutter.exceptions.FailedHookException: Hook script failed (exit status: 1)
mdpiper commented 6 years ago

If I comment out the problematic line in the hook, everything works fine.

mcflugen commented 6 years ago

This should be fixed with mcflugen/cookiecutter-bmi-wrap#10.