Giter Site home page Giter Site logo

jrfonseca / xdot.py Goto Github PK

View Code? Open in Web Editor NEW
838.0 42.0 145.0 393 KB

Interactive viewer for graphs written in Graphviz's dot language.

License: GNU Lesser General Public License v3.0

Python 85.72% Makefile 0.10% PostScript 14.18%
python graphviz gtk xdot

xdot.py's Introduction

About xdot.py

xdot.py is an interactive viewer for graphs written in Graphviz's dot language.

It uses internally the GraphViz's xdot output format as an intermediate format, Python GTK bindings, and Cairo for rendering.

xdot.py can be used either as a standalone application from command line, or as a library embedded in your Python application.

Status

xdot.py script became much more popular than I ever anticipated, and there are several interested in improving it further. However, for several years now, xdot.py already meets my own needs, and unfortunately I don't have much time for maintaining it myself.

So I'm looking into transition xdot.py maintenance to others: either hand over the maintenance xdot.py to a community or indicate an official fork of xdot.py.

I encourage people interested in development of xdot.py to fork the GitHub repository, and join the new mailing list.

Features

  • Since it doesn't use bitmaps it is fast and has a small memory footprint.
  • Arbitrary zoom.
  • Keyboard/mouse navigation.
  • Supports events on the nodes with URLs.
  • Animated jumping between nodes.
  • Highlights node/edge under mouse.

Known Issues

  • Not all xdot attributes are supported or correctly rendered yet. It works well for my applications but YMMV.

  • Text doesn't scale properly to large sizes if font hinting is enabled. I haven't found a reliable way to disable font hinting during rendering yet.

See also:

Screenshots

Profile 1 Screenshot Profile 2 Screenshot Control Flow Graph

Requirements

Windows users

Download and install:

Debian/Ubuntu users

Run:

apt install gir1.2-gtk-3.0 python3-gi python3-gi-cairo python3-numpy graphviz

Usage

Command Line

If you install xdot.py from PyPI or from your Linux distribution package managing system, you should have the xdot somewhere in your PATH automatically.

When running xdot.py from its source tree, you can run it by first setting PYTHONPATH environment variable to the full path of xdot.py's source tree, then running:

python3 -m xdot

You can also pass the following options:

Usage:
	xdot.py [file|-]

Options:
  -h, --help            show this help message and exit
  -f FILTER, --filter=FILTER
                        graphviz filter: dot, neato, twopi, circo, or fdp
                        [default: dot]
  -n, --no-filter       assume input is already filtered into xdot format (use
                        e.g. dot -Txdot)
  -g GEOMETRY           default window size in form WxH

Shortcuts:
  Up, Down, Left, Right     scroll
  PageUp, +, =              zoom in
  PageDown, -               zoom out
  R                         reload dot file
  F                         find
  Q                         quit
  P                         print
  T                         toggle toolbar
  W                         zoom to fit
  Escape                    halt animation
  Ctrl-drag                 zoom in/out
  Shift-drag                zooms an area
  Click (on edge)           focus edge's source node
  Ctrl-click (on edge)      focus edge's *destination* node

If - is given as input file then xdot.py will read the dot graph from the standard input.

Embedding

See included sample.py script for an example of how to embedded xdot.py into another application.

Screenshot

Download

Links

xdot.py's People

Contributors

arthurgleckler avatar coroa avatar ehooo avatar flying-sheep avatar htgoebel avatar iamahuman avatar jayvdb avatar jrfonseca avatar jtojnar avatar jwilk avatar krillegh avatar l0kod avatar liujed avatar ludwigme avatar mk-fg avatar mome avatar mxmgh avatar owst avatar p2004a avatar pfalcon avatar pfez avatar prj-2501 avatar rrbutani avatar snoopj avatar stebalien avatar stefanor avatar tbennun avatar timovwb avatar tlk avatar zedthree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xdot.py's Issues

Disable syntax error warnings

I love xdot. Precisely what I needed. Thank you.

Is ther a way for me to disable these syntax error warnings?
Getting the error message is not a problem. The problem is having to click "ok".
That interrupts my flow.

Thanks again!

xdot doesn't work~

Hello.
I've just installed xdot by using
brew install xdot

But when I start xdot from command line, it goes wrong.
xdot_wrong

Did I do sth wrong?
Please help, thank you~

reverse the direction of arrows in xdot.py graphs without modifying the dot input

Hi,
I am trying to reverse the arrows in th edges of my graph. Say I have directed graph a-> b, b->c in graphviz dot format. But, I want the xdot.py to draw the graphs(with arrow head and tail reversed,) as b->a and c->b. Perhaps, it should be possible by modifying the vector graphics drawing functions(LINE_CAP_BUTT/LINE_JOIN_MITER). I was trying to modify the cairo functions(cr.*) in many classes by exchanging the x and y , src and dst. But, could not get it done It would be really helpful for me if anyone could point me the function/show how to do it. Any help would be much appreciated.

View stops updating after file is found missing

During an update poll, if the file is found to be missing (e.g., it is being rewritten by an editor), a stack trace is produced, and the window stops updating.

Traceback (most recent call last):
 File "/usr/lib/python3.8/site-packages/xdot/ui/window.py", line 171, in update
   current_mtime = os.stat(self.openfilename).st_mtime
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/test.dot'

Missing edges using fdp between 2 nodes and 1 cluster

The POC code is:

graph "cluster_Full-Network" {
	subgraph cluster_d2dd739afc71e4eabc8b572ae98ca5e9 {}
	node_0831ce381fb8a3782996a1d40cf8935d
	node_166562e3c47ae9436f911047fb660528
	cluster_d2dd739afc71e4eabc8b572ae98ca5e9 -- node_166562e3c47ae9436f911047fb660528
	cluster_d2dd739afc71e4eabc8b572ae98ca5e9 -- node_0831ce381fb8a3782996a1d40cf8935d
}

The expected result (generated by fdp binary directly):
image
The current result:
image

Maintenance of xdot.py

@jrfonseca We have read in your README file that you don't have time to maintain this package and that you want to delegate the code to someone else. Is it still the case?

RuntimeError: could not open display

It can't create the GTK display, any solutions?

Traceback (most recent call last):
File "/usr/bin/xdot", line 9, in
load_entry_point('xdot==0.6', 'gui_scripts', 'xdot')()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 299, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2229, in load_entry_point
return ep.load()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1948, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "/usr/lib/python2.6/site-packages/xdot-0.6-py2.6.egg/xdot.py", line 34, in
import gtk
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/init.py", line 64, in
_init()
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/init.py", line 52, in _init
_gtk.init_check()
RuntimeError: could not open display

Request: don't recenter on reload?

Hi,

When I make a change to the dot file xdot is viewing, xdot reloads the file and then recenters. So every time I change anything I have to manually locate the parent of the changed node.

This could be difficult to do perfectly, but if dot could pick a node in the viewpoint and try to make sure that node is viewable when a reload is performed, then this would make editing and viewing DOT files a lot easier!

Fonts don't scale on macOS

I installed all dependencies using homebrew and pip.
Opening sample.py on macOS shows a graph with a font that has not been scaled properly:

Screen Shot 2020-06-25 at 14 21 05

Not able to run xdot

System -
ProductName: Mac OS X
ProductVersion: 10.13.6

cmd1 ->brew install xdot
cmd2 -> xdot
o/p cmd2 ->
/usr/local/bin/xdot: /usr/local/Cellar/xdot/0.9_3/libexec/bin/xdot: /usr/local/opt/python/bin/python3.7: bad interpreter: No such file or directory
/usr/local/bin/xdot: line 2: /usr/local/Cellar/xdot/0.9_3/libexec/bin/xdot: Undefined error: 0

Failure to render attached dot file

Hey there,

current trunk of xdot throws a python exception & stack trace when the attached file is rendered.
vma_tree.dot.txt

Stack trace looks like this:
Traceback (most recent call last):
File "xdot/ui/window.py", line 638, in on_open
self.open_file(filename)
File "xdot/ui/window.py", line 611, in open_file
self.set_dotcode(fp.read(), filename)
File "xdot/ui/window.py", line 593, in set_dotcode
if self.dotwidget.set_dotcode(dotcode, filename):
File "xdot/ui/window.py", line 133, in set_dotcode
self.set_xdotcode(xdotcode)
File "xdot/ui/window.py", line 147, in set_xdotcode
parser = XDotParser(xdotcode)
File "xdot/dot/parser.py", line 429, in init
DotParser.init(self, lexer)
File "xdot/dot/parser.py", line 303, in init
Parser.init(self, lexer)
File "xdot/dot/parser.py", line 56, in init
self.lookahead = next(self.lexer)
TypeError: instance has no next() method

Split into multiple modules

This obviously isn't very pressing but having one big python file makes it somewhat hard to work on xdot. I'd suggest a layout like the following:

.
├── dot
│   ├── __init__.py
│   ├── lexer.py
│   └── parser.py
├── __init__.py
└── ui
    ├── animations.py
    ├── colors.py
    ├── __init__.py
    ├── util.py
    └── window.py

Allow rendering from stdin without using a -

Before 0.7, I was able to pipe a dot file to xdot to render it by running something | xdot. Now, I have to run something | xdot -. This isn't really a problem per-say, it's just a bit inconsistent with other unix commands where the - is optional if unambiguous.

Gtk imported without specifying version first warning

Running archlinux, xdot from the official repositories, gives me the warnings below. I applied forcingly the suggested fix in the beggining of /usr/lib/..../xdot.py, just before the ig.repository imports, and the warnings disappeared.

/usr/lib/python3.6/site-packages/xdot.py:35: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk
/usr/lib/python3.6/site-packages/xdot.py:39: PyGIWarning: PangoCairo was imported without specifying a version first. Use gi.require_version('PangoCairo', '1.0') before import to ensure that the right version gets loaded.  
  from gi.repository import PangoCairo

Opening large file

I have a large dox file with ~24,000 nodes. Xdot hangs when I try to open it. Just wondering if there is a known limitation to Xdot or if something else is the problem. Cheers

Reading a float as an int

https://code.google.com/p/jrfonseca/issues/detail?id=93 explains the issue well:

  1. on OSX using w3af itwill throw an error about:
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/xdot.py", line 494, in read_number
    return int(self.read_code())

Upon opening the file i located the function read_number(). It is typcasting to an int from a string, therefore failing. To fix this I modified the function from:

def read_number(self):
    return int(self.read_code())

to:

def read_number(self):
    return int(float(self.read_code()))

It now evaluates the string, to a float first, then to an int()

Your code has changed a little bit now and instead of read_number you've got read_int, but I guess the same issue applies.

Users have reported this on the w3af project repository in the past andresriancho/w3af#1327 andresriancho/w3af#1089

I could send you a pull request with the changes that [email protected] proposes, but first I would like to know if you believe that this will fix the issue and you'll actually merge it.

Dependency on graphviz

A dependency on the graphviz package was added during the module splitting:
f0f0326#diff-2eeaed663bd0d25b7e608891384b7298R35

This is at best unnecessary, as xdot calls the graphviz binaries directly. At worst, it causes the launcher script to abort if the graphviz package is not installed:

Traceback (most recent call last):
File "/usr/bin/xdot", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3147, in <module>
@_call_aside
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3131, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3160, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 666, in _build_master
ws.require(__requires__)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 984, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 870, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'graphviz' distribution was not found and is required by xdot

Running xdot directly (e.g. python3 -m xdot) works fine. Is there a reason for this dependency or can it be dropped?

Errors in dotfile stop file reloading.

When there is an error in the dot file and the error dialog was shown the dot file is not automatically reloaded anymore, which breaks the workflow, because you have to restart xdot every time you make an error.

With latest xdot 0.8 from pip and Python 3.6.4.

When there is a subgraph connecting to a node and use fdp as the filter, xdot crashes.

To reproduce, save the following to test.dot:

graph {
  subgraph cluster_x {
    label = "hello";
  }

  cluster_x -- a;
}

fdp -Tsvg test.dot > test.svg generates a proper svg file. But running xdot -f fdp test.dot leads to the following error:

Traceback (most recent call last):
  File "/home/hong/.local/bin/xdot", line 10, in <module>
    sys.exit(main())
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/__main__.py", line 77, in main
    win.open_file(inputfile)
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/ui/window.py", line 615, in open_file
    self.set_dotcode(fp.read(), filename)
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/ui/window.py", line 597, in set_dotcode
    if self.dotwidget.set_dotcode(dotcode, filename):
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/ui/window.py", line 141, in set_dotcode
    if self._set_dotcode(dotcode, filename, center=center):
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/ui/window.py", line 132, in _set_dotcode
    self.set_xdotcode(xdotcode, center=center)
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/ui/window.py", line 152, in set_xdotcode
    self.graph = parser.parse()
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/dot/parser.py", line 519, in parse
    DotParser.parse(self)
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/dot/parser.py", line 309, in parse
    self.parse_graph()
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/dot/parser.py", line 318, in parse_graph
    self.parse_stmt()
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/dot/parser.py", line 358, in parse_stmt
    self.handle_edge(node_ids[i], node_ids[i + 1], attrs)
  File "/home/hong/.local/lib/python3.7/site-packages/xdot/dot/parser.py", line 514, in handle_edge
    src = self.node_by_name[src_id]
KeyError: b'cluster_x'

An Icon?

Forwarded from: Debian #854131:

Hi,
The xdot package installs a xdot.desktop file but is not setting any icon.
Could you please provide an icon for the application?
Regrads,

I know you aren't shipping the desktop file, we are. But it would be nice if there was a project logo to use as the icon.

GObject.__init__() takes exactly 0 arguments (1 given)

I am seeing this for the majority of the test cases on openSUSE Tumbleweed builds
currently at https://build.opensuse.org/package/show/home:jayvdb:py-new/python-xdot

[   43s] ...
[   43s] ./tests/graphs/labelroot-fdd.gv
[   43s] multiprocessing.pool.RemoteTraceback: 
[   43s] """
[   43s] Traceback (most recent call last):
[   43s]   File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
[   43s]     result = (True, func(*args, **kwds))
[   43s]   File "/usr/lib/python3.8/multiprocessing/pool.py", line 48, in mapstar
[   43s]     return list(map(*args))
[   43s]   File "test.py", line 37, in test
[   43s]     from xdot import DotWidget, DotWindow
[   43s]   File "/home/abuild/rpmbuild/BUILD/xdot.py-1.2/xdot/__init__.py", line 26, in <module>
[   43s]     from . import ui
[   43s]   File "/home/abuild/rpmbuild/BUILD/xdot.py-1.2/xdot/ui/__init__.py", line 3, in <module>
[   43s]     from .window import DotWidget, DotWindow
[   43s]   File "/home/abuild/rpmbuild/BUILD/xdot.py-1.2/xdot/ui/window.py", line 40, in <module>
[   43s]     from . import actions
[   43s]   File "/home/abuild/rpmbuild/BUILD/xdot.py-1.2/xdot/ui/actions.py", line 66, in <module>
[   43s]     class NullAction(DragAction):
[   43s]   File "/home/abuild/rpmbuild/BUILD/xdot.py-1.2/xdot/ui/actions.py", line 70, in NullAction
[   43s]     _tooltip_window = Gtk.Window(Gtk.WindowType.POPUP)
[   43s] TypeError: GObject.__init__() takes exactly 0 arguments (1 given)
[   43s] """
[   43s] 
[   43s] The above exception was the direct cause of the following exception:
[   43s] 
[   43s] Traceback (most recent call last):
[   43s]   File "test.py", line 146, in <module>
[   43s]     main()
[   43s]   File "test.py", line 133, in main
[   43s]     results = pool.map(test, args)
[   43s]   File "/usr/lib/python3.8/multiprocessing/pool.py", line 364, in map
[   43s]     return self._map_async(func, iterable, mapstar, chunksize).get()
[   43s]   File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
[   43s]     raise self._value
[   43s] TypeError: GObject.__init__() takes exactly 0 arguments (1 given)
[   44s] error: Bad exit status from /var/tmp/rpm-tmp.9egKEF (%check)

Make a 0.7 release

Could you consider making a 0.7 release? That way, changes like GTK3 xdot 1.7 support could be picked up by distributions.

Thanks :)

Drag display jumps back to prior location on mouse release

Reported in Debian: https://bugs.debian.org/925278

Package: xdot
Version: 1.0-1
Severity: normal
Tags: upstream

on exceptionally complex graphs that are displayed on extremely high resolution
screens, the refresh rate of xdot can be as low as two (2) SECONDS per frame.
not two frames per second, two SECONDS per frame.

this provides a unique means of identifying an otherwise obscure bug.
action is as follows:

  • load up ridiculously large graph on 3000x1800 (or greater) full-screen LCD
  • press and hold mouse
  • move mouse (to activate "display drag")
  • whilst STILL MOVING the mouse, LET GO of the button.

what will happen is that the display will jump BACK to a FORMER (last updated)
position, as opposed to leaving the display where the cursor is PRESENTLY
located.

this is understandable extremely annoying behaviour, as it requires an
additional two (or greater) seconds of holding the mouse absolutely still,
waiting for an otherwise unnecessary display-update in order that the last
known prior location become the present location, such that, on release of
the mouse, the bug will not result in the display jumping to an undesirable
location.

it is also understandable that given that most people do not view ridiculously
complex graphs on ridiculously high resolution LCDs, that the bug may never
have been encountered before.

ImportError: No module named 'xdot'

I am trying this on a machine running Ubuntu 14.04LTS and ROS Indigo. I checked out the latest master branch and ran 'sudo python setup install'. The installation went fine (output included below) but when I try to run the sample.py file outside the source directory, I get the error:

ImportError: No module named 'xdot'

My PYTHONPATH environment variable looks like this:

PYTHONPATH=/home/patrick/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/indigo/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages

Here is the output from running 'sudo python setup install':

running install
running bdist_egg
running egg_info
writing xdot.egg-info/PKG-INFO
writing top-level names to xdot.egg-info/top_level.txt
writing dependency_links to xdot.egg-info/dependency_links.txt
writing entry points to xdot.egg-info/entry_points.txt
reading manifest file 'xdot.egg-info/SOURCES.txt'
writing manifest file 'xdot.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/xdot.py -> build/bdist.linux-x86_64/egg
byte-compiling build/bdist.linux-x86_64/egg/xdot.py to xdot.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying xdot.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xdot.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xdot.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xdot.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xdot.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/xdot-0.6-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing xdot-0.6-py2.7.egg
Removing /usr/local/lib/python2.7/dist-packages/xdot-0.6-py2.7.egg
Copying xdot-0.6-py2.7.egg to /usr/local/lib/python2.7/dist-packages
xdot 0.6 is already the active version in easy-install.pth
Installing xdot script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/xdot-0.6-py2.7.egg
Processing dependencies for xdot==0.6
Finished processing dependencies for xdot==0.6

Unicode issue in Windows

windows 10 64bit
python 3.4 64bit
pygobject 3.24
graphviz-py 0.7.1
graphviz 2.36
xdot 0.8

when I tried to open tests\unicode.dot
it give error:

Traceback (most recent call last):
File "C:\python34-64\lib\site-packages\xdot\ui\window.py", line 638, in on_open
self.open_file(filename)
File "C:\python34-64\lib\site-packages\xdot\ui\window.py", line 611, in open_file
self.set_dotcode(fp.read(), filename)
File "C:\python34-64\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 32: character maps to

Highlight some word.

Hello.
May you please to add a new functional to selecting some text in node and highlighting them in another nodes? And highlighting only words in search mode.
Thank you.

New release?

Thanks for xdot.py. FWIW I've packaged it in RPM form for Fedora (as "python-xdot"), I've been using it whilst hacking on gcc.

I got a bug report ( https://bugzilla.redhat.com/show_bug.cgi?id=1067887 ) from someone attempting to use it on a file with decimal coordinates, which doesn't work in 0.5, but which you fixed back in e36b49b - and there have been 27 other commits since 0.5

So is there any chance of tagging 0.6? (or I guess I could just package up current "master", if that's OK with you).

Thanks!

Python 3: Hidden AttributeError

Hi, first I'd like to thank you for creating such an useful tool for interactive dot viewing! My first use of this tool was 6 years ago, to view the control flow graphs generated from some compilers.

Today I encountered a small logical bug at https://github.com/jrfonseca/xdot.py/blob/427cd4b/xdot/ui/window.py#L112, where it sets error to be a str while in the other branch (on L115) error is set to be a bytes (as no encoding or errors is set in subprocess.Popen above). Then on L118 there's a error.decode() which is only valid for bytes but not for str, which in my case triggers this bug.

One way to fix this is just to move the decode statement to the branch on L115.

move highlighed edges to the front

I have a graph that is very crowded in some places. Highlighting node and its edges red (with search box) helps a lot. However It often happens that highlighted edge is below many not-highlighted and is hidden anyway.
I propose enhancement that red should be on top of black. Possibly it could also be slightly wider, but that is secondary.

Motivating example:
binfo_... is connected to CLUSTER_0, but it is very hard to see without magnifying glass
Screenshot_20200529_120549
Screenshot_20200529_120617

Parsing error (unexpected char)

I created a dot file using gstreamer.

Xdot will crash trying to open it, but not graphviz's dot:
$ dot -Tpng 0.00.02.363840177-gst-launch.PAUSED_READY.dot -o test.png

$ xdot 0.00.02.363840177-gst-launch.PAUSED_READY.dot
/usr/lib/python3.6/site-packages/xdot.py:35: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk
/usr/lib/python3.6/site-packages/xdot.py:39: PyGIWarning: PangoCairo was imported without specifying a version first. Use gi.require_version('PangoCairo', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import PangoCairo
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1601, in set_dotcode
    self.set_xdotcode(xdotcode)
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1616, in set_xdotcode
    self.graph = parser.parse()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1285, in parse
    DotParser.parse(self)
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1082, in parse
    self.parse_graph()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1091, in parse_graph
    self.parse_stmt()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1121, in parse_stmt
    self.parse_subgraph()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1104, in parse_subgraph
    self.parse_stmt()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1121, in parse_stmt
    self.parse_subgraph()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1104, in parse_subgraph
    self.parse_stmt()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1111, in parse_stmt
    attrs = self.parse_attrs()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1146, in parse_attrs
    name, value = self.parse_attr()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1155, in parse_attr
    name = self.parse_id()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1182, in parse_id
    self.consume()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 963, in consume
    self.lookahead = next(self.lexer)
  File "/usr/lib/python3.6/site-packages/xdot.py", line 913, in __next__
    raise ParseError(msg, self.filename, line, col)
xdot.ParseError: 670:133:unexpected char b'\\'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/xdot", line 11, in <module>
    load_entry_point('xdot==0.7', 'gui_scripts', 'xdot')()
  File "/usr/lib/python3.6/site-packages/xdot.py", line 2159, in main
    win.open_file(args[0])
  File "/usr/lib/python3.6/site-packages/xdot.py", line 2070, in open_file
    self.set_dotcode(fp.read(), filename)
  File "/usr/lib/python3.6/site-packages/xdot.py", line 2052, in set_dotcode
    if self.dotwidget.set_dotcode(dotcode, filename):
  File "/usr/lib/python3.6/site-packages/xdot.py", line 1603, in set_dotcode
    self.error_dialog(str(ex))
AttributeError: 'DotWidget' object has no attribute 'error_dialog'

Here is an example dot file (zipped).

0.00.02.363840177-gst-launch.PAUSED_READY.zip

I am using Arch linux's 0.7-3 xdot community package with python 3.6.3

ImportError: No module named 'gi'

  1. successfully install via pip install --user xdot
  2. run xdot

expected:
opened empty xdot window

actual:

% xdot 
Traceback (most recent call last):
  File "/home/razor/.local/bin/xdot", line 11, in <module>
    load_entry_point('xdot==0.7', 'gui_scripts', 'xdot')()
  File "/usr/lib64/python3.4/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib64/python3.4/site-packages/pkg_resources/__init__.py", line 2627, in load_entry_point
    return ep.load()
  File "/usr/lib64/python3.4/site-packages/pkg_resources/__init__.py", line 2287, in load
    return self.resolve()
  File "/usr/lib64/python3.4/site-packages/pkg_resources/__init__.py", line 2293, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/razor/.local/lib64/python3.4/site-packages/xdot.py", line 33, in <module>
    from gi.repository import GLib
ImportError: No module named 'gi'

Making nodes clickable and linked @dot viewer

Hi,
Dot Viewer is AWESOME!
One thing I liked very much about graphviz is that i can add a url and if I'm saving it as an svg file, I can open it in a browser, click the node and get to where I want.
I wonder if such nice feature can be added to Dot Viewer.
Will be even better if linking between different DAGs will be possible - meaning - clicking one will open another... (linked by path, or any other creative way).

XDot loops on incomplete file

Thank you for this wonderful application! XDot does a great job when displaying dot files and helps a lot when creating dot files manually.

However, if the dot file contains errors, XDot sometimes loops.

In some situations, the parser apparently expects a token of a certain type even after having reached EOF.

Attached you'll find two "buggy" input files causing XDot to hang, plus a tiny patch, which I am using.

Thanks & KR
Björn

buggy_files_plus_patch.zip

Missing tooltip when hovering

Using a node's tooltip attribute does not show a tooltip when hovering with the mouse over the node. This is looks like a bug in xdot, since exporting a dot file to svg and reading it in with a browser does show the tooltip.

Issue found in w3af: "Error: invalid matrix (not invertible)"

We use xdot in w3af (maybe we're using an old version?) and one of our users found this bug: andresriancho/w3af#448

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/xdot.py", line 1536, in do_expose_event
    self.graph.draw(cr, highlight_items=self.highlight)
  File "/usr/local/lib/python2.7/dist-packages/xdot.py", line 447, in draw
    node.draw(cr, highlight=(node in highlight_items))
  File "/usr/local/lib/python2.7/dist-packages/xdot.py", line 327, in draw
    shape.draw(cr, highlight=highlight)
  File "/usr/local/lib/python2.7/dist-packages/xdot.py", line 177, in draw
    cr.restore()
Error: invalid matrix (not invertible)

How to start xdot.py?

I'm sorry for this dumb question, but how do I start xdot.py in the newest version?
Until 4947936 there was a startable file xdot.py but in f0f0326 it was deleted.

The readme just says I should start this file?

cross-compatibility with python2

Hey,
It seems like with the 0.7 release this has became a python3 only library, however this breaks compatibility with applications that require python2.
It would be great if this library could work in a compatible way for both python versions. Using 0.6 for python2 applications may not a good option because of the way distribution level of packaging works. It would be awesome if this library could just work for both versions of python (looking at the python2-to-3 changes this may not be too hard to achieve).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.