[Pkg-privacy-commits] [tails-installer] 119/210: Parse the sizes
Intrigeri
intrigeri at moszumanska.debian.org
Wed May 24 15:26:36 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 4cb3c42e23625f4bd9e225907c7fc6a2b284a9b1
Author: Martin Briza <mbriza at redhat.com>
Date: Thu Jul 9 12:49:49 2015 +0200
Parse the sizes
---
liveusb/releases.py | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/liveusb/releases.py b/liveusb/releases.py
index 74c6353..3fd13e3 100644
--- a/liveusb/releases.py
+++ b/liveusb/releases.py
@@ -39,8 +39,16 @@ def getSHA(url):
return i.group(2)
return ''
-def getSize(url):
- return 0
+def getSize(text):
+ match = re.search(r'([0-9.]+)[ ]?([KMG])B', text)
+ size = float(match.group(1))
+ if match.group(2) == 'G':
+ size *= 1024 * 1024 * 1024
+ if match.group(2) == 'M':
+ size *= 1024 * 1024
+ if match.group(2) == 'K':
+ size *= 1024
+ return int(size)
def getDownload(url):
d = pyquery.PyQuery(urlread(url))
@@ -49,7 +57,7 @@ def getDownload(url):
ret[getArch(url)] = dict(
url = url,
sha256 = getSHA(url),
- size = getSize(url)
+ size = getSize(d('a.btn-success').parent().parent()('h5').text())
)
for e in d.items("a"):
if "32-bit" in e.html().lower() and e.attr("href").endswith(".iso"):
@@ -57,7 +65,7 @@ def getDownload(url):
ret[getArch(altUrl)] = dict(
url = altUrl,
sha256 = getSHA(altUrl),
- size = getSize(altUrl)
+ size = getSize(e.text())
)
break
return ret
@@ -72,11 +80,11 @@ def getSpinDetails(url, source):
'logo': 'qrc:/logo-fedora.svg',
'screenshots': [],
'source': '',
- 'variants': dict()
- #{'x86_64': {
- # 'url': '',
- # 'sha256': '',
- # 'size': 0}}
+ 'variants': {'': dict(
+ url='',
+ sha256='',
+ size=0
+ )}
}
spin['source'] = source
@@ -119,11 +127,11 @@ def getProductDetails(url, name):
'logo': 'qrc:/logo-fedora.svg',
'screenshots': [],
'source': '',
- 'variants': dict()
- #{'x86_64': {
- # 'url': '',
- # 'sha256': '',
- # 'size': 0}}
+ 'variants': {'': dict(
+ url='',
+ sha256='',
+ size=0
+ )}
}
product['name'] = name
product['source'] = name
@@ -291,7 +299,7 @@ def get_fedora_releases():
return releases
# A backup list of releases, just in case we can't fetch them.
-fedora_releases = [{'releaseDate': '', 'source': 'Local', 'name': u'Custom OS...', 'logo': 'qrc:/icon-folder.svg', 'variants': {'': {'url': '', 'sha256': '', 'size': 0}}, 'summary': u'Pick a file from your drive(s)', 'screenshots': [], 'description': u'Here you can choose a OS image from your hard drive to be written to your flash disk'}, {'releaseDate': '', 'source': 'Workstation', 'name': 'Workstation', 'logo': 'qrc:/logo-color-workstation.png', 'description': "<p>Fedora Workstation is [...]
+fedora_releases = [{'releaseDate': '', 'source': 'Local', 'name': u'Custom OS...', 'logo': 'qrc:/icon-folder.svg', 'variants': {'': {'url': '', 'sha256': '', 'size': 0}}, 'summary': u'Pick a file from your drive(s)', 'screenshots': [], 'description': u'Here you can choose a OS image from your hard drive to be written to your flash disk'}, {'releaseDate': '', 'source': 'Workstation', 'name': 'Workstation', 'logo': 'qrc:/logo-color-workstation.png', 'description': "<p>Fedora Workstation is [...]
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