which is pelican executable script that user executes from shell?

132 views Asked by At

I am trying to call pelican via subprocess for automated blog posting, however when I tried which pelican in shell and opened it. I found this

#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pelican==3.5.0','console_scripts','pelican'
__requires__ = 'pelican==3.5.0'
import sys
from pkg_resources import load_entry_point

sys.exit(
   load_entry_point('pelican==3.5.0', 'console_scripts', 'pelican')()
)

while I was expecting to see a call to main function that gets called when somebody passes argument from shell to pelican.(I am not talking about pelican-quickstart)

I tried to look into the pelican project I think its the __init__.py that has main function, but normally I would have a executable wrapper that calls this main function, so can anyone redirect me to which function the above code passes the argument passed by user ?

1

There are 1 answers

0
Charles Duffy On BEST ANSWER

From pelican's setup.py:

entry_points = {
    'console_scripts': [
        'pelican = pelican:main',
        'pelican-import = pelican.tools.pelican_import:main',
        'pelican-quickstart = pelican.tools.pelican_quickstart:main',
        'pelican-themes = pelican.tools.pelican_themes:main'
    ]
}

Thus, the entry point for the pelican command is the main() function in the pelican module; you could also reach it by import pelican; pelican.main(). (Similarly, for pelican-quickstart: import pelican.tools.pelican_quickstart; pelican.tools.pelican_quickstart.main()).

To find the file:

import pelican
print pelican.__file__

...or, to get a handle on the main function directly:

>>> from pkg_resources import load_entry_point
>>> mainfunc = load_entry_point('pelican', 'console_scripts', 'pelican')
>>> print mainfunc.__module__
'pelican'
>>> mainfunc()
WARNING: Feeds generated without SITEURL set properly may not be valid