To exit the plotter, enter 'quit' or ^D at the 'gnuplot> ' prompt.
"""
+from __future__ import absolute_import
+from __future__ import print_function
import getopt, glob, os, sys, tempfile
verbose = 0
try:
(opts, args) = getopt.getopt(in_args, s_opts, l_opts)
- except getopt.error, msg:
- print >>sys.stderr, msg
- print >>sys.stderr, __doc__
+ except getopt.error as msg:
+ print(msg, file=sys.stderr)
+ print(__doc__, file=sys.stderr)
sys.exit(1)
for (o, a) in opts:
if o in ('-h', '--help'):
- print __doc__
+ print(__doc__)
sys.exit(0)
elif o in ('-v', '--verbose'):
verbose += 1
(bnos, keys_below) = parse_args(sys.argv[1:])
if verbose:
- print 'Using files:',
- for bno in bnos: print bno,
- if keys_below: print '\nKeys are to be placed below graph'
- else: print ''
+ print('Using files:', end=' ')
+ for bno in bnos: print(bno, end=' ')
+ if keys_below: print('\nKeys are to be placed below graph')
+ else: print('')
tmpdir = tempfile.mktemp()
os.mkdir(tmpdir)
fo = open(t, 'w')
for line in open(f, 'r'):
fld = line.split(None)
- print >>fo, fld[0], fld[1], int(fld[2])-int(fld[1])
+ print(fld[0], fld[1], int(fld[2])-int(fld[1]), file=fo)
fo.close()
t = t[t.rfind('/')+1:]
else: plot_cmd = "%s,'%s'" % (plot_cmd, t)
fo = open('%s/plot.cmds' % tmpdir, 'w')
- print >>fo, cmds
- if len(bnos) > 10 or keys_below: print >>fo, 'set key below'
- print >>fo, plot_cmd
+ print(cmds, file=fo)
+ if len(bnos) > 10 or keys_below: print('set key below', file=fo)
+ print(plot_cmd, file=fo)
fo.close()
pid = os.fork()
if pid == 0:
cmd = 'gnuplot %s/plot.cmds -' % tmpdir
- if verbose: print 'Executing %s' % cmd
+ if verbose: print('Executing %s' % cmd)
os.chdir(tmpdir)
os.system(cmd)
but the -o (--output) and -T (--title) options will be ignored.
"""
+from __future__ import absolute_import
+from __future__ import print_function
+import six
+from six.moves import range
__author__ = 'Alan D. Brunelle <alan.brunelle@hp.com>'
#------------------------------------------------------------------------------
def fatal(msg):
"""Generate fatal error message and exit"""
- print >>sys.stderr, 'FATAL: %s' % msg
+ print('FATAL: %s' % msg, file=sys.stderr)
sys.exit(1)
#------------------------------------------------------------------------------
if not os.path.exists(file):
fatal('%s not found' % file)
elif verbose:
- print 'Processing %s' % file
+ print('Processing %s' % file)
xs = []
ys = []
try:
(opts, args) = getopt.getopt(args[1:], s_opts, l_opts)
- except getopt.error, msg:
- print >>sys.stderr, msg
+ except getopt.error as msg:
+ print(msg, file=sys.stderr)
fatal(__doc__)
for (o, a) in opts:
def color(idx, style):
"""Returns a color/symbol type based upon the index passed."""
- colors = [ 'b', 'g', 'r', 'c', 'm', 'y', 'k' ]
+ colors = [ 'b', 'g', 'r', 'c', 'm', 'y', 'k' ]
l_styles = [ '-', ':', '--', '-.' ]
m_styles = [ 'o', '+', '.', ',', 's', 'v', 'x', '<', '>' ]
color = colors[idx % len(colors)]
if style == 'line':
- style = l_styles[(idx / len(l_styles)) % len(l_styles)]
+ style = l_styles[int((idx / len(l_styles)) % len(l_styles))]
elif style == 'marker':
- style = m_styles[(idx / len(m_styles)) % len(m_styles)]
+ style = m_styles[int((idx / len(m_styles)) % len(m_styles))]
return '%s%s' % (color, style)
ofile = '%s.png' % type
if verbose:
- print 'Generating plot into %s' % ofile
+ print('Generating plot into %s' % ofile)
fig = plt.figure(figsize=plot_size)
ax = fig.add_subplot(111)
legends = None
keys = []
- for file in db.iterkeys():
+ for file in six.iterkeys(db):
if not file in ['min_x', 'max_x', 'min_y', 'max_y']:
keys.append(file)