MartinPacker / mdpre

mdpre - Markdown Preprocessor
MIT License
7 stars 3 forks source link

os.getlogin Errno 6 #26

Open yamsu opened 2 days ago

yamsu commented 2 days ago

I use md2pptx, hence, this felt like the right templating tool, if that an appropriate classification, to use. Great work!

Unfortunately, running mdpre on a Ubuntu terminal resulted in the following error:

mdpre < presentation.mdp > presentation.md

Error

mdpre Markdown Preprocessor v0.6.8 (8 March, 2024)
==================================================
- opened <stdout> for writing
Traceback (most recent call last):
  File "~/usr/bin/mdpre", line 1432, in <module>
    setupStandardVariables()
  File "~/usr/bin/mdpre", line 1190, in setupStandardVariables
    input_file.insert(0, "=def userid " + os.getlogin() + " ")

The solution was to use os.getenv('LOGNAME'), as os.getlogin() seems to have documented issue: https://github.com/dblossom-marist/PerfMon/issues/20

MartinPacker commented 2 days ago

Thank you for this. Running on Mac I would never have seen it. Do you know if this solution works outside of Linux? I'd like to code a general solution, rather than a Linux-specific one. (But branching code, based on platform is a possibility. Yeuch!)

One tip: I always use the -v for "verbose" on the command line. It doesn't affect this bug, though.

MartinPacker commented 2 days ago

Candidate fix - using username = os.getenv('USER') or os.getenv('LOGNAME') or os.getenv('USERNAME') - coded. Have one other (minor) issue to fix before shipping v0.6.9. Other issue is Issue 27 - for which there is a candidate fix.

MartinPacker commented 2 days ago

Shipped in v0.6.9.

Keeping issue open for a few days.

yamsu commented 2 days ago

Thanks for the quick update. I can confirm that v0.6.9 works on Ubuntu!

MartinPacker commented 2 days ago

Great! Will leave open for a few days in case any Windows user has a problem.