AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-25784

SteeveDroz's questions

Martin Hope
SteeveDroz
Asked: 2022-04-10 22:06:56 +0800 CST

为什么 pandoc 不在 LXC 容器中生成目录?

  • 0

我对 pandoc 没有生成正确的目录有疑问。

这是我的工作流程:

  1. 我创建了一个包含网页内容的 Markdown 文件。
  2. 我用 Git 对我的项目进行版本控制。
  3. 我git push到我的自托管 GitLab 服务器。
  4. 使用 CI/CD,我的服务器在 Ubuntu/bionic LXC 容器中运行 3 个脚本。
    1. 第一个提取元数据。
    2. 第二个调用 pandoc 生成一个带有页眉、页脚、目录和 CSS 的 HTML 页面。
    3. 第三个将新的 HTML 页面推送到我的生产服务器。

除了一个小细节之外,一切都完美无缺:当 pandoc 生成 HTML 时,缺少目录。奇怪的是,当我在本地机器(Fedora 34)上运行它时它可以工作。

这是我在第二个容器中运行的脚本(事先没有安装任何东西):

apt-get update
apt-get install -y python3 pandoc pandoc-citeproc
mkdir -p build
python3 .deploy/convert.py

您可以在下面找到脚本的结果。

注意:在 LXC 容器中,用户是 root,不需要sudo.

内容.deploy/convert.py:

import sys
import os
import re
from pathlib import Path

if __name__ == '__main__':
    with open('data/type', 'r') as f:
        type = f.readline()
    with open('data/number', 'r') as f:
        number = f.readline()
    with open('data/name', 'r') as f:
        name = f.readline()

    result = list(Path(".").rglob("*.md"))
    for file in result:
        parts = str(file).split('.')
        parts.pop()
        filename = '.'.join(parts)
        if filename != 'README':
            parts = str(filename).split('/')
            parts.pop()
            directory = '/'.join(parts)
            os.system('mkdir -p build/' + directory)

            # This is the important line!
            os.system('pandoc --toc --metadata title=' + type + '-' + number +
                      ' --metadata type=' + type +
                      ' --metadata number=' + number +
                      ' --metadata name="' + name +
                      '" -s --template .deploy/template.html ' +
                      str(file) +
                      ' -o build/' + filename + '.html'
            )

            with open('build/' + filename + '.html', 'r') as f:
                filedata = f.read()
            filedata = re.sub('href="(.*)\.md"', 'href="\\1.html"', filedata)
            with open('build/' + filename + '.html', 'w') as f:
                f.write(filedata)

这 3 个容器是按顺序调用的,在它们之间留下所谓的工件:它们是可以传递给下一个容器的文件。我在转换容器之前和之后检查了工件,唯一缺少的部分是目录。

我错过了什么?

这是我从脚本中得到的结果。同样,即使您看到$而不是,也要#知道我是 root!

$ apt-get update
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:5 https://packagecloud.io/github/git-lfs/ubuntu bionic InRelease
Reading package lists...
$ apt-get install -y python3 pandoc
Reading package lists...
Building dependency tree...
Reading state information...
python3 is already the newest version (3.6.7-1~18.04).
python3 set to manually installed.
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
  liblua5.1-0 libluajit-5.1-2 libluajit-5.1-common pandoc-data
Suggested packages:
  texlive-latex-recommended texlive-xetex texlive-luatex pandoc-citeproc
  texlive-latex-extra context wkhtmltopdf
The following NEW packages will be installed:
  liblua5.1-0 libluajit-5.1-2 libluajit-5.1-common pandoc pandoc-data
0 upgraded, 5 newly installed, 0 to remove and 13 not upgraded.
Need to get 7103 kB of archives.
After this operation, 53.7 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/universe amd64 liblua5.1-0 amd64 5.1.5-8.1build2 [100 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libluajit-5.1-common all 2.1.0~beta3+dfsg-5.1 [44.3 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libluajit-5.1-2 amd64 2.1.0~beta3+dfsg-5.1 [227 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic/universe amd64 pandoc-data all 1.19.2.4~dfsg-1build4 [40.1 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 pandoc amd64 1.19.2.4~dfsg-1build4 [6692 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
Fetched 7103 kB in 1s (5904 kB/s)
dpkg-preconfigure: unable to re-open stdin: 
Selecting previously unselected package liblua5.1-0:amd64.
(Reading database ... 29084 files and directories currently installed.)
Preparing to unpack .../liblua5.1-0_5.1.5-8.1build2_amd64.deb ...
Unpacking liblua5.1-0:amd64 (5.1.5-8.1build2) ...
Selecting previously unselected package libluajit-5.1-common.
Preparing to unpack .../libluajit-5.1-common_2.1.0~beta3+dfsg-5.1_all.deb ...
Unpacking libluajit-5.1-common (2.1.0~beta3+dfsg-5.1) ...
Selecting previously unselected package libluajit-5.1-2:amd64.
Preparing to unpack .../libluajit-5.1-2_2.1.0~beta3+dfsg-5.1_amd64.deb ...
Unpacking libluajit-5.1-2:amd64 (2.1.0~beta3+dfsg-5.1) ...
Selecting previously unselected package pandoc-data.
Preparing to unpack .../pandoc-data_1.19.2.4~dfsg-1build4_all.deb ...
Unpacking pandoc-data (1.19.2.4~dfsg-1build4) ...
Selecting previously unselected package pandoc.
Preparing to unpack .../pandoc_1.19.2.4~dfsg-1build4_amd64.deb ...
Unpacking pandoc (1.19.2.4~dfsg-1build4) ...
Setting up libluajit-5.1-common (2.1.0~beta3+dfsg-5.1) ...
Setting up pandoc-data (1.19.2.4~dfsg-1build4) ...
Setting up libluajit-5.1-2:amd64 (2.1.0~beta3+dfsg-5.1) ...
Setting up liblua5.1-0:amd64 (5.1.5-8.1build2) ...
Setting up pandoc (1.19.2.4~dfsg-1build4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.5) ...
$ mkdir -p build
$ python3 .deploy/convert.py
Uploading artifacts for successful job 00:01
Uploading artifacts...
Runtime platform                                    arch=amd64 os=linux pid=1620 revision=bd40e3da version=14.9.1
build: found 2 matching files and directories      
untracked: found 4 files                           
Uploading artifacts as "archive" to coordinator... 201 Created  id=3380 responseStatus=201 Created token=WHTmbFcM
Cleaning up file based variables 00:00
Job succeeded
lxc
  • 1 个回答
  • 38 Views
Martin Hope
SteeveDroz
Asked: 2016-04-25 01:26:17 +0800 CST

我可以从自定义目录运行小型 Web 服务器吗?[复制]

  • 1
这个问题在这里已经有了答案:
从任何目录运行 Web 服务器 5 个答案
6年前关闭。

这个问题可能不太清楚,让我解释一下:

我使用 Symfony 开发网站,有一个聪明的小命令可以让我启动一个 apache 服务器,将服务器的根目录作为当前目录。然后我可以在专用端口 ( localhost:8000) 上查看结果。

没有 Symfony 是否有一种简单的方法可以做到这一点,可能包含在 Apache2 中?我想测试一些不需要 PHP 框架的东西。

我知道我可以简单地为我的实际 Apache 服务器建立一个符号链接(/var/www如果我没记错的话,我已经很久没有使用那个服务器了)。不是我被卡住了,我只是想知道如果没有太多眼泪是否可行。

command-line
  • 2 个回答
  • 1097 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve