[Pkg-privacy-commits] [tails-installer] 106/210: Added the products to the new 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 f1d9281f4269d8a592bf8ebef5bd19ceab29cbdf
Author: Martin Briza <mbriza at redhat.com>
Date: Wed Jun 17 16:17:34 2015 +0200
Added the products to the new parser
---
liveusb/gui.py | 2 --
liveusb/releases.py | 92 +++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 79 insertions(+), 15 deletions(-)
diff --git a/liveusb/gui.py b/liveusb/gui.py
index b8fc397..e82c656 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -709,7 +709,6 @@ class ReleaseListProxy(QSortFilterProxyModel):
self.setSourceModel(sourceModel)
def rowCount(self, parent=QModelIndex()):
- print (self._frontPage, self.sourceModel().rowCount(parent))
if self._frontPage and self.sourceModel().rowCount(parent) > 4:
return 4
return self.sourceModel().rowCount(parent)
@@ -758,7 +757,6 @@ class ReleaseListProxy(QSortFilterProxyModel):
@isFront.setter
def isFront(self, value):
if value != self._frontPage:
- print "WOT"
self._frontPage = value
self.isFrontChanged.emit()
self.invalidate()
diff --git a/liveusb/releases.py b/liveusb/releases.py
index 71b6c1d..86d6bac 100644
--- a/liveusb/releases.py
+++ b/liveusb/releases.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
import re
import traceback
@@ -14,23 +16,27 @@ PUB_URL = BASE_URL + '/pub/fedora/linux/releases/'
ALT_URL = BASE_URL + '/pub/alt/releases/'
ARCHES = ('armhfp', 'x86_64', 'i686', 'i386')
+
def getSpinDownload(url):
d = pyquery.PyQuery(urlread(url))
return d('div>div>div>p.gr>a.btn').attr('href')
def getSpinDetails(url, source):
d = pyquery.PyQuery(urlread(url))
- spin = {'name': '',
- 'description': '',
- 'screenshots': [],
- 'logo': 'qrc:/logo-fedora.svg',
- 'url': '',
- 'summary': '',
- 'sha256': '',
- 'size': 0,
- 'releaseDate': '',
- 'source': source,
- 'arch': 'x86_64'}
+ spin = {
+ 'name': '',
+ 'description': '',
+ 'screenshots': [],
+ 'logo': 'qrc:/logo-fedora.svg',
+ 'url': '',
+ 'summary': '',
+ 'sha256': '',
+ 'size': 0,
+ 'releaseDate': '',
+ 'source': '',
+ 'arch': 'x86_64'
+ }
+ spin['source'] = source
spin['name'] = d('title').html().strip()
screenshot = d('img').filter('.img-responsive').attr('src')
@@ -59,7 +65,65 @@ def getSpins(url, source):
return spins
-def get_fedora_spins():
+def getProductDetails(url, name):
+ d = pyquery.PyQuery(urlread(url))
+ product = {
+ 'name': '',
+ 'description': '',
+ 'screenshots': [],
+ 'logo': 'qrc:/logo-fedora.svg',
+ 'url': '',
+ 'summary': '',
+ 'sha256': '',
+ 'size': 0,
+ 'releaseDate': '',
+ 'source': '',
+ 'arch': 'x86_64'
+ }
+ product['name'] = name
+ product['source'] = name
+
+ product['summary'] = d('h1').html()
+
+ for i in d('div.col-md-8, div.col-sm-8, div.col-md-5, div.col-md-6, div.col-sm-5, div.col-sm-6').items('p, h3, h2'):
+ i.remove('a, br, img')
+ if i.parent().parent()('blockquote'):
+ i = i.parent().parent()('blockquote')
+ product['description'] += '<blockquote>'
+ product['description'] += str(i('p'))
+ product['description'] += '<p align=right> ― <em>' + i('cite').html() + '</em></p>'
+ product['description'] += '</blockquote>'
+ elif i.html() and len(i.html()) > 0: # can't remove empty tags with :empty for some reason
+ product['description'] += str(i)
+ product['description'].replace('h3', 'h4')
+
+ if name == "Workstation":
+ product['logo'] = 'qrc:/logo-color-workstation.png'
+ if name == "Cloud":
+ product['logo'] = 'qrc:/logo-color-cloud.png'
+ if name == "Server":
+ product['logo'] = 'qrc:/logo-color-server.png'
+
+ return product
+
+def getProducts(url='https://getfedora.org/'):
+ d = pyquery.PyQuery(urlread(url))
+
+ products = []
+
+ for i in d('div.productitem').items('a'):
+ productUrl = url
+ if i.attr('href').startswith("../"):
+ productUrl += i.attr('href')[3:]
+ else:
+ productUrl += i.attr('href')
+ productName = i('h4').html()
+
+ products.append(getProductDetails(productUrl, productName))
+
+ return products
+
+def get_fedora_flavors():
releases = [{'name': _('Custom OS...'),
'description': _('Here you can choose a OS image from your hard drive to be written to your flash disk'),
'logo': 'qrc:/icon-folder.svg',
@@ -71,8 +135,10 @@ def get_fedora_spins():
'releaseDate': '',
'source': 'Local',
'arch': ''}]
+ releases += getProducts('https://getfedora.org/')
releases += getSpins("http://spins.fedoraproject.org", "Spins")
releases += getSpins("http://labs.fedoraproject.org", "Labs")
+ print releases
def get_fedora_releases():
global releases
@@ -177,6 +243,6 @@ def get_fedora_releases():
return releases
# A backup list of releases, just in case we can't fetch them.
-fedora_releases = [{'size': 0, 'source': 'Local', 'sha256': '', 'name': u'Custom OS...', 'url': '', 'releaseDate': '', 'logo': 'qrc:/icon-folder.svg', 'summary': u'<pick from file chooser>', 'screenshots': [], 'arch': '', 'description': u'Here you can choose a OS image from your hard drive to be written to your flash disk'}, {'description': u'<p>The Fedora KDE Plasma Desktop Edition is a powerful Fedora-based operating system utilizing the KDE Plasma Desktop as the main user interface.</ [...]
+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