Package PyFoam :: Package ThirdParty :: Package Gnuplot :: Module gp_cygwin
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.ThirdParty.Gnuplot.gp_cygwin

  1  # $Id: gp_cygwin.py,v 2.2 2003/04/21 09:44:09 mhagger Exp $ 
  2   
  3  # Copyright (C) 1999-2003 Michael Haggerty <mhagger@alum.mit.edu> 
  4  # 
  5  # This file is licensed under the GNU Lesser General Public License 
  6  # (LGPL).  See LICENSE.txt for details. 
  7   
  8  """gp_cygwin -- an interface to gnuplot for cygwin under Windows. 
  9   
 10  This is identical to gp_win32.py except that prefer_inline_data is 
 11  set. 
 12   
 13  """ 
 14   
 15  __cvs_version__ = '$Revision: 2.2 $' 
 16   
 17   
 18  import Errors 
 19   
 20  # ############ Configuration variables: ################################ 
 21   
22 -class GnuplotOpts:
23 """The configuration options for gnuplot under windows. 24 25 See gp_unix.py for details about the meaning of these options. 26 Please let me know if you know better choices for these settings. 27 28 """ 29 30 # Command to start up the gnuplot program. Note that on windows 31 # the main gnuplot program cannot be used directly because it can 32 # not read commands from standard input. See README for more 33 # information. 34 # 35 # If pgnuplot is in a subdirectory with spaces in its name, extra 36 # quoting is required for windows for it to launch gnuplot. 37 # Moreover, any backslashes in the filename have to be escaped by 38 # writing them as "\\". Example: 39 # 40 # gnuplot_command = '"C:\\Program Files\\gp371w32\\pgnuplot.exe"' 41 gnuplot_command = 'pgnuplot.exe' 42 43 # The '-persist' option is not supported on windows: 44 recognizes_persist = 0 45 46 # As far as I know, gnuplot under windows can use binary data: 47 recognizes_binary_splot = 1 48 49 # Apparently gnuplot on windows can use inline data, but we use 50 # non-inline data (i.e., temporary files) by default for no 51 # special reason: 52 prefer_inline_data = 1 53 54 # os.mkfifo is apparently not supported under Windows. 55 support_fifo = 0 56 prefer_fifo_data = 0 57 58 # The default choice for the 'set term' command (to display on 59 # screen): 60 default_term = 'windows' 61 62 # According to the gnuplot help manual, the following can be used 63 # to print directly to a printer under windows. (Of course it 64 # won't help if your printer can't handle postscript!) 65 default_lpr = 'PRN' 66 67 # Used the 'enhanced' option of postscript by default? Set to 68 # None (*not* 0!) if your version of gnuplot doesn't support 69 # enhanced postscript. 70 prefer_enhanced_postscript = 1
71 72 # ############ End of configuration options ############################ 73 74 75 try: 76 from sys import hexversion 77 except ImportError: 78 hexversion = 0 79 80 if hexversion >= 0x02000000: 81 # Apparently at least as of Python 2.0b1, popen support for 82 # windows is adequate. Give that a try: 83 from os import popen 84 else: 85 # For earlier versions, you have to have the win32 extensions 86 # installed and we use the popen that it provides. 87 from win32pipe import popen 88 89 90 # Mac doesn't recognize persist.
91 -def test_persist():
92 return 0
93 94
95 -class GnuplotProcess:
96 """Unsophisticated interface to a running gnuplot program. 97 98 See gp_unix.py for usage information. 99 100 """ 101
102 - def __init__(self, persist=0):
103 """Start a gnuplot process. 104 105 Create a 'GnuplotProcess' object. This starts a gnuplot 106 program and prepares to write commands to it. 107 108 Keyword arguments: 109 110 'persist' -- the '-persist' option is not supported under 111 Windows so this argument must be zero. 112 113 """ 114 115 if persist: 116 raise Errors.OptionError( 117 '-persist is not supported under Windows!') 118 119 self.gnuplot = popen(GnuplotOpts.gnuplot_command, 'w') 120 121 # forward write and flush methods: 122 self.write = self.gnuplot.write 123 self.flush = self.gnuplot.flush
124
125 - def __call__(self, s):
126 """Send a command string to gnuplot, followed by newline.""" 127 128 self.write(s + '\n') 129 self.flush()
130