pycallgraph2
pycallgraph2 copied to clipboard
How to specify a dot file as output from the command-line?
Hi.
This is related to issue #12, but not quite the same. I would like, for the purposes of publication, to have a vector output instead of a hardcoded PNG file being produced.
I am using the version of pycallgraph as packaged by Debian's @sandrotosi like:
pycallgraph graphviz foo.py bar
Unfortunately, reading the output of the pycallgraph command doesn't make it obvious how to give extra arguments to get the output in, say, SVG or PDF or whatever.
If this is indeed the case (and not me missing something obvious), can it be enabled in a future release?
For now, I'm using the ugly workaround of using the --debug option and copying the graphviz code that it generates and saving it to have the dot file.
Thanks,
Rogério Brito.
Dear Rogério,
we are doing it like that [1]:
# Generate "pycallgraph.dot"
pycallgraph ${pycg_options} graphviz --output-format=dot --output-file=pycallgraph.dot -- terkin --config=src/settings.py
# Convert to SVG
dot -Tsvg pycallgraph.dot > pycallgraph.svg
# Open SVG in browser
open -a firefox pycallgraph.svg
With kind regards, Andreas.
[1] https://github.com/hiveeyes/terkin-datalogger/blob/149e4d80825585f781f75237d6a77203c0663167/tools/cpython.mk#L60-L62
Dear Andreas,
I used the following command to generate the dot files : pycallgraph graphviz --output-format=dot --output-file=pycallgraph.dot my_python_file.py
However, the dot files being generated seem to be corrupted binary files. Could you please help me out with this?
Thanks, Arjun
Dear Arjun,
please note the -- which separates the pycallgraph output options from the command+arguments being invoked. So, your command line should actually be
pycallgraph graphviz --output-format=dot --output-file=pycallgraph.dot -- my_python_file.py
Maybe this helps already.
With kind regards, Andreas.
Dear Andreas,
Yes, thank you for pointing it out however it still generates a corrupted binary file. Any other suggestions?
Thanks, Arjun
Tested the same issue. Looks like the --output-format cmd variable does not update the default value of 'png' correctly in the GraphvizOutput class. As a result you get a png image but with a .dot extenstion in your output.