Frage

Here is my code:

   #!/usr/bin/python

    import subprocess

    asciidoc_file_name = '/tmp/redoc_2013-06-25_12:52:19.txt'
    asciidoc_call = ["asciidoc","-b docbook45",asciidoc_file_name]
    print asciidoc_call
    subprocess.call(asciidoc_call)

And here is the output:

    labamba@lambada:~$ ./debug.py
    ['asciidoc', '-b docbook45', '/tmp/redoc_2013-06-25_12:52:19.txt']
    asciidoc: FAILED: missing backend conf file:  docbook45.conf
    labamba@lambada:~$ asciidoc -b docbook45 /tmp/redoc_2013-06-25_12\:52\:19.txt
    labamba@lambada:~$ file /tmp/redoc_2013-06-25_12\:52\:19.xml
    /tmp/redoc_2013-06-25_12:52:19.xml: XML document text
    labamba@lambada:~$ file /etc/asciidoc/docbook45.conf
    /etc/asciidoc/docbook45.conf: HTML document, ASCII text, with very long lines

When called via python subprocess, asciidoc complains about a missing config file. When called on the command line, everything is fine, and the config file is there. Can anyone make sense out of this? I'm lost.

War es hilfreich?

Lösung

Try this:

asciidoc_call = ["asciidoc","-b", "docbook45", asciidoc_file_name]

the other call would call ascidoc with "-b docbook45" as one single option, which won't work.

Andere Tipps

The question is old... Anyway, the asciidoc is implemented in Python and it also includes the asciidocapi.py that can be used as a module from your Python program. The module docstring says:

asciidocapi - AsciiDoc API wrapper class.

The AsciiDocAPI class provides an API for executing asciidoc. Minimal example
compiles `mydoc.txt` to `mydoc.html`:

  import asciidocapi
  asciidoc = asciidocapi.AsciiDocAPI()
  asciidoc.execute('mydoc.txt')

- Full documentation in asciidocapi.txt.
- See the doctests below for more examples.

To simplify, it implements the AsciiDocAPI class that--when initialized--searches for the asciidoc script and imports it behind the scene as a module. This way, you can use it more naturally in Python, and you can avoid using the subprocess.call().

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top