Commit 741fe40e authored by Andreas Freise's avatar Andreas Freise
Browse files

making lkat files python2/3 compatible'

parent b310015f
...@@ -10,6 +10,11 @@ https://code.google.com/p/ctypesgen/. The command I use to generate the wrapper ...@@ -10,6 +10,11 @@ https://code.google.com/p/ctypesgen/. The command I use to generate the wrapper
You then also need to build libkat.so shared library from the python_shared branch of Finesse. You then also need to build libkat.so shared library from the python_shared branch of Finesse.
Once the above is done the following script may or may not work... Once the above is done the following script may or may not work...
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import ctypes import ctypes
import pylibkat import pylibkat
...@@ -29,7 +34,7 @@ def callback(lkat, maxphi): ...@@ -29,7 +34,7 @@ def callback(lkat, maxphi):
lkat - The handle to the finesse instance lkat - The handle to the finesse instance
maxphi - a shared object between this and the main process, see multiprocessing.Value maxphi - a shared object between this and the main process, see multiprocessing.Value
""" """
print "Entering callback..." print ("Entering callback...")
# first we need to get a handle on the internals of Finesse # first we need to get a handle on the internals of Finesse
inter = pylibkat.interferometer.in_dll(lkat, "inter") inter = pylibkat.interferometer.in_dll(lkat, "inter")
...@@ -51,8 +56,8 @@ def callback(lkat, maxphi): ...@@ -51,8 +56,8 @@ def callback(lkat, maxphi):
maxphi.value = m1.phi maxphi.value = m1.phi
print "Process: Maximum power =", circ.re print ("Process: Maximum power =", circ.re)
print "Process: Mirror tuning =", m1.phi print ("Process: Mirror tuning =", m1.phi)
cmd = """ cmd = """
l l1 1 0 n1 l l1 1 0 n1
...@@ -80,4 +85,4 @@ p = kat.getProcess(callback, maxphi=maxphi) ...@@ -80,4 +85,4 @@ p = kat.getProcess(callback, maxphi=maxphi)
p.start() p.start()
p.join() p.join()
print "Host: Received maximum phi =", maxphi.value print ("Host: Received maximum phi =", maxphi.value)
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pykat import pykat
import pylab import pylab
import numpy import numpy
...@@ -28,9 +32,9 @@ kat.parseCommands(cmd) ...@@ -28,9 +32,9 @@ kat.parseCommands(cmd)
info = kat.lkat_trace() info = kat.lkat_trace()
print "n1 qx =", info["n1"].qx print ("n1 qx =", info["n1"].qx)
print "Cavity info ", info["c1"] print ("Cavity info ", info["c1"])
import numpy import numpy
...@@ -66,7 +70,7 @@ try: ...@@ -66,7 +70,7 @@ try:
g_factors.append(cav.stability_x) g_factors.append(cav.stability_x)
except Exception as ex: except Exception as ex:
print "Exception caught in python: ", ex.message print ("Exception caught in python: ", ex.message)
finally: finally:
# This should always be called no matter what # This should always be called no matter what
lkat._pykat_finish(0) lkat._pykat_finish(0)
......
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