Changeset 3956
- Timestamp:
- 01/30/09 13:08:20 (4 years ago)
- Location:
- branch/NetworkInventory/umitPlugin
- Files:
-
- 5 modified
-
Containers.py (modified) (2 diffs)
-
Engine.py (modified) (2 diffs)
-
PluginPage.py (modified) (5 diffs)
-
Tree.py (modified) (4 diffs)
-
Update.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/NetworkInventory/umitPlugin/Containers.py
r3852 r3956 41 41 from distutils.command.install import install as installcmd 42 42 from distutils.command.install_lib import install_lib as install_libcmd 43 from distutils.command.install_egg_info import install_egg_info as install_egginfocmd 43 44 try: 45 from distutils.command.install_egg_info import install_egg_info as install_egginfocmd 46 47 class PlugEggInstaller(install_egginfocmd): 48 def run(self): 49 pass 50 51 except ImportError: 52 pass 44 53 45 54 # For removing directory trees we need … … 367 376 installcmd.run(self) 368 377 369 class PlugEggInstaller(install_egginfocmd):370 def run(self):371 pass372 373 378 class PlugDistribution(Distribution): 374 379 def __init__(self, *attrs): -
branch/NetworkInventory/umitPlugin/Engine.py
r3835 r3956 20 20 21 21 import sys 22 import os, os.path 22 import os 23 import os.path 23 24 24 25 from umitPlugin.Core import Core … … 38 39 """ 39 40 def start(self, reader): 40 "This is the main for your plugin "41 "This is the main for your plugin (reader could be None if testing)" 41 42 pass 42 43 -
branch/NetworkInventory/umitPlugin/PluginPage.py
r3835 r3956 18 18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 20 from __future__ import with_statement21 22 20 import os 23 21 import gtk … … 203 201 204 202 for obj in self.p_window.update_eng.list: 205 with obj.lock: 203 obj.lock.acquire() 204 205 try: 206 206 if obj.status == FILE_GETTING or \ 207 207 obj.status == FILE_CHECKING: … … 211 211 row.message = obj.label 212 212 row.progress = obj.fract 213 finally: 214 obj.lock.release() 213 215 214 216 if not working: … … 299 301 300 302 for upd_obj in self.p_window.update_eng.list: 301 with upd_obj.lock: 302 303 upd_obj.lock.acquire() 304 305 try: 303 306 # Check if we are working 304 307 if upd_obj.status == LATEST_GETTING: … … 308 311 row = upd_obj.object 309 312 row.message = upd_obj.label 313 finally: 314 upd_obj.lock.release() 310 315 311 316 # No locking from here we have finished -
branch/NetworkInventory/umitPlugin/Tree.py
r3878 r3956 64 64 try: 65 65 sys.path.insert(0, path) 66 67 return original_import(name.replace(get_config_vars("SO")[0], ""), \ 68 level=0) 69 except Exception, exc: 70 continue 66 67 try: 68 return original_import(name.replace(get_config_vars("SO")[0], ""), \ 69 level=0) 70 except Exception, exc: 71 continue 71 72 finally: 72 73 sys.path.pop(0) … … 489 490 __builtin__.__import__ = original_import 490 491 491 492 492 def __load_hook(self, pkg): 493 493 """ … … 519 519 520 520 try: 521 # We add to modules to avoid deleting and stop working plugin ;) 522 sys.plugins_path.insert(0, pkg) 523 module = self.__cache_import(pkg) 524 525 except Exception, err: 526 sys.plugins_path.pop(0) 527 raise PluginException(pkg, str(err)) 521 try: 522 # We add to modules to avoid deleting and stop working plugin ;) 523 sys.plugins_path.insert(0, pkg) 524 module = self.__cache_import(pkg) 525 526 except Exception, err: 527 sys.plugins_path.pop(0) 528 raise PluginException(pkg, str(err)) 528 529 529 530 finally: … … 544 545 except Exception, err: 545 546 log.critical("Error while starting %s from %s:" % (plug, pkg)) 546 log.critical( err)547 log.critical(generate_traceback()) 547 548 log.critical("Ignoring instance.") 548 549 -
branch/NetworkInventory/umitPlugin/Update.py
r3835 r3956 18 18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 20 from __future__ import with_statement21 22 20 import os 23 import md5 21 22 try: 23 from hashlib import md5 24 except ImportError: 25 from md5 import md5 24 26 25 27 from threading import RLock … … 177 179 178 180 if isinstance(exc, ErrorNetException): 179 180 with obj.lock: 181 obj.lock.acquire() 182 183 try: 181 184 obj.status = FILE_ERROR 182 185 obj.label = exc.reason … … 185 188 self.__process_next_download() 186 189 return 190 finally: 191 obj.lock.release() 187 192 188 193 elif isinstance(exc, StopNetException): … … 190 195 191 196 data = "" 192 193 with obj.lock: 197 obj.lock.acquire() 198 199 try: 194 200 obj.label = _('Checking validity ...') 195 201 obj.status = FILE_CHECKING … … 199 205 200 206 data = obj.fd.read() 207 finally: 208 obj.lock.release() 201 209 202 210 # Not locked it could freeze the ui 203 hasher = md5.new() 204 hasher.update(data) 205 206 with obj.lock: 211 hasher = md5(data) 212 213 obj.lock.acquire() 214 215 try: 207 216 if hasher.hexdigest() == obj.hash: 208 217 obj.label = _('Updated. Restart to take effect') … … 211 220 obj.label = _('Corrupted file.') 212 221 obj.status = FILE_ERROR 222 finally: 223 obj.lock.release() 224 213 225 else: 214 with obj.lock: 226 obj.lock.acquire() 227 228 try: 215 229 obj.label = _('Updated. Restart to take effect') 216 230 obj.status = FILE_GETTED 217 218 with obj.lock: 231 finally: 232 obj.lock.release() 233 234 obj.lock.acquire() 235 236 try: 219 237 obj.fd.close() 220 238 obj.fract = 1 239 finally: 240 obj.lock.release() 221 241 222 242 try: … … 233 253 234 254 elif isinstance(exc, StartNetException): 235 with obj.lock: 255 obj.lock.acquire() 256 257 try: 236 258 try: 237 259 obj.status = FILE_GETTING … … 242 264 243 265 obj.label = _('Downloading ...') 266 finally: 267 obj.lock.release() 244 268 245 269 elif not exc: … … 268 292 269 293 if isinstance(exc, ErrorNetException): 270 with obj.lock: 294 obj.lock.acquire() 295 296 try: 271 297 obj.status = LATEST_ERROR 272 298 obj.label = _('Cannot find newer version (%s)') % exc.reason … … 274 300 self.__process_next() 275 301 return 302 finally: 303 obj.lock.release() 276 304 277 305 elif isinstance(exc, StopNetException): … … 288 316 type = 1 289 317 290 with obj.lock: 318 obj.lock.acquire() 319 320 try: 291 321 if url and version and type >= 0: 292 322 … … 320 350 321 351 self.__process_next() 352 finally: 353 obj.lock.release() 322 354 323 355 elif not exc:
