Modify

Opened 6 years ago

Closed 6 years ago

#3542 closed defect (fixed)

default_graph_*, default_node_* and default_edge_* of trac.ini incorrectly handled

Reported by: anonymous Owned by: cboos
Priority: normal Component: GraphvizPlugin
Severity: major Keywords:
Cc: Trac Release: 0.11

Description

On some ports the default_* options are handled incorrectly, building an invalid command line for dot. I researched the problem and it is caused by subprocess.Popen() implementation on Unix platforms.

The code that builds the command line (graphviz.py:382...393) concatenates all filtered ini file options into a single string. Later it is passed as a single subprocess argument. On Posix this will be interpreted as a single argument and causes errors such as "Could not find/open font".

Another problem related to this occurs, when you don't specify any default_ options in your ini file. In this case an empty argument is passed to the dot executable, which returns an error.

Proposed FIX

To fix the problem self.processor_options datatype should be changed to list and all occurrences revised (graphviz.py:182,185,209,225,237,382...393).

Line 182

            sha_text = self.processor.encode(encoding) + u''.join(self.processor_options).encode(encoding) + content

Line 185

            sha_text = self.processor + ''.join(self.processor_options) + content

Line 209

                cmd = [proc_cmd]
                cmd += self.processor_options
                cmd += ['-Tsvg', '-o%s.svg' % img_path]

Line 225

                cmd = [proc_cmd]
                cmd += self.processor_options
                cmd += ['-T%s' % self.out_format, '-o%s' % img_path]

Line 237

                    cmd = [proc_cmd]
                    cmd += self.processor_options
                    cmd += ['-Tcmap', '-o%s' % map_path]

Lines 382...393

        self.processor_options = []
        default_attributes = [ o for o in self.config.options('graphviz') if o[0].startswith('default_') ]
        if default_attributes:
           graph_attributes   = [ o for o in default_attributes if o[0].startswith('default_graph_') ]
           node_attributes    = [ o for o in default_attributes if o[0].startswith('default_node_') ]
           edge_attributes    = [ o for o in default_attributes if o[0].startswith('default_edge_') ]
           if graph_attributes:
               self.processor_options += [ "-G" + o[0].replace('default_graph_', '') + "=" + o[1] for o in graph_attributes]
           if node_attributes:
               self.processor_options += [ "-N" + o[0].replace('default_node_', '') + "=" + o[1] for o in node_attributes]
           if edge_attributes:
               self.processor_options += [ "-E" + o[0].replace('default_edge_', '') + "=" + o[1] for o in edge_attributes]

Attachments (3)

processor_options.diff (4.1 KB) - added by anonymous 6 years ago.
fixes #3542
default_arguments.patch (6.4 KB) - added by cboos 6 years ago.
rework self.processor_options so that it's now a list and also change the encoding is performed (everything is now done in self.launch). Should be applied on top of the patches I sent this morning.
graphvizplugin-misc-fixes-r4341.patch (9.7 KB) - added by cboos 6 years ago.
cumulative patch for graphviz 0.11, on top of r4341

Download all attachments as: .zip

Change History (8)

comment:1 Changed 6 years ago by anonymous

  • Severity changed from normal to blocker

Changed 6 years ago by anonymous

fixes #3542

comment:2 Changed 6 years ago by anonymous

Hi.

The attached patch also fixes #3304.

Regards, Claudio

comment:3 Changed 6 years ago by cboos

  • Severity changed from blocker to major

I came up with a solution similar to attachment:processor_options.diff, but mine should be more robust w.r.t. unicode strings in those parameters.

This patch also improves upon some of my patches of this morning (#3605 and #3073).

Changed 6 years ago by cboos

rework self.processor_options so that it's now a list and also change the encoding is performed (everything is now done in self.launch). Should be applied on top of the patches I sent this morning.

Changed 6 years ago by cboos

cumulative patch for graphviz 0.11, on top of r4341

comment:4 Changed 6 years ago by cboos

  • Owner changed from pkropf to cboos

comment:5 Changed 6 years ago by cboos

  • Resolution set to fixed
  • Status changed from new to closed

Patch similar to default_arguments.patch applied in [4395].

Add Comment

Modify Ticket

Action
as closed The owner will remain cboos.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.