← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~phill-ridout/openlp/bug1410694 into lp:openlp

 

Phill has proposed merging lp:~phill-ridout/openlp/bug1410694 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1410694 in OpenLP: "global name 'ConnectionException' is not defined in check_latest_version"
  https://bugs.launchpad.net/openlp/+bug/1410694

For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/bug1410694/+merge/246508

Fixes1410694 by fixing typo, also added additional error. Added the OS Name and version to the version file request headers

Add this to your merge proposal:
--------------------------------
lp:~phill-ridout/openlp/bug1410694 (revision 2476)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/865/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/797/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/743/
[FAILURE] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/648/
Stopping after failure
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~phill-ridout/openlp/bug1410694 into lp:openlp.
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py	2015-01-09 15:38:10 +0000
+++ openlp/core/utils/__init__.py	2015-01-14 21:47:04 +0000
@@ -34,6 +34,7 @@
 import logging
 import locale
 import os
+import platform
 import re
 import time
 from shutil import which
@@ -251,14 +252,15 @@
                 req = urllib.request.Request('http://www.openlp.org/files/dev_version.txt')
             else:
                 req = urllib.request.Request('http://www.openlp.org/files/version.txt')
-        req.add_header('User-Agent', 'OpenLP/%s' % current_version['full'])
+        req.add_header('User-Agent', 'OpenLP/%s %s/%s; ' % (current_version['full'], platform.system(),
+                                                            platform.release()))
         remote_version = None
         retries = 0
         while True:
             try:
                 remote_version = str(urllib.request.urlopen(req, None,
                                                             timeout=CONNECTION_TIMEOUT).read().decode()).strip()
-            except ConnectionException:
+            except (urllib.error.URLError, ConnectionError):
                 if retries > CONNECTION_RETRIES:
                     log.exception('Failed to download the latest OpenLP version file')
                 else:

=== modified file 'tests/functional/openlp_core_utils/test_utils.py'
--- tests/functional/openlp_core_utils/test_utils.py	2014-12-31 10:58:13 +0000
+++ tests/functional/openlp_core_utils/test_utils.py	2015-01-14 21:47:04 +0000
@@ -236,6 +236,19 @@
         # THEN: the resolve method is called with the correct argument
         mock_resolver.resolve.assert_called_with('uno:pipe,name=openlp_pipe;urp;StarOffice.ComponentContext')
 
+    def get_uno_instance_socket_test(self):
+        """
+        Test that when the UNO connection type is other than "pipe" the resolver is given the "socket" URI
+        """
+        # GIVEN: A mock resolver object and UNO_CONNECTION_TYPE is "socket"
+        mock_resolver = MagicMock()
+
+        # WHEN: get_uno_instance() is called
+        get_uno_instance(mock_resolver, 'socket')
+
+        # THEN: the resolve method is called with the correct argument
+        mock_resolver.resolve.assert_called_with('uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
+
     def get_user_agent_linux_test(self):
         """
         Test that getting a user agent on Linux returns a user agent suitable for Linux


Follow ups