openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #07212
[Merge] lp:~raoul-snyman/openlp/wizard into lp:openlp
Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/wizard into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/wizard/+merge/53820
Update the wizard to show actual downloading on the progress page.
--
https://code.launchpad.net/~raoul-snyman/openlp/wizard/+merge/53820
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/wizard into lp:openlp.
=== modified file 'openlp/core/ui/firsttimeform.py'
--- openlp/core/ui/firsttimeform.py 2011-03-15 01:07:40 +0000
+++ openlp/core/ui/firsttimeform.py 2011-03-17 13:55:22 +0000
@@ -52,7 +52,7 @@
# check to see if we have web access
self.web = u'http://openlp.org/files/frw/'
self.config = SafeConfigParser()
- self.webAccess = get_web_page(u'%s%s' % (self.web, u'download.cfg'))
+ self.webAccess = get_web_page(u'%s%s' % (self.web, u'download.cfg?99'))
if self.webAccess:
files = self.webAccess.read()
self.config.readfp(io.BytesIO(files))
@@ -160,6 +160,16 @@
self._performWizard()
self._postWizard()
+ def _getFileSize(self, url):
+ site = urllib.urlopen(url)
+ meta = site.info()
+ return int(meta.getheaders("Content-Length")[0])
+
+ def _downloadProgress(self, count, block_size, total_size):
+ increment = (count * block_size) - self.previous_size
+ self._incrementProgressBar(None, increment)
+ self.previous_size = count * block_size
+
def _incrementProgressBar(self, status_text, increment=1):
"""
Update the wizard progress page.
@@ -184,19 +194,27 @@
max_progress = 2
# Loop through the songs list and increase for each selected item
for i in xrange(self.songsListWidget.count()):
- if self.songsListWidget.item(i).checkState() == QtCore.Qt.Checked:
- max_progress += 1
+ item = self.songsListWidget.item(i)
+ if item.checkState() == QtCore.Qt.Checked:
+ filename = item.data(QtCore.Qt.UserRole).toString()
+ size = self._getFileSize(u'%s%s' % (self.web, filename))
+ max_progress += size
# Loop through the Bibles list and increase for each selected item
iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
while iterator.value():
item = iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
- max_progress += 1
+ filename = item.data(0, QtCore.Qt.UserRole).toString()
+ size = self._getFileSize(u'%s%s' % (self.web, filename))
+ max_progress += size
iterator += 1
# Loop through the themes list and increase for each selected item
for i in xrange(self.themesListWidget.count()):
- if self.themesListWidget.item(i).checkState() == QtCore.Qt.Checked:
- max_progress += 1
+ item = self.themesListWidget.item(i)
+ if item.checkState() == QtCore.Qt.Checked:
+ filename, screenshot = item.data(QtCore.Qt.UserRole).toPyObject()
+ size = self._getFileSize(u'%s%s' % (self.web, filename))
+ max_progress += size
self.finishButton.setVisible(False)
self.progressBar.setValue(0)
self.progressBar.setMinimum(0)
@@ -241,27 +259,33 @@
item = self.songsListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole).toString()
- self._incrementProgressBar(self.downloading % filename)
+ self._incrementProgressBar(self.downloading % filename, 0)
+ self.previous_size = 0
destination = os.path.join(songs_destination, unicode(filename))
- urllib.urlretrieve(u'%s%s' % (self.web, filename), destination)
+ urllib.urlretrieve(u'%s%s' % (self.web, filename), destination,
+ self._downloadProgress)
# Download Bibles
bibles_iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
while bibles_iterator.value():
item = bibles_iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
bible = unicode(item.data(0, QtCore.Qt.UserRole).toString())
- self._incrementProgressBar(self.downloading % bible)
+ self._incrementProgressBar(self.downloading % bible, 0)
+ self.previous_size = 0
urllib.urlretrieve(u'%s%s' % (self.web, bible),
- os.path.join(bibles_destination, bible))
+ os.path.join(bibles_destination, bible),
+ self._downloadProgress)
bibles_iterator += 1
# Download themes
for i in xrange(self.themesListWidget.count()):
item = self.themesListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
theme = unicode(item.data(QtCore.Qt.UserRole).toString())
- self._incrementProgressBar(self.downloading % theme)
+ self._incrementProgressBar(self.downloading % theme, 0)
+ self.previous_size = 0
urllib.urlretrieve(u'%s%s' % (self.web, theme),
- os.path.join(themes_destination, theme))
+ os.path.join(themes_destination, theme),
+ self._downloadProgress)
# Set Default Display
if self.displayComboBox.currentIndex() != -1:
QtCore.QSettings().setValue(u'General/monitor',
Follow ups