GetRD / academic-file-converter

📚 Import Bibtex publications and Jupyter Notebook blog posts into your Markdown website or book. 将Bibtex转换为Markdown网站
https://docs.hugoblox.com/reference/content-types/#automatically-import-publications-from-bibtex
MIT License
363 stars 102 forks source link

hugo command usage in bibtext import does not check cmd return #96

Closed 7yl4r closed 3 years ago

7yl4r commented 3 years ago

Usage of hugo with subprocess should ideally wait for process completion and check for errors. This would eliminate the sleep cruft there too.

https://github.com/wowchemy/hugo-academic-cli/blob/93acb29fd7833d3932868bf96875f284a4dabcb5/academic/import_bibtex.py#L80-L82

Currently when the hugo command fails to create the index.md (if hugo isn't installed for example) an error without this needed info is thrown: FileNotFoundError: [Errno 2] No such file or directory: 'content/publication/.../index.md'.

It would be better to show the error from the hugo subprocess:

[tylar@tylar-pc www_marinebon2]$ python
Python 3.8.3 (default, May 17 2020, 18:15:42)
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.call(f"{hugo} new {markdown_path} --kind publication", shell=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'hugo' is not defined
7yl4r commented 3 years ago

Oh... weird. subprocess.call is supposed to wait for completion and throw errors. Not sure what is happening here.

github-actions[bot] commented 3 years ago

This issue is stale because it has not had any recent activity. The resources of the project maintainers are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the main branch, consider contributing a Pull Request with a fix.

If this is a feature request, and you feel that it is still relevant and valuable, consider contributing a Pull Request for review.

This issue will automatically close soon if no further activity occurs. Thank you for your contributions.

7yl4r commented 3 years ago

I have done some experiments (here) to better understand how subprocess.run behaves with different options and errors. It is not yet clear to me how to fix this issue, however. My best guess at this point is to remove shell=True. But will that break something?

github-actions[bot] commented 3 years ago

This issue is stale because it has not had any recent activity. The resources of the project maintainers are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the main branch, consider contributing a Pull Request with a fix.

If this is a feature request, and you feel that it is still relevant and valuable, consider contributing a Pull Request for review.

This issue will automatically close soon if no further activity occurs. Thank you for your contributions.

7yl4r commented 3 years ago

no close please, mr bot.