[Pkg-privacy-commits] [tails-installer] 111/210: Again a bit better website parser

Intrigeri intrigeri at moszumanska.debian.org
Wed May 24 15:26:34 UTC 2017


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to tag 3.90.0
in repository tails-installer.

commit 34a01df00f92841055e4800832e7273119f22000
Author: Martin Briza <mbriza at redhat.com>
Date:   Wed Jun 24 17:54:12 2015 +0200

    Again a bit better website parser
---
 liveusb/releases.py | 41 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 37 insertions(+), 4 deletions(-)

diff --git a/liveusb/releases.py b/liveusb/releases.py
index b0058d7..d4f0381 100644
--- a/liveusb/releases.py
+++ b/liveusb/releases.py
@@ -16,10 +16,32 @@ 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]
 
-def getSpinDownload(url):
+def getRelease(url):
+    return url.split('/')[-1].split('.')[0].split('-')[4]
+
+def getSHA(url):
+    baseurl = '/'.join(url.split('/')[:-1])
+    filename = url.split('/')[-1]
+    d = pyquery.PyQuery(urlread(baseurl))
+    checksum = ''
+    for i in d.items('a'):
+        if 'CHECKSUM' in i.attr('href'):
+            checksum = urlread(baseurl + '/' + i.attr('href'))
+            break
+
+    for line in checksum.split('\n'):
+        i = re.match(r'^SHA256 \(([^)]+)\) = ([a-f0-9]+)$', line)
+        if i:
+            if i.group(1) == filename:
+                return i.group(2)
+    return ''
+
+def getDownload(url):
     d = pyquery.PyQuery(urlread(url))
-    return d('div>div>div>p.gr>a.btn').attr('href')
+    return d('a.btn-success').attr('href')
 
 def getSpinDetails(url, source):
     d = pyquery.PyQuery(urlread(url))
@@ -49,7 +71,11 @@ def getSpinDetails(url, source):
         if len(line):
             spin['description'] += line
 
-    spin['url'] = getSpinDownload(url + "/.." + d('a.btn').attr('href'))
+    download = getDownload(url + "/.." + d('a.btn').attr('href'))
+    spin['url'] = download
+    spin['sha256'] = getSHA(download)
+    spin['arch'] = getArch(download)
+    spin['release'] = getRelease(download)
 
     return spin
 
@@ -105,6 +131,13 @@ def getProductDetails(url, name):
     if name == "Server":
         product['logo'] = 'qrc:/logo-color-server.png'
 
+    if d('a.btn-success'):
+        download = getDownload(url + "/" + d('a.btn-success').attr('href'))
+        product['url'] = download
+        product['sha256'] = getSHA(download)
+        product['arch'] = getArch(download)
+        product['release'] = getRelease(download)
+
     return product
 
 def getProducts(url='https://getfedora.org/'):
@@ -244,6 +277,6 @@ def get_fedora_releases():
     return releases
 
 # A backup list of releases, just in case we can't fetch them.
-fedora_releases = [{'description': u'Here you can choose a OS image from your hard drive to be written to your flash disk', 'releaseDate': '', 'logo': 'qrc:/icon-folder.svg', 'screenshots': [], 'size': 0, 'name': u'Custom OS...', 'url': '', 'arch': '', 'summary': u'<pick from file chooser>', 'source': 'Local', 'sha256': ''}, {'description': "<p>Fedora Workstation is a reliable, user-friendly, and powerful operating system for your laptop or desktop computer. It supports a wide range of d [...]
+fedora_releases = [{'description': u'Here you can choose a OS image from your hard drive to be written to your flash disk', 'releaseDate': '', 'logo': 'qrc:/icon-folder.svg', 'screenshots': [], 'size': 0, 'name': u'Custom OS...', 'url': '', 'arch': '', 'summary': u'<pick from file chooser>', 'source': 'Local', 'sha256': ''}, {'description': "<p>Fedora Workstation is a reliable, user-friendly, and powerful operating system for your laptop or desktop computer. It supports a wide range of d [...]
 
 releases = fedora_releases

-- 
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