Commit d05f4cd5 authored by Daniel Brown's avatar Daniel Brown
Browse files

Merge branch 'master' of gitmaster.atlas.aei.uni-hannover.de:pykat/pykat

parents 9fb26587 23cd8c96
......@@ -4,9 +4,12 @@ Created on Mon Jan 28 11:58:09 2013
@author: Daniel
"""
from __future__ import print_function
import numpy
from numpy import min,max
import exceptions
import pykat.external.six as six
if six.PY2:
import exceptions
from components import *
from structs import *
from pykat.param import Param, putter
......
......@@ -4,7 +4,10 @@ Created on Mon Jan 28 11:10:01 2013
@author: Daniel
"""
import exceptions
from __future__ import print_function
import pykat.external.six as six
if six.PY2:
import exceptions
import pykat.exceptions as pkex
import pykat
from pykat.node_network import *
......
......@@ -4,7 +4,10 @@ Created on Fri Feb 01 0split()9:09:10 2013
@author: Daniel
"""
import exceptions
from __future__ import print_function
import pykat.external.six as six
if six.PY2:
import exceptions
import abc
from pykat.node_network import *
from pykat.param import Param
......@@ -878,4 +881,4 @@ class qhd(Detector2):
for p in self._params:
rtn.extend(p.getFinesseText())
return rtn
\ No newline at end of file
return rtn
import exceptions
from __future__ import print_function
import pykat.external.six as six
if six.PY2:
import exceptions
import os
class BasePyKatException(Exception):
......
This diff is collapsed.
Copyright (c) 2010-2014 Benjamin Peterson
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
......@@ -23,6 +23,7 @@ Contact at ddb@star.sr.bham.ac.uk
@author: Daniel Brown
"""
from __future__ import print_function
import sys
import os
import subprocess
......@@ -92,7 +93,7 @@ def f__lkat_process(callback, cmd, kwargs):
callback(lkat, **kwargs)
except Exception as ex:
print "Exception caught in python: ", ex.message
print("Exception caught in python: ", ex.message)
finally:
# This should always be called no matter what
lkat._pykat_finish(0)
......@@ -493,7 +494,7 @@ class kat(object):
@staticmethod
def logo():
print """ ..-
print(""" ..-
PyKat {0:7} _ '(
\\`.|\\.__...-\"\"""-_." )
..+-----.._ / ' ` .-'
......@@ -501,7 +502,7 @@ class kat(object):
( '::;;+;;: `-"' =" /,`"" `) /
L. \\`:::a:f c_/ n_'
..`--...___`. . ,
`^-....____: +. {1}\n""".format(pykat.__version__, pykat_web)
`^-....____: +. {1}\n""".format(pykat.__version__, pykat_web))
def loadKatFile(self, katfile, blocks=None):
commands=open(katfile).read()
......@@ -709,7 +710,7 @@ class kat(object):
self.deriv_h = float(v[1])
elif(first == "gnuterm" or first == "pyterm"):
if self.verbose:
print "Ignoring Gnuplot/Python terminal command '{0}'".format(line)
print("Ignoring Gnuplot/Python terminal command '{0}'".format(line))
elif(first == "fsig"):
after_process.append(line)
elif(first == "noplot"):
......@@ -717,7 +718,7 @@ class kat(object):
self.__blocks[self.__currentTag].contents.append(line)
else:
if self.verbose:
print "Parsing `{0}` into pykat object not implemented yet, added as extra line.".format(line)
print("Parsing `{0}` into pykat object not implemented yet, added as extra line.".format(line))
obj = line
# manually add the line to the block contents
......@@ -726,13 +727,13 @@ class kat(object):
if obj != None and not isinstance(obj, str):
if self.hasNamedObject(obj.name):
getattr(self, obj.name).remove()
print "Removed existing object '{0}' of type {1} to add line '{2}'".format(obj.name, obj.__class__, line)
print("Removed existing object '{0}' of type {1} to add line '{2}'".format(obj.name, obj.__class__, line))
self.add(obj)
except:
print "--------------------------------------------------------"
print "Error parsing line: " + line
print "--------------------------------------------------------"
print("--------------------------------------------------------")
print("Error parsing line: " + line)
print("--------------------------------------------------------")
raise
......@@ -857,7 +858,7 @@ class kat(object):
katfile.close()
except pkex.BasePyKatException as ex:
print ex
print(ex)
def getProcess(self, callback, **kwargs):
......@@ -910,8 +911,8 @@ class kat(object):
if not (os.path.isfile(kat_exec) and os.access(kat_exec, os.X_OK)):
raise pkex.MissingFinesse()
if self.verbose: print "--------------------------------------------------------------"
if self.verbose: print "Running kat - Started at " + str(start)
if self.verbose: print("--------------------------------------------------------------")
if self.verbose: print("Running kat - Started at " + str(start))
if hasattr(self, "x2axis") and self.noxaxis == False:
r = katRun2D()
......@@ -994,9 +995,9 @@ class kat(object):
[out,errpipe] = p.communicate()
if printout == 1:
print out
print(out)
else:
if printerr == 1: print ""
if printerr == 1: print("")
# get the version number
ix = out.find('build ') + 6
......@@ -1007,7 +1008,7 @@ class kat(object):
# If Finesse returned an error, just print that and exit!
if p.returncode != 0:
print err
print(err)
sys.exit(1)
self.__prevrunfilename = katfile.name
......@@ -1027,7 +1028,7 @@ class kat(object):
os.rename(outfile, newoutfile)
if self.verbose: print "\nOutput data saved to '{0}'".format(newoutfile)
if self.verbose: print("\nOutput data saved to '{0}'".format(newoutfile))
if hasattr(self, "x2axis") and self.noxaxis == False:
[r.x,r.y,r.z,hdr] = self.readOutFile(outfile)
......@@ -1054,7 +1055,7 @@ class kat(object):
os.rename(katfile.name, newkatfile)
if self.verbose: print "Kat file saved to '{0}'".format(newkatfile)
if self.verbose: print("Kat file saved to '{0}'".format(newkatfile))
if self.trace != None and self.trace > 0:
#print "{0}".format(out)
......@@ -1064,7 +1065,7 @@ class kat(object):
#print "Trace 1: {0}".format(out[search:])
# for now, just try to print the trace block in full
print out[out.find(' ---') :]
print(out[out.find(' ---') :])
katfile.close()
perfData = []
......@@ -1081,10 +1082,10 @@ class kat(object):
return r
except pkex.FinesseRunError as fe:
print fe
print(fe)
finally:
if self.verbose: print ""
if self.verbose: print "Finished in " + str(datetime.datetime.now()-start)
if self.verbose: print("")
if self.verbose: print("Finished in " + str(datetime.datetime.now()-start))
def remove(self, obj):
if not isinstance(obj, pykat.finesse.Signals) and not (obj.name in self.__components or obj.name in self.__detectors or obj.name in self.__commands or obj in self.signals.targets):
......@@ -1135,7 +1136,7 @@ class kat(object):
self.noxaxis = True
self.printmatrix = True
print "".join(self.generateKatScript())
print("".join(self.generateKatScript()))
self.verbose = True
self.run(printout=1)
self.printmatrix = None
......@@ -1207,7 +1208,7 @@ class kat(object):
obj._on_kat_add(self)
except pkex.BasePyKatException as ex:
print ex
print(ex)
def readOutFile(self, filename):
......@@ -1262,7 +1263,7 @@ class kat(object):
for obj in objs:
if isinstance(obj, str):
if fragment in obj:
print " ** removing line '{0}'".format(obj)
print(" ** removing line '{0}'".format(obj))
objs.remove(obj)
found = True
......@@ -1549,7 +1550,7 @@ class kat(object):
name = com.__class__.__name__
print getattr(self.__class__, name)
print(getattr(self.__class__, name))
delattr(self.__class__, name)
delattr(self, '__com_' + name)
......
......@@ -5,12 +5,15 @@ Created on Fri Feb 01 09:13:03 2013
@author: Daniel
"""
from __future__ import print_function
import pykat.external.six as six
if six.PY2:
import exceptions
from PyQt4.QtGui import *
from PyQt4.Qt import *
from PyQt4 import QtSvg
from PyQt4.QtSvg import QGraphicsSvgItem
import pykat.components
import exceptions
import weakref
nsize = 10
......
......@@ -4,7 +4,7 @@ Created on Sun Jan 27 10:02:41 2013
@author: Daniel
"""
from __future__ import print_function
from pykat import USE_GUI, NoGUIException
if USE_GUI:
......@@ -349,7 +349,7 @@ class NodeNetwork(object):
return False
elif isinstance(currcomp, pykat.components.isolator):
print "isol"
print("isol")
elif isinstance(currcomp, pykat.components.laser):
# if we are at a laser then we can't go any further
# and it isn;t this node as we checked before
......
from __future__ import print_function
import abc
import pykat.exceptions as pkex
import weakref
......@@ -150,7 +151,7 @@ class Param(putable, putter):
#if this param can be put somewhere we need to check if it is
if self.isPutable:
for a in self.putees:
print "Removing put from {0} {1} to {2} {3}".format(self.owner.name, self.name, a.owner.name, a.name)
print("Removing put from {0} {1} to {2} {3}".format(self.owner.name, self.name, a.owner.name, a.name))
a._putter = None
self.put_count -= 1
......@@ -160,7 +161,7 @@ class Param(putable, putter):
# check if we have anything being put to us
if self.isPutter:
if self._putter != None:
print "Removing put from {0} {1} to {2} {3}".format(self._putter.owner.name, self._putter.name, self.owner.name, self.name)
print("Removing put from {0} {1} to {2} {3}".format(self._putter.owner.name, self._putter.name, self.owner.name, self.name))
self._putter.put_count -= 1
self._putter.putees.remove(self)
self._putter = None
......
......@@ -2,7 +2,7 @@ from itertools import combinations_with_replacement as combinations
from pykat.utilities.optics.gaussian_beams import beam_param, HG_beam
from pykat.exceptions import BasePyKatException
from romhom import u_star_u
from progressbar import ProgressBar, ETA, Percentage, Bar
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
from scipy.interpolate import interp2d
from scipy.integrate import dblquad
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment