Changeset 3089
- Timestamp:
- 07/05/08 16:38:36 (5 years ago)
- Location:
- branch/UmitPlugins/umitPlugin
- Files:
-
- 3 modified
-
Network.py (modified) (2 diffs)
-
PluginPage.py (modified) (7 diffs)
-
Update.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/UmitPlugins/umitPlugin/Network.py
r3001 r3089 36 36 def proxy(*args, **kwargs): 37 37 thread = Thread(target=func, args=args, kwargs=kwargs) 38 #thread.setDaemon(True)38 thread.setDaemon(True) 39 39 thread.start() 40 40 return thread … … 158 158 data = list() 159 159 Network.get_url( \ 160 "http://localhost/~stack/plugins/systeminfo/SystemInfo -2.0.0.ump", \160 "http://localhost/~stack/plugins/systeminfo/SystemInfo.ump", \ 161 161 callback, data) 162 162 -
branch/UmitPlugins/umitPlugin/PluginPage.py
r3087 r3089 32 32 from higwidgets.higrichlists import HIGRichList, PluginRow 33 33 34 from Update import FILE_GETTING 34 from Update import FILE_GETTING, FILE_CHECKING 35 35 from Update import LATEST_GETTED, LATEST_ERROR, LATEST_GETTING 36 36 … … 40 40 41 41 self.p_window = parent 42 self.menu_enabled = True 42 43 43 44 self.__create_widgets() … … 128 129 self.install_updates_btn.hide() 129 130 self.find_updates_btn.show() 131 132 self.menu_enabled = True 130 133 131 134 def __on_install_updates(self, widget): … … 170 173 for obj in self.p_window.update_eng.list: 171 174 with obj.lock: 172 if obj.status == FILE_GETTING: 175 if obj.status == FILE_GETTING or \ 176 obj.status == FILE_CHECKING: 173 177 working = True 174 178 … … 212 216 213 217 self.find_updates_btn.set_sensitive(False) 218 self.menu_enabled = False 214 219 215 220 lst = [] … … 295 300 self.populate() 296 301 302 self.menu_enabled = True 297 303 else: 298 304 # Now prepare the download page … … 330 336 "Popup menu" 331 337 338 if not self.menu_enabled: 339 return 340 332 341 menu = gtk.Menu() 333 342 -
branch/UmitPlugins/umitPlugin/Update.py
r3087 r3089 31 31 32 32 from umitPlugin.Network import * 33 from umitPlugin.Atoms import Version 33 34 34 35 STATUS_IDLE = 0 … … 144 145 145 146 def __process_plugin(self, file, data, exc, obj): 146 with obj.lock:147 self.__process_plugin_cb(file, data, exc, obj)148 149 def __process_plugin_cb(self, file, data, exc, obj):150 147 if isinstance(exc, ErrorNetException): 151 obj.status = FILE_ERROR 152 obj.label = exc.reason 153 obj.fract = 1 154 155 self.__process_next_download() 156 return 148 149 with obj.lock: 150 obj.status = FILE_ERROR 151 obj.label = exc.reason 152 obj.fract = 1 153 154 self.__process_next_download() 155 return 157 156 158 157 elif isinstance(exc, StopNetException): 159 158 if obj.hash: 160 obj.label = _('Checking validity ...') 161 obj.status = FILE_CHECKING 162 163 obj.fd.flush() 164 obj.fd.seek(0) 165 159 160 data = "" 161 162 with obj.lock: 163 obj.label = _('Checking validity ...') 164 obj.status = FILE_CHECKING 165 166 obj.fd.flush() 167 obj.fd.seek(0) 168 169 data = obj.fd.read() 170 171 # Not locked it could freeze the ui 166 172 hasher = md5.new() 167 hasher.update(obj.fd.read()) 168 169 if hasher.hexdigest() == obj.hash: 173 hasher.update(data) 174 175 with obj.lock: 176 if hasher.hexdigest() == obj.hash: 177 obj.label = _('Updated. Restart to take effect') 178 obj.status = FILE_GETTED 179 else: 180 obj.label = _('Corrupted file.') 181 obj.status = FILE_ERROR 182 else: 183 with obj.lock: 170 184 obj.label = _('Updated. Restart to take effect') 171 185 obj.status = FILE_GETTED 172 else: 173 obj.label = _('Corrupted file.') 174 obj.status = FILE_ERROR 175 else: 176 obj.label = _('Updated. Restart to take effect') 177 obj.status = FILE_GETTED 178 179 obj.fd.close() 180 obj.fract = 1 186 187 with obj.lock: 188 obj.fd.close() 189 obj.fract = 1 181 190 182 191 # TODO: try/except here … … 190 199 191 200 elif isinstance(exc, StartNetException): 192 try: 193 obj.status = FILE_GETTING 194 obj.size = 0 195 obj.total = int(file.info()['Content-Length']) 196 except: 197 pass 198 199 obj.label = _('Downloading ...') 201 with obj.lock: 202 try: 203 obj.status = FILE_GETTING 204 obj.size = 0 205 obj.total = int(file.info()['Content-Length']) 206 except: 207 pass 208 209 obj.label = _('Downloading ...') 200 210 201 211 elif not exc: … … 218 228 219 229 def __process_manifest(self, file, data, exc, obj): 220 with obj.lock:221 self.__process_manifest_cb(file, data, exc, obj)222 223 def __process_manifest_cb(self, file, data, exc, obj):224 230 """ 225 231 Callback to parse latest.xml file containing meta information about … … 228 234 229 235 if isinstance(exc, ErrorNetException): 230 obj.status = LATEST_ERROR 231 obj.label = _('Cannot find newer version (%s)') % exc.reason 232 233 self.__process_next() 234 return 236 with obj.lock: 237 obj.status = LATEST_ERROR 238 obj.label = _('Cannot find newer version (%s)') % exc.reason 239 240 self.__process_next() 241 return 235 242 236 243 if isinstance(exc, StopNetException): … … 238 245 239 246 new_v = Version(version) 240 cur_v = Version(obj.object. version)247 cur_v = Version(obj.object.reader.version) 241 248 242 249 type = -1 # -1 no action / 0 update / 1 downgrade … … 246 253 elif cur_v < new_v: 247 254 type = 1 248 249 if url and version and type >= 0: 250 251 # We check if the path is the plugins in config_dir 252 253 plug_dir = os.path.join(Path.config_dir, 'plugins') 254 255 if os.path.dirname(obj.object.reader.get_path()) != plug_dir and \ 256 os.access(plug_dir, os.O_RDWR): 257 255 256 with obj.lock: 257 if url and version and type >= 0: 258 259 # We check if the path is the plugins in config_dir 260 261 plug_dir = os.path.join(Path.config_dir, 'plugins') 262 263 if os.path.dirname(obj.object.reader.get_path()) != plug_dir and \ 264 os.access(plug_dir, os.O_RDWR): 265 266 obj.status = LATEST_ERROR 267 268 if not type: 269 obj.label = _('Version %s avaiable but need manual update.') % version 270 else: 271 obj.label = _('Version %s avaiable but need manual downgrade.') % version 272 else: 273 obj.status = LATEST_GETTED 274 obj.label = _('Version %s avaiable.') % version 275 276 obj.version = version 277 obj.url = url 278 obj.hash = hash 279 else: 258 280 obj.status = LATEST_ERROR 259 281 260 if not type:261 obj.label = _(' Version %s avaiable but need manual update.') % version282 if type < 0: 283 obj.label = _('Unable to parse latest.xml') 262 284 else: 263 obj.label = _('Version %s avaiable but need manual downgrade.') % version 264 else: 265 obj.status = LATEST_GETTED 266 obj.label = _('Version %s avaiable.') % version 267 268 obj.version = version 269 obj.url = url 270 obj.hash = hash 271 else: 272 obj.status = LATEST_ERROR 273 274 if type < 0: 275 obj.label = _('Unable to parse latest.xml') 276 else: 277 obj.label = _('No applicable updates found') 278 279 self.__process_next() 285 obj.label = _('No applicable updates found') 286 287 self.__process_next() 280 288 281 289 if not exc:
