fre. 3. jan. 2025, 12:57 skrev Ilya Maximets <[email protected]>:

> On 12/19/24 11:53, Frode Nordahl wrote:
> > The graphviz library has a large set of dependencies, and as such
> > it may be desireable to not install it by default.
> >
> > Before this patch execution of ovs-flowviz would end in
> > ImportError when graphviz is unavailable.
> >
> > Exit with a friendly message instead, allowing the user to consume
> > the parts of the program that do not depend on graphviz.
> >
> > Signed-off-by: Frode Nordahl <[email protected]>
> > ---
> >  python/ovs/flowviz/odp/graph.py | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/python/ovs/flowviz/odp/graph.py
> b/python/ovs/flowviz/odp/graph.py
> > index 4d1fb7493..5ab14e227 100644
> > --- a/python/ovs/flowviz/odp/graph.py
> > +++ b/python/ovs/flowviz/odp/graph.py
> > @@ -14,16 +14,27 @@
> >
> >  """ Defines a Datapath Graph using graphviz. """
> >  import colorsys
> > -import graphviz
> > +import os
> >  import random
> > +import sys
> >
> >  from ovs.flowviz.odp.html import HTMLTree, HTMLFormatter
> >  from ovs.flowviz.odp.tree import FlowTree
> >  from ovs.flowviz.process import FileProcessor
> >
> > +try:
> > +    import graphviz
> > +except ImportError:
> > +    graphviz = None
> > +
> >
> >  class GraphProcessor(FileProcessor):
> >      def __init__(self, opts):
> > +        if graphviz is None:
> > +            print("ERROR: The graph sub-command depends on the graphviz
> "
> > +                  "Python library, which does not appear to be
> installed.",
> > +                  file=sys.stderr)
> > +            sys.exit(os.EX_UNAVAILABLE)
>
> Most of these exit codes are not available on Windows, so should not be
> used in a portable code.  exit(1) might be good enough.
>

Thanks, I keep forgetting about Windows portability.

Any other comments for this series? Otherwise, I'll post a reroll.

--
Frode Nordahl


> >          super().__init__(opts, "odp")
> >
> >      def start_file(self, name, filename):
>
>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to