~activity/openobject-server/trunk

« back to all changes in this revision

Viewing changes to bin/pychart/gs_frontend.py

  • Committer: Dainius Malachovskis
  • Date: 2009-06-11 21:01:55 UTC
  • mfrom: (1235.2.5 server)
  • Revision ID: dainius.malachovskis@sandas.eu-20090611210155-ql9k1pd0dnr9avr0
merged

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import os.path
19
19
import pscanvas
20
20
import tempfile
21
 
import string
22
21
import basecanvas
23
22
from scaling import *
24
23
 
25
 
def get_gs_path():
 
24
def _get_gs_path():
26
25
    """Guess where the Ghostscript executable is
27
26
    and return its absolute path name."""
28
 
    path = os.defpath
29
 
    if os.environ.has_key("PATH"):
30
 
        path = os.environ["PATH"]
 
27
    path = os.environ.get("PATH", os.defpath)
 
28
    
31
29
    for dir in path.split(os.pathsep):
32
30
        for name in ("gs", "gs.exe", "gswin32c.exe"):
33
31
            g = os.path.join(dir, name)
34
32
            if os.path.exists(g):
35
33
                return g
36
 
    raise Exception, "Ghostscript not found."
 
34
    raise Exception, "Ghostscript not found. path=%s" % str(path)
37
35
 
38
36
class T(pscanvas.T):
 
37
    """This class is a special kind of canvas that runs ghostscript
 
38
    on the generated postscript contents. It is not used stand-alone, but as
 
39
    a component of PNG and X11 display functionality."""
 
40
    
39
41
    def __write_contents(self, fp):
40
42
        fp.write(pscanvas.preamble_text)
41
43
        for name, id in self.__font_ids.items():
56
58
                                               xscale(self.__xmax),
57
59
                                               yscale(self.__ymax)])
58
60
        
59
 
        gs_path = get_gs_path()
 
61
        gs_path = _get_gs_path()
60
62
        self.pipe_fp = None
61
63
        if self.__output_lines == []:
62
64
            return