gp_cygwin.py :  » Chart-Report » Gnuplot.py » gnuplot-py-1.8 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Chart Report » Gnuplot.py 
Gnuplot.py » gnuplot py 1.8 » gp_cygwin.py
# $Id: gp_cygwin.py 292 2006-03-03 09:49:04Z mhagger $

# Copyright (C) 1999-2003 Michael Haggerty <mhagger@alum.mit.edu>
#
# This file is licensed under the GNU Lesser General Public License
# (LGPL).  See LICENSE.txt for details.

"""gp_cygwin -- an interface to gnuplot for cygwin under Windows.

This is identical to gp_win32.py except that prefer_inline_data is
set.

"""

import Errors

# ############ Configuration variables: ################################

class GnuplotOpts:
    """The configuration options for gnuplot under windows.

    See gp_unix.py for details about the meaning of these options.
    Please let me know if you know better choices for these settings.

    """

    # Command to start up the gnuplot program.  Note that on windows
    # the main gnuplot program cannot be used directly because it can
    # not read commands from standard input.  See README for more
    # information.
    #
    # If pgnuplot is in a subdirectory with spaces in its name, extra
    # quoting is required for windows for it to launch gnuplot.
    # Moreover, any backslashes in the filename have to be escaped by
    # writing them as "\\".  Example:
    #
    #     gnuplot_command = '"C:\\Program Files\\gp371w32\\pgnuplot.exe"'
    gnuplot_command = 'pgnuplot.exe'

    # The '-persist' option is not supported on windows:
    recognizes_persist = 0

    # As far as I know, gnuplot under windows can use binary data:
    recognizes_binary_splot = 1

    # Apparently gnuplot on windows can use inline data, but we use
    # non-inline data (i.e., temporary files) by default for no
    # special reason:
    prefer_inline_data = 1

    # os.mkfifo is apparently not supported under Windows.
    support_fifo = 0
    prefer_fifo_data = 0

    # The default choice for the 'set term' command (to display on
    # screen):
    default_term = 'windows'

    # According to the gnuplot help manual, the following can be used
    # to print directly to a printer under windows.  (Of course it
    # won't help if your printer can't handle postscript!)
    default_lpr = 'PRN'

    # Used the 'enhanced' option of postscript by default?  Set to
    # None (*not* 0!) if your version of gnuplot doesn't support
    # enhanced postscript.
    prefer_enhanced_postscript = 1

# ############ End of configuration options ############################


try:
    from sys import hexversion
except ImportError:
    hexversion = 0

if hexversion >= 0x02000000:
    # Apparently at least as of Python 2.0b1, popen support for
    # windows is adequate.  Give that a try:
    from os import popen
else:
    # For earlier versions, you have to have the win32 extensions
    # installed and we use the popen that it provides.
    from win32pipe import popen


# Mac doesn't recognize persist.
def test_persist():
    return 0


class GnuplotProcess:
    """Unsophisticated interface to a running gnuplot program.

    See gp_unix.py for usage information.

    """

    def __init__(self, persist=0):
        """Start a gnuplot process.

        Create a 'GnuplotProcess' object.  This starts a gnuplot
        program and prepares to write commands to it.

        Keyword arguments:

            'persist' -- the '-persist' option is not supported under
                Windows so this argument must be zero.

        """

        if persist:
            raise Errors.OptionError(
                '-persist is not supported under Windows!')

        self.gnuplot = popen(GnuplotOpts.gnuplot_command, 'w')

        # forward write and flush methods:
        self.write = self.gnuplot.write
        self.flush = self.gnuplot.flush

    def close(self):
        if self.gnuplot is not None:
            self.gnuplot.close()
            self.gnuplot = None

    def __del__(self):
        self.close()

    def __call__(self, s):
        """Send a command string to gnuplot, followed by newline."""

        self.write(s + '\n')
        self.flush()


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.