diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index a24876e88..c0c8515b0 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -45,7 +45,7 @@ from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, \ check_directory_exists from openlp.core.lib.settings import Settings from openlp.core.utils import get_web_page, AppLocation, join_url, \ - get_filesystem_encoding + get_filesystem_encoding, get_application_version from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage log = logging.getLogger(__name__) @@ -106,7 +106,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): # url is defined in 'download.cfg' file. self.baseurl = None # Check to see if we have web access - self.webAccess = get_web_page(u'%s%s' % (self.web, u'download.cfg')) + user_agent = u'OpenLP/' + get_application_version()[u'version'] + self.webAccess = get_web_page(u'%s%s' % (self.web, u'download.cfg'), header=(u'User-Agent', user_agent)) if self.webAccess: files = self.webAccess.read() self.config.readfp(io.BytesIO(files)) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 964513507..cead844fd 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -493,11 +493,11 @@ def get_web_page(url, header=None, update_openlp=False): if not url: return None req = urllib2.Request(url) - user_agent = _get_user_agent() - log.debug(u'Using user agent: %s', unicode(user_agent)) - req.add_header('User-Agent', user_agent) - if header: - req.add_header(header[0], header[1]) + if not header or header[0].lower() != u'user-agent': + user_agent = _get_user_agent() + req.add_header('User-Agent', str(user_agent)) + elif header: + req.add_header(str(header[0]), str(header[1])) page = None log.debug(u'Downloading URL = %s' % url) try: