[Pkg-privacy-commits] [tails-installer] 07/13: Better error handling when fetching the release list
Intrigeri
intrigeri at moszumanska.debian.org
Wed May 24 15:28:05 UTC 2017
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to tag 3.95.0
in repository tails-installer.
commit aae6ab819db9623b4a5a49b6a00e523dba4d432a
Author: Martin Briza <mbriza at redhat.com>
Date: Thu Apr 28 11:33:35 2016 +0200
Better error handling when fetching the release list
---
liveusb/grabber.py | 1 +
liveusb/gui.py | 1 -
liveusb/releases.py | 61 ++++++++++++++++++++++++++++++++++++++++-------------
3 files changed, 47 insertions(+), 16 deletions(-)
diff --git a/liveusb/grabber.py b/liveusb/grabber.py
index ace31be..6500ec6 100644
--- a/liveusb/grabber.py
+++ b/liveusb/grabber.py
@@ -5,6 +5,7 @@ import requests
import tempfile
from liveusb import _
+from liveusb import LiveUSBError
from PyQt5.QtCore import QStandardPaths
diff --git a/liveusb/gui.py b/liveusb/gui.py
index ad52762..79f060b 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -706,7 +706,6 @@ class LiveUSBData(QObject):
@pyqtSlot()
def fillReleases(self):
- print ("BAM")
self.releaseModel.beginResetModel()
self.releaseData = []
diff --git a/liveusb/releases.py b/liveusb/releases.py
index ea61370..1c2384a 100644
--- a/liveusb/releases.py
+++ b/liveusb/releases.py
@@ -5,10 +5,11 @@ import traceback
from pyquery import pyquery
-from liveusb.grabber import urlread
-from liveusb import _
+import grabber
+from liveusb import _, LiveUSBError
from PyQt5.QtCore import QDateTime
+
BASE_URL = 'https://dl.fedoraproject.org'
PUB_URL = BASE_URL + '/pub/fedora/linux/releases/'
ALT_URL = BASE_URL + '/pub/alt/releases/'
@@ -30,13 +31,16 @@ def getSHA(url):
baseurl = '/'.join(url.split('/')[:-1])
filename = url.split('/')[-1]
try:
- d = pyquery.PyQuery(urlread(baseurl))
- except LiveUSBError:
+ d = pyquery.PyQuery(grabber.urlread(baseurl))
+ except LiveUSBError, e:
return ''
checksum = ''
for i in d.items('a'):
if 'CHECKSUM' in i.attr('href'):
- checksum = urlread(baseurl + '/' + i.attr('href'))
+ try:
+ checksum = grabber.urlread(baseurl + '/' + i.attr('href'))
+ except LiveUSBError, e:
+ pass
break
for line in checksum.split('\n'):
@@ -60,7 +64,10 @@ def getSize(text):
return int(size)
def getDownload(url):
- d = pyquery.PyQuery(urlread(url))
+ try:
+ d = pyquery.PyQuery(grabber.urlread(url))
+ except LiveUSBError, e:
+ return None
ret = dict()
url = d('a.btn-success').attr('href')
ret[getArch(url)] = dict(
@@ -80,7 +87,10 @@ def getDownload(url):
return ret
def getSpinDetails(url, source):
- d = pyquery.PyQuery(urlread(url))
+ try:
+ d = pyquery.PyQuery(grabber.urlread(url))
+ except LiveUSBError, e:
+ return None
spin = {
'name': '',
'summary': '',
@@ -112,6 +122,8 @@ def getSpinDetails(url, source):
spin['description'] += line
download = getDownload(url + "/.." + d('a.btn').attr('href'))
+ if not download:
+ return None
spin['variants'] = download
spin['version'] = getRelease(download)
if spin['version'] == '23':
@@ -148,19 +160,24 @@ def getSpinDetails(url, source):
return spin
def getSpins(url, source):
- d = pyquery.PyQuery(urlread(url))
+ try:
+ d = pyquery.PyQuery(grabber.urlread(url))
+ except LiveUSBError, e:
+ return None
spins = []
for i in d('div').filter('.high').items('span'):
spinUrl = url + i.siblings()('a').attr('href')
spin = getSpinDetails(spinUrl, source)
+ if not spin:
+ continue
spin['summary'] = i.html()
spins.append(spin)
return spins
def getProductDetails(url):
- d = pyquery.PyQuery(urlread(url))
+ d = pyquery.PyQuery(grabber.urlread(url))
product = {
'name': '',
'summary': '',
@@ -210,7 +227,10 @@ def getProductDetails(url):
return product
def getProducts(url='https://getfedora.org/'):
- d = pyquery.PyQuery(urlread(url))
+ try:
+ d = pyquery.PyQuery(grabber.urlread(url))
+ except LiveUSBError, e:
+ return None
products = []
@@ -222,13 +242,20 @@ def getProducts(url='https://getfedora.org/'):
productUrl += i.attr('href')
if not "cloud" in productUrl and not productUrl.endswith("download"):
- products.append(getProductDetails(productUrl))
+ product = getProductDetails(productUrl)
+ if product:
+ products.append(product)
return products
def get_fedora_flavors(store=True):
r = []
- r += getProducts('https://getfedora.org/')
+ products = getProducts('https://getfedora.org/')
+ spins = getSpins("http://spins.fedoraproject.org", "Spins")
+ labs = getSpins("http://labs.fedoraproject.org", "Labs")
+
+ if products:
+ r += products
r += [{'name': _('Custom OS...'),
'description': _('<p>Here you can choose a OS image from your hard drive to be written to your flash disk</p><p>Currently it is only supported to write raw disk images (.iso or .bin)</p>'),
'logo': 'qrc:/icon_folder',
@@ -238,10 +265,14 @@ def get_fedora_flavors(store=True):
'releaseDate': '',
'source': 'Local',
'variants': {'': dict(url='', sha256='', size=0)}}]
- r += getSpins("http://spins.fedoraproject.org", "Spins")
- r += getSpins("http://labs.fedoraproject.org", "Labs")
- if (store):
+ if spins:
+ r += spins
+ if labs:
+ r += labs
+
+ if store and len(r) > 1:
releases[:] = r
+
return r
# A backup list of releases, just in case we can't fetch them.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/tails-installer.git
More information about the Pkg-privacy-commits
mailing list