~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to dotgraph.py

  • Committer: Aaron Bentley
  • Date: 2007-08-14 19:57:48 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070814195748-ez1h8moqbu6hatjb
Clean up branches error handling when it can't connect

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python2.4
 
1
# Copyright (C) 2004, 2005 Aaron Bentley
 
2
# <aaron.bentley@utoronto.ca>
 
3
#
 
4
#    This program is free software; you can redistribute it and/or modify
 
5
#    it under the terms of the GNU General Public License as published by
 
6
#    the Free Software Foundation; either version 2 of the License, or
 
7
#    (at your option) any later version.
 
8
#
 
9
#    This program is distributed in the hope that it will be useful,
 
10
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
#    GNU General Public License for more details.
 
13
#
 
14
#    You should have received a copy of the GNU General Public License
 
15
#    along with this program; if not, write to the Free Software
 
16
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
2
18
from subprocess import Popen, PIPE
3
19
from urllib import urlencode
4
20
from xml.sax.saxutils import escape
9
25
import time
10
26
 
11
27
RSVG_OUTPUT_TYPES = ('png', 'jpg')
12
 
DOT_OUTPUT_TYPES = ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png', 
 
28
DOT_OUTPUT_TYPES = ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png',
13
29
                    'cmapx')
14
30
 
15
31
class NoDot(Exception):
182
198
        shutil.rmtree(tempdir)
183
199
    return status
184
200
 
185
 
def invoke_dot(input, out_file=None, file_type='svg', antialias=None, 
 
201
def invoke_dot(input, out_file=None, file_type='svg', antialias=None,
186
202
               fontname="Helvetica", fontsize=11):
187
 
    cmdline = ['dot', '-T%s' % file_type, '-Nfontname=%s' % fontname, 
 
203
    cmdline = ['dot', '-T%s' % file_type, '-Nfontname=%s' % fontname,
188
204
               '-Efontname=%s' % fontname, '-Nfontsize=%d' % fontsize,
189
205
               '-Efontsize=%d' % fontsize]
190
206
    if out_file is not None:
197
213
        else:
198
214
            raise
199
215
    for line in input:
200
 
        dot_proc.stdin.write(line)
 
216
        dot_proc.stdin.write(line.encode('utf-8'))
201
217
    dot_proc.stdin.close()
202
218
    return dot_proc.wait()
203
219