fix(windows): convert back-slashes to forward-slashes for Windows#11
Open
Kristinita wants to merge 2 commits intopelican-plugins:mainfrom
Open
fix(windows): convert back-slashes to forward-slashes for Windows#11Kristinita wants to merge 2 commits intopelican-plugins:mainfrom
Kristinita wants to merge 2 commits intopelican-plugins:mainfrom
Conversation
for more information, see https://pre-commit.ci
Contributor
|
@Kristinita: Please accept my sincere apologies for the delay in responding to your PR submission. Mea culpa! Would you please test again using the just-released v1.1.0 version of this plugin and see if the issue persists? If so, would you consider making follow-up changes based on the current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Summary
Pelican Stork search doesn’t work correctly on my Windows if
OUTPUT_PATHsetting is custom.After fixing I can successfully use Pelican Stork search:
2. MCVE files
You can see this MCVE configuration on the
KiraPelicanPluginsSitemapStorkbranch of my demo repository for testing Pelican.All files except those listed below are the result of running the command
pelican-quickstart.pelicanconf.pycontent/Articles/KiraArticle.md:.circleci/config.yml:3. Behavior before change
If custom
OUTPUT_PATHon Windows, Pelican Stork search generate invalid path slashes for the value ofbase_directorysetting ofsearch.tomlfile:If I run:
I get an error:
Full output:
D:\SashaDemoRepositories\SashaPelicanDebugging>pelican content -s pelicanconf.py --fatal warnings --ignore-cache --debug [11:23:23] DEBUG Pelican version: 4.8.0 __init__.py:531 DEBUG Python version: 3.10.6 __init__.py:532 DEBUG Adding current directory to system path __init__.py:66 DEBUG Finding namespace plugins _utils.py:81 DEBUG Namespace plugins found: _utils.py:84 pelican.plugins.search pelican.plugins.sitemap DEBUG Loading plugin `search` _utils.py:90 DEBUG Registering plugin `pelican.plugins.search` __init__.py:73 DEBUG Found generator: ArticlesGenerator (internal) __init__.py:209 DEBUG Found generator: PagesGenerator (internal) __init__.py:209 DEBUG Found generator: SearchSettingsGenerator (pelican.plugins.search.search) __init__.py:209 DEBUG Found generator: StaticGenerator (internal) __init__.py:209 DEBUG Template list: ['!simple/archives.html', '!simple/article.html', '!simple/author.html', '!simple/authors.html', '!simple/base.html', '!simple/categories.html', '!simple/category.html', '!simple/gosquared.html', '!simple/index.html', generators.py:70 '!simple/page.html', '!simple/pagination.html', '!simple/period_archives.html', '!simple/tag.html', '!simple/tags.html', '!simple/translations.html', '!theme/analytics.html', '!theme/archives.html', '!theme/article.html', '!theme/article_infos.html', '!theme/author.html', '!theme/authors.html', '!theme/base.html', '!theme/categories.html', '!theme/category.html', '!theme/comments.html', '!theme/disqus_script.html', '!theme/github.html', '!theme/index.html', '!theme/page.html', '!theme/period_archives.html', '!theme/tag.html', '!theme/taglist.html', '!theme/tags.html', '!theme/translations.html', '!theme/twitter.html', 'analytics.html', 'archives.html', 'article.html', 'article_infos.html', 'author.html', 'authors.html', 'base.html', 'categories.html', 'category.html', 'comments.html', 'disqus_script.html', 'github.html', 'gosquared.html', 'index.html', 'page.html', 'pagination.html', 'period_archives.html', 'tag.html', 'taglist.html', 'tags.html', 'translations.html', 'twitter.html'] DEBUG Read file Articles/KiraArticle.md -> Article readers.py:547 DEBUG Signal article_generator_preread.send(ArticlesGenerator) readers.py:560 DEBUG Successfully imported extension module "markdown.extensions.meta". core.py:163 DEBUG Successfully loaded extension "markdown.extensions.meta.MetaExtension". core.py:126 DEBUG Signal article_generator_context.send(ArticlesGenerator, <metadata>) readers.py:627 [11:23:24] DEBUG Read file images/.keep -> Static readers.py:547 DEBUG Signal static_generator_preread.send(StaticGenerator) readers.py:560 DEBUG Signal static_generator_context.send(StaticGenerator, <metadata>) readers.py:627 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/feeds/all.atom.xml writers.py:163 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/feeds/articles.atom.xml writers.py:163 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/feeds/sasha-chernykh.atom.xml writers.py:163 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/feeds/sasha-chernykh.rss.xml writers.py:163 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/feeds/all-en.atom.xml writers.py:163 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/KiraArticle.html writers.py:212 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/index.html writers.py:212 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/tags.html writers.py:212 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/categories.html writers.py:212 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/authors.html writers.py:212 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/archives.html writers.py:212 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/category/articles.html writers.py:212 INFO Writing D:/SashaDemoRepositories/SashaPelicanDebugging/output/author/sasha-chernykh.html writers.py:212 CRITICAL Exception: Search plugin reported Error: Couldn't read the configuration file: Cannot parse config as TOML. Stork recieved error: `invalid escape character in string: `S` at line 2 column 22` __init__.py:566 ┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐ │ C:\Python310\lib\site-packages\pelican\plugins\search\search.py:38 in build_search_index │ │ │ │ 35 │ │ if not which("stork"): │ │ 36 │ │ │ raise Exception("Stork must be installed and available on $PATH.") │ │ 37 │ │ try: │ │ > 38 │ │ │ output = subprocess.run( │ │ 39 │ │ │ │ [ │ │ 40 │ │ │ │ │ "stork", │ │ 41 │ │ │ │ │ "build", │ │ │ │ C:\Python310\lib\subprocess.py:524 in run │ │ │ │ 521 │ │ │ raise │ │ 522 │ │ retcode = process.poll() │ │ 523 │ │ if check and retcode: │ │ > 524 │ │ │ raise CalledProcessError(retcode, process.args, │ │ 525 │ │ │ │ │ │ │ │ │ output=stdout, stderr=stderr) │ │ 526 │ return CompletedProcess(process.args, retcode, stdout, stderr) │ │ 527 │ └──────────────────────────────────────────────────────────────────────────────────────────────────┘ CalledProcessError: Command '['stork', 'build', '--input', 'D:\\SashaDemoRepositories\\SashaPelicanDebugging\\output\\search.toml', '--output', 'D:\\SashaDemoRepositories\\SashaPelicanDebugging\\output/search-index.st']' returned non-zero exit status 1. During handling of the above exception, another exception occurred: ┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐ │ C:\Python310\lib\site-packages\pelican\__init__.py:562 in main │ │ │ │ 559 │ │ │ watcher = FileSystemWatcher(args.settings, Readers, settings) │ │ 560 │ │ │ watcher.check() │ │ 561 │ │ │ with console.status("Generating…"): │ │ > 562 │ │ │ │ pelican.run() │ │ 563 │ except KeyboardInterrupt: │ │ 564 │ │ logger.warning('Keyboard interrupt received. Exiting.') │ │ 565 │ except Exception as e: │ │ │ │ C:\Python310\lib\site-packages\pelican\__init__.py:127 in run │ │ │ │ 124 │ │ │ │ 125 │ │ for p in generators: │ │ 126 │ │ │ if hasattr(p, 'generate_output'): │ │ > 127 │ │ │ │ p.generate_output(writer) │ │ 128 │ │ │ │ 129 │ │ signals.finalized.send(self) │ │ 130 │ │ │ │ C:\Python310\lib\site-packages\pelican\plugins\search\search.py:113 in generate_output │ │ │ │ 110 │ │ │ fd.write(search_settings) │ │ 111 │ │ │ │ 112 │ │ # Build the search index │ │ > 113 │ │ build_log = self.build_search_index(search_settings_path) │ │ 114 │ │ build_log = "".join(["Search plugin reported ", build_log]) │ │ 115 │ │ logger.error(build_log) if "error" in build_log else logger.debug(build_log) │ │ 116 │ │ │ │ C:\Python310\lib\site-packages\pelican\plugins\search\search.py:52 in build_search_index │ │ │ │ 49 │ │ │ │ check=True, │ │ 50 │ │ │ ) │ │ 51 │ │ except subprocess.CalledProcessError as e: │ │ > 52 │ │ │ raise Exception("".join(["Search plugin reported ", e.stdout, e.stderr])) │ │ 53 │ │ │ │ 54 │ │ return output.stdout │ │ 55 │ └──────────────────────────────────────────────────────────────────────────────────────────────────┘ Exception: Search plugin reported Error: Couldn't read the configuration file: Cannot parse config as TOML. Stork recieved error: `invalid escape character in string: `S` at line 2 column 22`4. Change
I applied
os.septo convert back-slashes to forward-slashes. I change the line ofsearch.py:5. Behavior after change
search.tomlon Windows after my changes:This is the correct path for Windows. No errors in output.
6. UNIX possible consequences
My change shouldn’t affect *nix operating systems. I check it on Circle CI.
Circle CI build with configuration from the item 2.3 of this issue, generated
search.toml:I change in my
config.yml:Circle CI build, the same
search.toml.I didn’t see anything changed in Ubuntu build after my change.
7. Reproducing problem
I can’t reproduce my problem on free remote CI services. Unfortunately, installing Stork on Windows isn’t quick. To install Stork, a Windows user must install Rust and compile Stork on his own machine. I can to compile Stork on my machine, but I was getting bugs on Circle CI and AppVeyor CI.
If you know how to compile Stork for Windows on free remote CI services, please, tell me. See also my issue on the Stork issue tracker.
8. Environment
Operating system:
Python — 3.10.5, 3.10.6
Pelican — 4.8.0
Stork — 1.5.0
pelican-search — 1.0.1
Thanks.