[IPOL discuss] question about run_algo

Nicolas Limare nicolas.limare at cmla.ens-cachan.fr
Thu Dec 9 14:18:42 CET 2010


> I'm still thinking about using optional libraries (not many) mainly
> for extra visualization. Would it be too crazy to have a part of the
> demo that could 'safely' fail if that library is not present?
> For example, my algorithm optionally outputs a  tree or a region
> adjacency graph which is saved as a file on disk. Is really
> straightforward and nice to render them as a graph using graphviz. I
> thinking about:
> run_proc(algo)
> if(exists(graphviz))
> run_proc(...)

You *can* do it with exceptions:

p = self.run_proc(['foo', 'graph.dot']
self.wait(p)
try:
    p = self.run_proc(['/usr/bin/dot', '-Tpng', '-ograph.png', 'output.dot'])
    self.wait(p)
    have_graph = True
except OSError:
    cherrypy.log("graph generation failed, graphviz probably not available")
    have_graph = False

Do we *want* to do it? Well, as usual, I think it is a matter of
balance. These things can really improve the user experience. Too much
of these thinks will be a nightmare to maintain. So do it with
moderation, only when it is really needed.

See the python doc for more details:
-> http://docs.python.org/tutorial/errors.html#exceptions


@Rafael: You can do it too for your eps->png conversion with gs.

PS: the run_proc() list-based syntax is really horrible, I must change it.

-- 
Nicolas LIMARE
http://nicolas.limare.net/                         pgp:0xFA423F4F
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://tools.ipol.im/mailman/archive/discuss/attachments/20101209/85e30fa6/attachment-0001.pgp>


More information about the discuss mailing list