← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~alisonken1/openlp/bug-1588369-2.4-projectorNetwork-signal into lp:openlp/2.4

 

Ken Roberts has proposed merging lp:~alisonken1/openlp/bug-1588369-2.4-projectorNetwork-signal into lp:openlp/2.4.

Commit message:
Bugfix 1588369 - projectorNetwork signal/slot signature mismatch

Requested reviews:
  Raoul Snyman (raoul-snyman)
  Tim Bentley (trb143)
Related bugs:
  Bug #1588369 in OpenLP: "Projector Won't Connect in OpenLP"
  https://bugs.launchpad.net/openlp/+bug/1588369

For more details, see:
https://code.launchpad.net/~alisonken1/openlp/bug-1588369-2.4-projectorNetwork-signal/+merge/298374

Bugfix 1588369 - projectorNetwork signal/slot signature mismatch

- Fix projectorNetwork signal signature
- Fix projector manager projectorNetwork signature and method call
- Updated pjlink1 test
- Merge 2.4 base and fix conflicts

--------------------------------
lp:~alisonken1/openlp/bug-1588369-2.4-projectorNetwork-signal (revision 2639)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1636/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1547/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1485/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1254/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/844/
[SUCCESS] https://ci.openlp.io/job/Branch-05a-Code_Analysis/912/
[SUCCESS] https://ci.openlp.io/job/Branch-05b-Test_Coverage/780/

-- 
Your team OpenLP Core is subscribed to branch lp:openlp/2.4.
=== modified file 'openlp/core/lib/projector/pjlink1.py'
--- openlp/core/lib/projector/pjlink1.py	2016-06-18 03:18:52 +0000
+++ openlp/core/lib/projector/pjlink1.py	2016-06-25 17:43:37 +0000
@@ -68,7 +68,7 @@
     """
     # Signals sent by this module
     changeStatus = pyqtSignal(str, int, str)
-    projectorNetwork = pyqtSignal(int)  # Projector network activity
+    projectorNetwork = pyqtSignal(str, int)  # Projector network activity
     projectorStatus = pyqtSignal(int)  # Status update
     projectorAuthentication = pyqtSignal(str)  # Authentication error
     projectorNoAuthentication = pyqtSignal(str)  # PIN set and no authentication needed
@@ -396,7 +396,7 @@
             self.projectorReceivedData.emit()
             return
         self.socket_timer.stop()
-        self.projectorNetwork.emit(S_NETWORK_RECEIVED)
+        self.projectorNetwork.emit(self.ip, S_NETWORK_RECEIVED)
         data_in = decode(read, 'ascii')
         data = data_in.strip()
         if len(data) < 7:
@@ -475,17 +475,15 @@
             log.warn('({ip}) send_command(): Not connected - returning'.format(ip=self.ip))
             self.send_queue = []
             return
-        self.projectorNetwork.emit(S_NETWORK_SENDING)
-        log.debug('({ip}) send_command(): Building cmd="{command}" opts="{data}"{salt}'.format(ip=self.ip,
-                                                                                               command=cmd,
-                                                                                               data=opts,
-                                                                                               salt='' if salt is None
-                                                                                               else ' with hash'))
-        out = '{salt}{header}{command} {options}{suffix}'.format(salt="" if salt is None else salt,
-                                                                 header=PJLINK_HEADER,
-                                                                 command=cmd,
-                                                                 options=opts,
-                                                                 suffix=CR)
+        self.projectorNetwork.emit(self.ip, S_NETWORK_SENDING)
+        log.debug('(%s) send_command(): Building cmd="%s" opts="%s" %s' % (self.ip,
+                                                                           cmd,
+                                                                           opts,
+                                                                           '' if salt is None else 'with hash'))
+        if salt is None:
+            out = '%s%s %s%s' % (PJLINK_HEADER, cmd, opts, CR)
+        else:
+            out = '%s%s%s %s%s' % (salt, PJLINK_HEADER, cmd, opts, CR)
         if out in self.send_queue:
             # Already there, so don't add
             log.debug('({ip}) send_command(out="{data}") Already in queue - skipping'.format(ip=self.ip,
@@ -535,13 +533,19 @@
         log.debug('({ip}) _send_string(): Sending "{data}"'.format(ip=self.ip, data=out.strip()))
         log.debug('({ip}) _send_string(): Queue = {data}'.format(ip=self.ip, data=self.send_queue))
         self.socket_timer.start()
-        self.projectorNetwork.emit(S_NETWORK_SENDING)
-        sent = self.write(out.encode('ascii'))
-        self.waitForBytesWritten(2000)  # 2 seconds should be enough
-        if sent == -1:
-            # Network error?
-            self.change_status(E_NETWORK,
-                               translate('OpenLP.PJLink1', 'Error while sending data to projector'))
+        try:
+            self.projectorNetwork.emit(self.ip, S_NETWORK_SENDING)
+            sent = self.write(out.encode('ascii'))
+            self.waitForBytesWritten(2000)  # 2 seconds should be enough
+            if sent == -1:
+                # Network error?
+                self.change_status(E_NETWORK,
+                                   translate('OpenLP.PJLink1', 'Error while sending data to projector'))
+        except SocketError as e:
+            self.disconnect_from_host(abort=True)
+            self.changeStatus(E_NETWORK,
+                              translate('OpenLP.PJLink1', '{code} : {string}').format(code=e.error(),
+                                                                                      string=e.errorString()))
 
     def process_command(self, cmd, data):
         """

=== modified file 'openlp/core/ui/projector/manager.py'
--- openlp/core/ui/projector/manager.py	2015-12-31 22:46:06 +0000
+++ openlp/core/ui/projector/manager.py	2016-06-25 17:43:37 +0000
@@ -61,6 +61,9 @@
                 E_NOT_CONNECTED: ':/projector/projector_not_connected_error.png'
                 }
 
+STATUS_NETWORK_BUSY = [S_CONNECTING, S_NETWORK_SENDING]
+STATUS_NETWORK_FREE = [E_NETWORK, E_UNKNOWN_SOCKET_ERROR, E_NOT_CONNECTED, S_NETWORK_RECEIVED]
+
 
 class Ui_ProjectorManager(object):
     """
@@ -288,6 +291,8 @@
         self.projectordb = projectordb
         self.projector_list = []
         self.source_select_form = None
+        self.network_list = {}  # Currently active network communications keyed on IP
+        self.network_busy = False
 
     def bootstrap_initialise(self):
         """
@@ -482,7 +487,7 @@
         if ans == msg.Cancel:
             return
         try:
-            projector.link.projectorNetwork.disconnect(self.update_status)
+            projector.link.projectorNetwork.disconnect(self.update_network_status)
         except (AttributeError, TypeError):
             pass
         try:
@@ -720,7 +725,7 @@
         thread.started.connect(item.link.thread_started)
         thread.finished.connect(item.link.thread_stopped)
         thread.finished.connect(thread.deleteLater)
-        item.link.projectorNetwork.connect(self.update_status)
+        item.link.projectorNetwork.connect(self.update_network_status)
         item.link.changeStatus.connect(self.update_status)
         item.link.projectorAuthentication.connect(self.authentication_error)
         item.link.projectorNoAuthentication.connect(self.no_authentication_error)
@@ -790,6 +795,39 @@
         """
         return self.projector_list
 
+    @pyqtSlot(str, int)
+    def update_network_status(self, ip, status):
+        """
+        Update network busy icon
+
+        NOTE: Placeholder for bugfix 1588369. Permanent fix will be in trunk for 2.6.
+
+        :param ip: IP of destination
+        :param status: Status code
+        """
+        log.debug('update_network_status(ip="%s" status=%d)' % (ip, status))
+        # Keep track of what connections are currently being chatty
+        if status in STATUS_NETWORK_BUSY:
+            if ip not in self.network_list:
+                log.debug('Adding %s to network list' % ip)
+                self.network_list[ip] = status
+        elif status in STATUS_NETWORK_FREE:
+            if ip in self.network_list:
+                log.debug('Removing %s from network list' % ip)
+                self.network_list.pop(ip)
+            else:
+                log.warn('"%s" not in network list - something got dropped in setting?')
+        else:
+            log.warn('Unknown network status update: ip="%s" stutus: %s' % (ip, status))
+        # Check for turnin on/off network busy icon
+        if self.network_list:
+            log.debug('network list: %s' % self.network_list)
+            log.debug('Turning on network busy icon')
+            self.network_busy = True
+        else:
+            log.debug('No network chatter - turning off network busy icon')
+            self.network_busy = False
+
     @pyqtSlot(str, int, str)
     def update_status(self, ip, status=None, msg=None):
         """

=== modified file 'tests/functional/openlp_core_lib/test_projector_pjlink1.py'
--- tests/functional/openlp_core_lib/test_projector_pjlink1.py	2016-06-18 03:18:52 +0000
+++ tests/functional/openlp_core_lib/test_projector_pjlink1.py	2016-06-25 17:43:37 +0000
@@ -102,6 +102,20 @@
         self.assertEquals(pjlink.pjlink_class, '1',
                           'Non-standard class reply should have set proper class')
 
+    def projector_class_test(self):
+        """
+        Test class version from projector
+        """
+        # GIVEN: Test object
+        pjlink = pjlink_test
+
+        # WHEN: Process class response
+        pjlink.process_clss('1')
+
+        # THEN: Projector class should be set to 1
+        self.assertEquals(pjlink.pjlink_class, '1',
+                          'Projector should have returned class=1')
+
     @patch.object(pjlink_test, 'change_status')
     def test_status_change(self, mock_change_status):
         """


Follow ups