Changeset d8e9cb2325469b3c2eb53e85bca47650b14a8822
- Timestamp:
- 11/22/10 14:43:16 (18 months ago)
- Children:
- a9600c54b979c31276a8cb1ebde6f86a1fad96b1, cf7994aa7727099d65825b7d6e36b7077d59ad18
- Parents:
- bad98400ae7869c9fbc79bec7e188fd66356b64c
- git-committer:
- Luper Rouch <luper.rouch@…> (11/22/10 14:43:16)
- Location:
- pyflu/pyflu/update
- Files:
-
- 2 edited
-
qt.py (modified) (7 diffs)
-
signals.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pyflu/pyflu/update/qt.py
rbad9840 rd8e9cb2 5 5 import re 6 6 import louie 7 import urllib2 7 8 from PyQt4.QtGui import * 8 9 from PyQt4.QtCore import * … … 12 13 from pyflu.update.remote import find_patches_groups 13 14 from pyflu.update.version import Version 15 from pyflu.qt.util import get_or_create_app 14 16 15 17 … … 39 41 patch_dl_dir = None 40 42 patch_target_dir = None 43 progress_bar_name = "progress_bar" 44 operation_label_name = "operation_label" 41 45 42 46 def start_update(self, confirm=True): … … 45 49 46 50 If *confirm* is True, a confirmation dialog is shown before starting 47 the update. 48 """ 51 the update. The :class:`~pyflu.update.signals.not_updated` signal is 52 sent if no update was performed (either because there was no update 53 available or the user refused to apply it). 54 """ 55 # Check for updates 49 56 self.patches_paths = [] 50 QDialog.show(self)51 # Check for updates if we are running a frozen executable52 57 self.start_long_operation( 53 58 self.trUtf8("Searching for updates..."), 1) … … 68 73 self._download_next() 69 74 return 70 else: 71 self._exit(0) 72 return 75 louie.send(signals.not_updated, self) 73 76 74 77 def start_long_operation(self, text, length): 75 self.operation_label.setText(text) 76 self.progress_bar.setValue(0) 77 self.progress_bar.setRange(0, length) 78 pb = getattr(self, self.progress_bar_name) 79 ol = getattr(self, self.operation_label_name) 80 ol.setText(text) 81 pb.setValue(0) 82 pb.setRange(0, length) 83 app = get_or_create_app() 84 app.processEvents() 78 85 79 86 def update_long_operation(self, index): 80 self.progress_bar.setValue(index) 87 pb = getattr(self, self.progress_bar_name) 88 pb.setValue(index) 89 app = get_or_create_app() 90 app.processEvents() 81 91 82 92 def _download_next(self): 93 pb = getattr(self, self.progress_bar_name) 94 ol = getattr(self, self.operation_label_name) 83 95 # Open download file object 84 96 self.download_url = self.download_queue.pop(0) 85 97 fname = basename(self.download_url) 86 98 self.save_path = join(self.patch_dl_dir, fname) 87 self.operation_label.setText(self.trUtf8("Downloading '%1'") 88 .arg(fname)) 89 self.progress_bar.setValue(0) 99 ol.setText(self.trUtf8("Downloading '%1'").arg(fname)) 100 pb.setValue(0) 90 101 self.file = QFile(self.save_path) 91 102 self.file.open(QFile.ReadWrite) … … 99 110 100 111 def _update_download_progress(self, received, total): 101 self.progress_bar.setRange(0, total) 102 self.progress_bar.setValue(received) 112 pb = getattr(self, self.progress_bar_name) 113 pb.setRange(0, total) 114 pb.setValue(received) 103 115 104 116 def _flush_download(self): … … 191 203 latest version. 192 204 """ 193 groups = find_patches_groups(self.update_url, 194 re.compile(self.patch_files_pattern)) 195 # Find patches chain entry point 196 current_version = Version(self.current_version) 197 group = groups.get(current_version, []) 198 return [x[2] for x in group] 205 try: 206 groups = find_patches_groups(self.update_url, 207 re.compile(self.patch_files_pattern)) 208 except urllib2.HTTPError, err: 209 pb = getattr(self, self.progress_bar_name) 210 ol = getattr(self, self.operation_label_name) 211 pb.setValue(0) 212 ol.setText(self.trUtf8("Error opening update url: %1") 213 .arg(unicode(err))) 214 else: 215 # Find patches chain entry point 216 current_version = Version(self.current_version) 217 group = groups.get(current_version, []) 218 return [x[2] for x in group] 199 219 200 220 201 221 __all__ = ["StartupDialog"] 202 203 -
pyflu/pyflu/update/signals.py
r77bf72f rd8e9cb2 9 9 It receives a single argument, containing the path of the patched files. 10 10 """ 11 12 13 class not_updated(Signal): 14 """ 15 Sent by :meth:`~pyflu.update.qt.UpdateDialogMixin.start_update` when no 16 update was performed. 17 """
Note: See TracChangeset
for help on using the changeset viewer.
