From a8ae8546298626fd9cdce6335ea520b9d4d7e76a Mon Sep 17 00:00:00 2001 From: Henrik Enquist Date: Thu, 3 Dec 2020 10:56:45 +0100 Subject: [PATCH 1/6] Dont use python2 compatible TCP --- sardana_pandabox/ctrl/PandaboxCoTiCtrl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py index 12c34ee..4ceb0ce 100644 --- a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py +++ b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py @@ -2,7 +2,7 @@ from pandaboxlib import PandA import time import socket -from sockio.py2 import TCP +from sockio.sio import TCP from StringIO import StringIO import numpy as np From 8048a8403c9a501f288c951d7f95e8c569eafaf8 Mon Sep 17 00:00:00 2001 From: Henrik Enquist Date: Mon, 7 Dec 2020 15:17:22 +0100 Subject: [PATCH 2/6] fix python2 prints --- sardana_pandabox/ctrl/PandaboxCoTiCtrl.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py index 4ceb0ce..82e7146 100644 --- a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py +++ b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py @@ -72,7 +72,7 @@ def __init__(self, inst, props, *args, **kwargs): ack = self.data_socket.write_readline('\n') if "OK" not in ack: raise Exception('Acknowledge to data stream failed!') - print "PandaboxCoTiCtrl: data stream listener starts...", ack + print("PandaboxCoTiCtrl: data stream listener starts...", ack) self.data_buffer = "" self.header_okay_flag = False self.data_end_flag = False @@ -237,12 +237,12 @@ def ReadAll(self): #self.index = 0 if self.data_ready == 0: - print "Pandabox: No data available yet." + print("Pandabox: No data available yet.") self._ParseHeader() return elif self.data_ready <= self._repetitions: if self.data_ready == self._repetitions: - print "Pandabox data acquisition has finished, disabling PCAP..." + print("Pandabox data acquisition has finished, disabling PCAP...") self.pandabox.query('PCAP.ENABLE=ZERO') # it disarms PCAP too try: if not self.data_end_flag: @@ -253,7 +253,7 @@ def ReadAll(self): print "Pandabox data acquisition ENDs okay!" self.data_end_flag = True except socket.error, e: - print "Pandabox: data socket error: ", e + print("Pandabox: data socket error: ", e) self.data_socket.close() data_only = np.genfromtxt(StringIO(self.data_buffer), dtype='float64') @@ -327,10 +327,10 @@ def _ParseHeader(self): try: data_header = self.data_socket.readlines(num_lines+1) #+1 blank line if "fields" in data_header[3]: - print "Pandabox data header parsing okay!" + print("Pandabox data header parsing okay!") self.header_okay_flag = True except socket.error, e: - print "Pandabox: socket error header!!!! = ", e + print("Pandabox: socket error header!!!! = ", e) self.header_okay_flag = False pass @@ -419,8 +419,8 @@ def GetCtrlPar(self, parameter): ctrl.StateAll() ctrl.ReadAll() time.sleep(0.25) - print "Time: ", time.time() - t0 - acqtime - print "COUNTER1.OUT = ", ctrl.ReadOne(2) - print "INENC1.VAL = ", ctrl.ReadOne(3) + print("Time: ", time.time() - t0 - acqtime) + print("COUNTER1.OUT = ", ctrl.ReadOne(2)) + print("INENC1.VAL = ", ctrl.ReadOne(3)) From f7fa56eb7f6e9fcdeeba36435624cd20b00544d5 Mon Sep 17 00:00:00 2001 From: Henrik Enquist Date: Mon, 7 Dec 2020 15:18:14 +0100 Subject: [PATCH 3/6] fix python2 prints --- sardana_pandabox/ctrl/PandaboxCoTiCtrl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py index 82e7146..b5f74f8 100644 --- a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py +++ b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py @@ -201,7 +201,7 @@ def StartAllCT(self): # self._log.debug("StartAllCT(): Entering...") ret = self.pandabox.query('*PCAP.ARM=') if "OK" not in ret: - print "Pandabox arm PCAP failed. Disarm and arm again..." + print("Pandabox arm PCAP failed. Disarm and arm again...") ret = self.pandabox.query('*PCAP.DISARM=') ret = self.pandabox.query('*PCAP.ARM=') @@ -250,7 +250,7 @@ def ReadAll(self): if 'END' not in data: self.data_buffer += data else: - print "Pandabox data acquisition ENDs okay!" + print("Pandabox data acquisition ENDs okay!") self.data_end_flag = True except socket.error, e: print("Pandabox: data socket error: ", e) From ce7178a22c5106bc2ee0620585d2888726264d95 Mon Sep 17 00:00:00 2001 From: Henrik Enquist Date: Mon, 7 Dec 2020 15:20:08 +0100 Subject: [PATCH 4/6] fix python2 except --- sardana_pandabox/ctrl/PandaboxCoTiCtrl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py index b5f74f8..ae29a19 100644 --- a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py +++ b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py @@ -252,7 +252,7 @@ def ReadAll(self): else: print("Pandabox data acquisition ENDs okay!") self.data_end_flag = True - except socket.error, e: + except socket.error as e: print("Pandabox: data socket error: ", e) self.data_socket.close() From 535a632e0c91cf2c930365c6a7724efe58acb56a Mon Sep 17 00:00:00 2001 From: Henrik Enquist Date: Mon, 7 Dec 2020 15:21:08 +0100 Subject: [PATCH 5/6] fix python2 except --- sardana_pandabox/ctrl/PandaboxCoTiCtrl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py index ae29a19..cdf394e 100644 --- a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py +++ b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py @@ -329,7 +329,7 @@ def _ParseHeader(self): if "fields" in data_header[3]: print("Pandabox data header parsing okay!") self.header_okay_flag = True - except socket.error, e: + except socket.error as e: print("Pandabox: socket error header!!!! = ", e) self.header_okay_flag = False pass From 03d7c6f9e4834a137652105e641f823c429467bf Mon Sep 17 00:00:00 2001 From: Henrik Enquist Date: Mon, 7 Dec 2020 15:24:14 +0100 Subject: [PATCH 6/6] Fix import of StringIO --- sardana_pandabox/ctrl/PandaboxCoTiCtrl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py index cdf394e..caad758 100644 --- a/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py +++ b/sardana_pandabox/ctrl/PandaboxCoTiCtrl.py @@ -3,7 +3,7 @@ import time import socket from sockio.sio import TCP -from StringIO import StringIO +from io import StringIO import numpy as np from sardana import State, DataAccess