Creates files in the current directory

Bug #514422 reported by Stefano Rivera on 2010-01-29
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
objgraph
Fix Released
Undecided
Unassigned

Bug Description

It's a little tricky to use bits this in other packages when files can be created in the current directory.
That's not a particularly desirable feature.

It would be better to supply a filename.

Related branches

Changed in objgraph:
status: New → Confirmed
tags: added: patch-would-be-nice
Marius Gedminas (mgedmin) wrote :

Branch merged, but I think it doesn't go far enough. The default logic (spawn viewer if it's available) is fine for interactive debugging use, not so for automation (e.g. now setup.py --build-images doesn't build any images on my machine, it spawns three xdots showing the three graphs -- an improvement over the old version, which opened three xdots all showing the same objects.dot).

So perhaps objgraph should do this:

  * if no filename is specified, create a temp file in /tmp (using the tempfile module) and try to spawn xdot; fall back to producing a png and open it with a viewer of some kind (xdg-open foo.png?), fall back to printing the filename

  * if a filename is specified and ends in '.dot', just write the dot file and do nothing

  * if a filename is specified and ends in '.png', write a temporary dot file and convert it to png

  * if a filename is specified with an unknown extension, raise an error.

Thoughts?

Marius Gedminas (mgedmin) wrote :

While I was trying to fix setup.py --build-images I ended up redoing the filename logic like I outlined in my previous comment (with the difference that I'm not raising exceptions, just printing warnings to stdout if the filename has an unknown exception).

Incidentally, I'd love to hear how you're using it.

Changed in objgraph:
status: Confirmed → Fix Committed

Hi Marius (2010.02.01_15:16:50_+0200)
> While I was trying to fix setup.py --build-images I ended up redoing the
> filename logic like I outlined in my previous comment (with the
> difference that I'm not raising exceptions, just printing warnings to
> stdout if the filename has an unknown exception).

Fantastic. I was going to reply saying yes, that sounds like exactly the
right way forward :)

> Incidentally, I'd love to hear how you're using it.

I'm only using the memory inspection utility functions, for this:
http://bazaar.launchpad.net/~ibid-core/ibid/trunk/annotate/head:/ibid/plugins/memory.py

Then post-process with these:
http://bazaar.launchpad.net/~ibid-core/ibid/trunk/annotate/head:/scripts/ibid-memgraph
http://bazaar.launchpad.net/~ibid-core/ibid/trunk/annotate/head:/scripts/ibid-objgraph

You get graphs like: http://holst.cs.uct.ac.za/~stefanor/tibid-memory.png

I used this logging to track down some memory leaks in Ibid.

SR

--
Stefano Rivera
  http://tumbleweed.org.za/
  H: +27 21 465 6908 C: +27 72 419 8559 UCT: X4057

Changed in objgraph:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers