forked from openlp/openlp
[bug 1410694] Fixing typo, also add additional error.
Add the OS Name and version to the version file request headers bzr-revno: 2476 Fixes: https://launchpad.net/bugs/1410694
This commit is contained in:
commit
bd48100e55
@ -34,6 +34,7 @@ from distutils.version import LooseVersion
|
||||
import logging
|
||||
import locale
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import time
|
||||
from shutil import which
|
||||
@ -251,14 +252,15 @@ def check_latest_version(current_version):
|
||||
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:
|
||||
|
@ -236,6 +236,19 @@ class TestUtils(TestCase):
|
||||
# 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
|
||||
|
Loading…
Reference in New Issue
Block a user