forked from openlp/openlp
Specify OpenLP as the user agent when querying SF.net
This commit is contained in:
parent
60b7f2dbbd
commit
a023e63f21
@ -45,7 +45,7 @@ from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, \
|
|||||||
check_directory_exists
|
check_directory_exists
|
||||||
from openlp.core.lib.settings import Settings
|
from openlp.core.lib.settings import Settings
|
||||||
from openlp.core.utils import get_web_page, AppLocation, join_url, \
|
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
|
from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -106,7 +106,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
|||||||
# url is defined in 'download.cfg' file.
|
# url is defined in 'download.cfg' file.
|
||||||
self.baseurl = None
|
self.baseurl = None
|
||||||
# Check to see if we have web access
|
# 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:
|
if self.webAccess:
|
||||||
files = self.webAccess.read()
|
files = self.webAccess.read()
|
||||||
self.config.readfp(io.BytesIO(files))
|
self.config.readfp(io.BytesIO(files))
|
||||||
|
@ -493,11 +493,11 @@ def get_web_page(url, header=None, update_openlp=False):
|
|||||||
if not url:
|
if not url:
|
||||||
return None
|
return None
|
||||||
req = urllib2.Request(url)
|
req = urllib2.Request(url)
|
||||||
user_agent = _get_user_agent()
|
if not header or header[0].lower() != u'user-agent':
|
||||||
log.debug(u'Using user agent: %s', unicode(user_agent))
|
user_agent = _get_user_agent()
|
||||||
req.add_header('User-Agent', user_agent)
|
req.add_header('User-Agent', str(user_agent))
|
||||||
if header:
|
elif header:
|
||||||
req.add_header(header[0], header[1])
|
req.add_header(str(header[0]), str(header[1]))
|
||||||
page = None
|
page = None
|
||||||
log.debug(u'Downloading URL = %s' % url)
|
log.debug(u'Downloading URL = %s' % url)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user