pyreport LaTeX formulae not working - python

I'm trying to create a HTML report using pyreport and it works up to the single point, that the LaTeX formulae are not generated.
Here is the input file I use for testing:
#$ This is \LaTeX : $c = 2\cdot(a+b)$
Than I run pyreport -l -t html --verbose file.py, but the report that I get is empty. When I add other comments to the input file, or some Python code, than it is displayed properly within the report. Here is the output from pyreport:
Running python script
/tmp/file.py:
Outputing report to
/tmp/file.html Ran script in 0.13s
I'm using Ubuntu and I have the texlive package installed. Why isn't the formula added to the report?

I think i have find the problem.
The problem is the RST tools to convert in html.
In pyreport, when you choose the math mode, the program will do the sentence in a bock .. raw:: LaTeX
But in the new version of rst2html, this command doesnt work, it's replace by:
.. math::
If you use the command:
pyreport -l -e -t rst --verbose file.py
and after
rst2html file.rst > test.html
You will see the problem.
You can change that in pyreport code, in main.py of pyreport. (use a locate to find it). And replace the
.. raw:: Latex
, by
.. math::
The last problem is for the command \LaTeX, that's not in a math mode of latex. So it's not work.
You can report to RST documentation http://docutils.sourceforge.net/docs/ref/rst/directives.html#raw

Related

How to place output of python script compiling latex document at desired location using "execute_process" command of cmake?

I have a cmake file from which i am executing a python script using "execute_command" as follows:
execute_process (COMMAND C:/Programs/Python27/python.exe "C:/packaging/doc/release_doc.py"
--var_ProjectName "${TARGET}"
--var_version "${_VERSION}" OUTPUT_FILE "C:/packaging/doc/")
When the cmake is executed i am not getting the output at the location specified inside "OUTPUT_FILE". The python file which i am executing is actually compiling a latex .tex file and hence generating a the corresponding pdf document along with the .log file, .aux file and .out file.
When i execute the python script from the location where the latex .tex document is located i get all the files generated at the same location and pdf is all alligned but when i have to execute the same python script from the cmake i am getting all the four files placed at the location different from .tex document and the pdf file alignment gets distrupted.
So, please suggest how can i have the this python file executed from within the cmake and the output of files at the location as i desire.
Is "C:/packaging/doc/" a folder? Then please replace it by something like "C:/packaging/doc/output.txt".
you can also try using OUTPUT_VARIABLE and check if it makes any difference:
execute_process (COMMAND COMMAND C:/Programs/Python27/python.exe "C:/packaging/doc/release_doc.py" --var_ProjectName "${TARGET}" --var_version "${_VERSION}" OUTPUT_VARIABLE test)
message(${test})
file(WRITE "C:/packaging/doc/output2.txt" "${test}")

Error in check_call() subprocess, executing 'mv' unix command: "Syntax error: '(' unexpected"

I'm making a python script for Travis CI.
.travis.yml
...
script:
- support/travis-build.py
...
The python file travis-build.py is something like this:
#!/usr/bin/env python
from subprocess import check_call
...
check_call(r"mv !(my_project|cmake-3.0.2-Darwin64-universal) ./my_project/final_folder", shell=True)
...
When Travis building achieves that line, I'm getting an error:
/bin/sh: 1: Syntax error: "(" unexpected
I just tried a lot of different forms to write it, but I get the same result. Any idea?
Thanks in advance!
Edit
My current directory layout:
- my_project/final_folder/
- cmake-3.0.2-Darwin64-universal/
- fileA
- fileB
- fileC
I'm trying with this command to move all the current files fileA, fileB and fileC, excluding my_project and cmake-3.0.2-Darwin64-universal folders into ./my_project/final_folder. If I execute this command on Linux shell, I get my aim but not through check_call() command.
Note: I can't move the files one by one, because there are many others
I don't know which shell Travis are using by default because I don't specify it, I only know that if I write the command in my .travis.yml:
.travis.yml
...
script:
# Here is the previous Travis code
- mv !(my_project|cmake-3.0.2-Darwin64-universal) ./my_project/final_folder
...
It works. But If I use the script, it fails.
I found this command from the following issue:
How to use 'mv' command to move files except those in a specific directory?
You're using the bash feature extglob, to try to exclude the files that you're specifying. You'll need to enable it in order to have it exclude the two entries you're specifying.
The python subprocess module explicitly uses /bin/sh when you use shell=True, which doesn't enable the use of bash features like this by default (it's a compliance thing to make it more like original sh).
If you want to get bash to interpret the command; you have to pass it to bash explicitly, for example using:
subprocess.check_call(["bash", "-O", "extglob", "-c", "mv !(my_project|cmake-3.0.2-Darwin64-universal) ./my_project/final_folder"])
I would not choose to do the job in this manner, though.
Let me try again: in which shell do you expect your syntax !(...) to work? Is it bash? Is it ksh? I have never used it, and a quick search for a corresponding bash feature led nowhere. I suspect your syntax is just wrong, which is what the error message is telling you. In that case, your problem is entirely independent form python and the subprocess module.
If a special shell you have on your system supports this syntax, you need to make sure that Python is using the same shell when invoking your command. It tells you which shell it has been using: /bin/sh. This is usually just a link to the real shell executable. Does it point to the same shell you have tested your command in?
Edit: the SO solution you referenced contains the solution in the comments:
Tip: Note however that using this pattern relies on extglob. You can
enable it using shopt -s extglob (If you want extended globs to be
turned on by default you can add shopt -s extglob to .bashrc)
Just to demonstrate that different shells might deal with your syntax in different ways, first using bash:
$ !(uname)
-bash: !: event not found
And then, using /bin/dash:
$ !(uname)
Linux
The argument to a subprocess.something method must be a list of command line arguments. Use e.g. shlex.split() to make the string be split into correct command line arguments:
import shlex, subprocess
subprocess.check_call( shlex.split("mv !(...)") )
EDIT:
So, the goal is to move files/directories, with the exemption of some file(s)/directory(ies). By playing around with bash, I could get it to work like this:
mv `ls | grep -v -e '\(exclusion1\|exclusion2\)'` my_project
So in your situation that would be:
mv `ls | grep -v -e '\(myproject\|cmake-3.0.2-Darwin64-universal\)'` my_project
This could go into the subprocess.check_call(..., shell=True) and it should do what you expect it to do.

sphinx: Including .eps images via raw:: latex

I would like to add an eps image within sphinx, using the raw:: latex command. I imagine something like this:
.. raw:: latex
\includegraphics[width = 100mm, height = 100mm]{example.eps}
Running the sphinx-build command works perfectly, but oddly everything within the ..raw:: latex block is ignored in the html file.
What did I miss?
Do I need to enable the raw command in a docutils.conf file? I couldn't find that file in /etc .

Gcovr errors under Windows

I'm trying to generate a HTML file of results of a C program using Gcovr.
I've installed gcov (via MinGW), Python, easy_stall and gcovr.
Added the C:\MinGW\bin, C:\Python33 and C:\Python\Scripts to the Windows PATH.
Now the problems I'm having (in Windows commandline):
1. gcovr command
gcovr cannot be found/executed from any directory until executed from c:\Python33\Scripts with the python gcovr command.
Temp fix, rename gcovr to gcovr.py? But this doesn't sound as the right solution.
2. Executing gcovr
No results when I call:
c:\Python33\Scripts>python gcovr -r "d:\somepath\Debug"
------------------------------------------------------------------------------
File Lines Exec Cover Missing
------------------------------------------------------------------------------
------------------------------------------------------------------------------
TOTAL 0 0 --%
------------------------------------------------------------------------------
But gcov gives proper results.
D:\somepath\Debug>gcov some_file.gcda
File '../some_file.c'
Lines executed:21.43% of 14
Creating 'some_file.c.gcov'
What do I need to do to get proper results?
Try running the same command without the -r option, that is:
c:\Python33\Scripts>python gcovr "d:\somepath\Debug"
I had the same problem. I did solve it with following approach.
Go to root (main) directory of your project.
To generate output in Tabular format,
in command prompt, Give the command to generate coverage in
1) Tabular format
"python C:\Python27\Scripts\gcovr -r . --object-directory <path to *.gcno *.gcda file>"
2) XML format
"python C:\Python27\Scripts\gcovr -r . --object-directory <path to *.gcno *.gcda file> -x -o <desired_name.xml>"
3) HTML format
"python C:\Python27\Scripts\gcovr -r . --object-directory <path to *.gcno *.gcda file> –-html -o <desired_name.html>"
This post may resolve your issue.
GCOVR giving empty results zero percent in MAC
Had the same issue.
The problem is that your source file is not "below" the root folder and by default gcovr will filter it.
If you call
python gcovr -r "d:\somepath\Debug" --verbose
you will notice the line
Filtering coverage data for file ../some_file.c
An easy fix is to add a filter option:
python gcovr -r "d:\somepath\Debug" --verbose -f .*
From gcovr help:
-f FILTER, --filter=FILTER
Keep only the data files that match this regular
expression
What gcovr documentation fail to mention is that if you do not provide a filter it will use the root path as default filter.
Hope it will help someone.

Simplest way to run Sphinx on one python file

We have a Sphinx configuration that'll generate a slew of HTML documents for our whole codebase. Sometimes, I'm working on one file and I just would like to see the HTML output from that file to make sure I got the syntax right without running the whole suite.
I looked for the simplest command I could run in a terminal to run sphinx on this one file and I'm sure the info's out there but I didn't see it.
Sphinx processes reST files (not Python files directly). Those files may contain references to Python modules (when you use autodoc). My experience is that if only a single Python module has been modified since the last complete output build, Sphinx does not regenerate everything; only the reST file that "pulls in" that particular Python module is processed. There is a message saying updating environment: 0 added, 1 changed, 0 removed.
To explicitly process a single reST file, specify it as an argument to sphinx-build:
sphinx-build -b html -d _build/doctrees . _build/html your_filename.rst
This is done in two steps:
Generate rst file from the python module with sphinx-apidoc.
Generate html from rst file with sphinx-build.
This script does the work. Call it while standing in the same directory as the module and provide it with the file name of the module:
#!/bin/bash
# Generate html documentation for a single python module
PACKAGE=${PWD##*/}
MODULE="$1"
MODULE_NAME=${MODULE%.py}
mkdir -p .tmpdocs
rm -rf .tmpdocs/*
sphinx-apidoc \
-f -e --module-first --no-toc -o .tmpdocs "$PWD" \
# Exclude all directories
$(find "$PWD" -maxdepth 1 -mindepth 1 -type d) \
# Exclude all other modules (apidoc crashes if __init__.py is excluded)
$(find "$PWD" -maxdepth 1 -regextype posix-egrep \
! -regex ".*/$MODULE|.*/__init__.py" -type f)
rm .tmpdocs/$PACKAGE.rst
# build crashes if index.rst does not exist
touch .tmpdocs/index.rst
sphinx-build -b html -c /path/to/your/conf.py/ \
-d .tmpdocs .tmpdocs .tmpdocs .tmpdocs/*.rst
echo "**** HTML-documentation for $MODULE is available in .tmpdocs/$PACKAGE.$MODULE_NAME.html"

Categories