Skip to content

Commit e8389ed

Browse files
author
Benedikt J. Daurer
authored
Merge pull request #116 from FXIhub/travis
More changes to be compatible with python 3
2 parents 71005e5 + c8f0dd2 commit e8389ed

9 files changed

Lines changed: 27 additions & 21 deletions

File tree

examples/basic/hitfinding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def onEvent(evt):
5050
analysis.hitfinding.hitrate(evt, hit, history=5000)
5151

5252
# Plot the hitscore
53-
plotting.line.plotHistory(evt["analysis"]["litpixel: hitscore"], label='Nr. of lit pixels', hline=100)
53+
plotting.line.plotHistory(evt["analysis"]["litpixel: hitscore"], label='Nr. of lit pixels', hline=100, group="A")
5454

5555
# Plot the hitrate
56-
plotting.line.plotHistory(evt["analysis"]["hitrate"], label='Hit rate [%]')
56+
plotting.line.plotHistory(evt["analysis"]["hitrate"], label='Hit rate [%]', group="B")
5757

5858
# Visualize detector image of hits
5959
if hit:
60-
plotting.image.plotImage(evt["photonPixelDetectors"]["CCD"], vmin=-10, vmax=40)
60+
plotting.image.plotImage(evt["photonPixelDetectors"]["CCD"], vmin=-10, vmax=40, group="Detectors")

src/interface/Qt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def setResizeMode(self, mode):
167167
QtWidgets.QHeaderView.setResizeMode = setResizeMode
168168

169169

170+
QtGui.qApp = QtWidgets.qApp
170171
QtGui.QApplication = QtWidgets.QApplication
171172
QtGui.QGraphicsScene = QtWidgets.QGraphicsScene
172173
QtGui.QGraphicsObject = QtWidgets.QGraphicsObject

src/interface/data_source.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def subscribe(self, title, plot):
4343
if title not in self._subscribed_titles:
4444
self._subscribed_titles[title] = [plot]
4545
try:
46-
self._data_socket.subscribe(bytes(title))
46+
self._data_socket.subscribe(title)
4747
self.subscribed.emit(title)
4848
logging.debug("Subscribing to %s on %s.", title, self.name())
4949
# socket might still not exist
@@ -58,7 +58,7 @@ def unsubscribe(self, title, plot):
5858
self._subscribed_titles[title].remove(plot)
5959
# Check if list is empty
6060
if not self._subscribed_titles[title]:
61-
self._data_socket.unsubscribe(bytes(title))
61+
self._data_socket.unsubscribe(title)
6262
self.unsubscribed.emit(title)
6363
logging.debug("Unsubscribing from %s on %s.", title, self.name())
6464
self._subscribed_titles.pop(title)
@@ -71,7 +71,7 @@ def subscribe_for_recording(self, title):
7171
if title not in self._recorded_titles:
7272
self._recorded_titles[title] = True
7373
try:
74-
self._data_socket.subscribe(bytes(title))
74+
self._data_socket.subscribe(title)
7575
self.subscribed.emit(title)
7676
logging.debug("Subscribing to %s on %s.", title, self.name())
7777
# socket might still not exist
@@ -83,7 +83,7 @@ def unsubscribe_for_recording(self, title):
8383
If no one else is associated with it unsubscrine"""
8484
self._recorded_titles[title] = False
8585
if not title in self._subscribed_titles:
86-
self._data_socket.unsubscribe(bytes(title))
86+
self._data_socket.unsubscribe(title)
8787
self.unsubscribed.emit(title)
8888
logging.debug("Unsubscribing from %s on %s.", title, self.name())
8989
self._recorded_titles.pop(title)
@@ -109,15 +109,15 @@ def _connect(self):
109109

110110
def _get_data_port(self):
111111
"""Ask to the backend for the data port"""
112-
self._ctrl_socket.send_multipart(['data_port'])
112+
self._ctrl_socket.send_multipart(['data_port'.encode('UTF-8')])
113113

114114
def query_configuration(self):
115115
"""Ask to the backend for the configuration"""
116-
self._ctrl_socket.send_multipart(['conf'])
116+
self._ctrl_socket.send_multipart(['conf'.encode('UTF-8')])
117117

118118
def query_reloading(self):
119119
"""Ask the backend to reload its configuration"""
120-
self._ctrl_socket.send_multipart(['reload'])
120+
self._ctrl_socket.send_multipart(['reload'.encode('UTF-8')])
121121

122122
def _get_request_reply(self, socket=None):
123123
"""Handle the reply of the backend to a previous request"""

src/interface/ringbuffer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def resize(self, new_maxlen):
192192

193193
def _init_data(self):
194194
"""Initialize the buffer with the given data"""
195-
self._data = [None for i in xrange(self._maxlen)]
195+
self._data = [None for i in range(self._maxlen)]
196196

197197
def __len__(self):
198198
"""Return the length of the buffer"""

src/interface/ui/data_window.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def _on_title_change(self, title):
5454
def on_menu_show(self):
5555
"""Show what data sources are available"""
5656
# Go through all the available data sources and add them
57-
5857
def add_menu(title, menu, ds):
5958
action = QtGui.QAction(title, self)
6059
action.setData([ds, title])

src/interface/ui/image_window.ui

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@
490490
<property name="title">
491491
<string>Data Sources</string>
492492
</property>
493+
<addaction name="actionDefault"/>
493494
</widget>
494495
<widget class="QMenu" name="menuSave">
495496
<property name="title">
@@ -709,6 +710,11 @@
709710
<string>Reset Cache</string>
710711
</property>
711712
</action>
713+
<action name="actionDefault">
714+
<property name="text">
715+
<string>default</string>
716+
</property>
717+
</action>
712718
</widget>
713719
<customwidgets>
714720
<customwidget>

src/interface/ui/plotdata_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get_group_row(self, group):
7575
return self.table.indexFromItem(self._groups[group][1]).row()
7676

7777
def item_is_group_header(self, item):
78-
return isinstance(item.data(QtCore.Qt.UserRole), unicode)
78+
return isinstance(item.data(QtCore.Qt.UserRole), type(u""))
7979

8080
def _on_plotdata_added(self, plotdata):
8181
source = self.sender()

src/interface/zmqsocket.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,4 @@ def recv_array(self, flags=0, copy=True, track=False):
109109
"""Receive a numpy array"""
110110
md = self._socket.recv_json(flags=flags)
111111
msg = self._socket.recv(flags=flags, copy=copy, track=track)
112-
buf = buffer(msg)
113-
return numpy.ndarray(shape=md['shape'], dtype=md['dtype'], buffer=buf, strides=md['strides'])
112+
return numpy.ndarray(shape=md['shape'], dtype=md['dtype'], buffer=msg, strides=md['strides'])

src/ipc/zmqserver.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ def send(self, title, data):
119119

120120
def _answer_command(self, stream, msg):
121121
"""Reply to commands received on the _ctrl_stream"""
122-
if(msg[0] == 'conf'):
122+
print(msg)
123+
if(msg[0] == 'conf'.encode('UTF-8')):
123124
stream.socket.send_json(['conf', ipc.broadcast.data_conf])
124-
if(msg[0] == 'data_port'):
125-
stream.socket.send_json(['data_port', bytes(self._broker_pub_port)])
125+
if(msg[0] == 'data_port'.encode('UTF-8')):
126+
stream.socket.send_json(['data_port', self._broker_pub_port])
126127
if(msg[0] == 'uuid'):
127128
stream.socket.send_json(['uuid', bytes(ipc.uuid)])
128-
if(msg[0] == 'reload'):
129+
if(msg[0] == 'reload'.encode('UTF-8')):
129130
#TODO: Find a way to replace this with a direct function call (in all workers)
130131
stream.socket.send_json(['reload', bytes(True)])
131132
print("Answering reload command")
@@ -141,10 +142,10 @@ def _forward_xsub(self, stream, msg):
141142
self._xpub_stream.send_multipart(msg)
142143

143144
def _forward_xpub(self, stream, msg):
144-
if msg[0][0] == '\x00':
145+
if (msg[0][0] == '\x00') or (msg[0][0] == 0):
145146
logging.debug("Got unsubscription for: %r" % msg[0][1:])
146147
self._subscribed.discard(msg[0][1:])
147-
elif msg[0][0] == '\x01':
148+
elif (msg[0][0] == '\x01') or (msg[0][0] == 1):
148149
logging.debug("Got subscription for: %r" % msg[0][1:])
149150
self._subscribed.add(msg[0][1:])
150151
else:

0 commit comments

Comments
 (0)