[Pkg-privacy-commits] [tails-installer] 03/13: Add a urlread replacement and enable the parser again

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 15400c76336a5d668538b1f3560309fc0ed53fb4
Author: Martin Briza <mbriza at redhat.com>
Date:   Tue Apr 26 11:37:07 2016 +0200

    Add a urlread replacement and enable the parser again
---
 liveusb/grabber.py  | 23 +++++++++++++++++++++++
 liveusb/releases.py | 11 +++--------
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/liveusb/grabber.py b/liveusb/grabber.py
index dd89a23..ec31695 100644
--- a/liveusb/grabber.py
+++ b/liveusb/grabber.py
@@ -118,6 +118,29 @@ def download(parent, url, target_folder=find_downloads(), update_maximum = None,
     return full_path
 
 
+def urlread(url):
+    CHUNK_SIZE = 1024 * 1024
+
+    bytes_read = 0
+    ret = ''
+
+    try:
+        r = requests.get(url, stream=True, allow_redirects=True, timeout=(30.0, 30.0))
+
+        if r.status_code != 200:
+            raise LiveUSBError("Couldn't download the file: %s (%d)" % (r.reason, r.status_code))
+
+        for chunk in r.iter_content(CHUNK_SIZE):
+            bytes_read += len(chunk)
+            ret += chunk
+
+    except requests.exceptions.RequestException as e:
+        raise LiveUSBError("Your internet connection seems to be broken")
+
+    return ret
+
+
+
 
 def __print(val):
     print(val)
diff --git a/liveusb/releases.py b/liveusb/releases.py
index 8a12232..8935119 100644
--- a/liveusb/releases.py
+++ b/liveusb/releases.py
@@ -4,10 +4,7 @@ import re
 import traceback
 
 #todo port away from urlgrabber too
-"""
-from urlgrabber import urlread
-from urlgrabber.grabber import URLGrabError
-"""
+from grabber import urlread
 from pyquery import pyquery
 
 from liveusb import _
@@ -17,7 +14,7 @@ BASE_URL = 'https://dl.fedoraproject.org'
 PUB_URL = BASE_URL + '/pub/fedora/linux/releases/'
 ALT_URL = BASE_URL + '/pub/alt/releases/'
 ARCHES = ('armhfp', 'x86_64', 'i686', 'i386')
-"""
+
 def getArch(url):
     return url.split('/')[-1].split('.')[0].split('-')[3]
 
@@ -229,10 +226,9 @@ def getProducts(url='https://getfedora.org/'):
             products.append(getProductDetails(productUrl))
 
     return products
-"""
+
 def get_fedora_flavors(store=True):
     r = []
-    """
     r += getProducts('https://getfedora.org/')
     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>'),
@@ -247,7 +243,6 @@ def get_fedora_flavors(store=True):
     r += getSpins("http://labs.fedoraproject.org", "Labs")
     if (store):
         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