Ticket #3542 (closed defect: fixed)

Opened 4 months ago

Last modified 2 months ago

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

Reported by: anonymous Assigned to: 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

processor_options.diff (4.1 kB) - added by anonymous on 08/18/08 04:00:14.
fixes #3542
default_arguments.patch (6.4 kB) - added by cboos on 09/26/08 08:33:31.
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 on 09/26/08 08:35:02.
cumulative patch for graphviz 0.11, on top of r4341

Change History

08/12/08 10:53:54 changed by anonymous

  • severity changed from normal to blocker.

08/18/08 04:00:14 changed by anonymous

  • attachment processor_options.diff added.

fixes #3542

08/18/08 04:05:28 changed by anonymous

Hi.

The attached patch also fixes #3304.

Regards, Claudio

09/26/08 08:31:01 changed 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).

09/26/08 08:33:31 changed by cboos

  • attachment default_arguments.patch added.

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.

09/26/08 08:35:02 changed by cboos

  • attachment graphvizplugin-misc-fixes-r4341.patch added.

cumulative patch for graphviz 0.11, on top of r4341

10/06/08 12:13:52 changed by cboos

  • owner changed from pkropf to cboos.

10/06/08 12:14:35 changed by cboos

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #3542 (default_graph_*, default_node_* and default_edge_* of trac.ini incorrectly handled)




Change Properties
Action