Changeset 3956

Show
Ignore:
Timestamp:
01/30/09 13:08:20 (4 years ago)
Author:
gpolo
Message:

Merged revisions 3948 via svnmerge from
http://svn.umitproject.org/svnroot/umit/trunk

................

r3948 | nopper | 2009-01-11 17:13:04 -0200 (Sun, 11 Jan 2009) | 9 lines


Merged revisions 3944 via svnmerge from
http://svn.umitproject.org/svnroot/umit/branch/UmitPlugins


........

r3944 | nopper | 2009-01-11 19:47:12 +0100 (dom, 11 gen 2009) | 1 line


Backport to py24

........

................

Location:
branch/NetworkInventory/umitPlugin
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branch/NetworkInventory/umitPlugin/Containers.py

    r3852 r3956  
    4141from distutils.command.install import install as installcmd 
    4242from 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 
     44try: 
     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 
     51except ImportError: 
     52    pass 
    4453 
    4554# For removing directory trees we need 
     
    367376        installcmd.run(self) 
    368377 
    369 class PlugEggInstaller(install_egginfocmd): 
    370     def run(self): 
    371         pass 
    372  
    373378class PlugDistribution(Distribution): 
    374379    def __init__(self, *attrs): 
  • branch/NetworkInventory/umitPlugin/Engine.py

    r3835 r3956  
    2020 
    2121import sys 
    22 import os, os.path 
     22import os 
     23import os.path 
    2324 
    2425from umitPlugin.Core import Core 
     
    3839    """ 
    3940    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)" 
    4142        pass 
    4243 
  • branch/NetworkInventory/umitPlugin/PluginPage.py

    r3835 r3956  
    1818# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    1919 
    20 from __future__ import with_statement 
    21  
    2220import os 
    2321import gtk 
     
    203201         
    204202        for obj in self.p_window.update_eng.list: 
    205             with obj.lock: 
     203            obj.lock.acquire() 
     204 
     205            try: 
    206206                if obj.status == FILE_GETTING or \ 
    207207                   obj.status == FILE_CHECKING: 
     
    211211                row.message = obj.label 
    212212                row.progress = obj.fract 
     213            finally: 
     214                obj.lock.release() 
    213215         
    214216        if not working: 
     
    299301         
    300302        for upd_obj in self.p_window.update_eng.list: 
    301             with upd_obj.lock: 
    302  
     303            upd_obj.lock.acquire() 
     304 
     305            try: 
    303306                # Check if we are working 
    304307                if upd_obj.status == LATEST_GETTING: 
     
    308311                row = upd_obj.object 
    309312                row.message = upd_obj.label 
     313            finally: 
     314                upd_obj.lock.release() 
    310315         
    311316        # No locking from here we have finished 
  • branch/NetworkInventory/umitPlugin/Tree.py

    r3878 r3956  
    6464            try: 
    6565                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 
    7172            finally: 
    7273                sys.path.pop(0) 
     
    489490            __builtin__.__import__ = original_import 
    490491 
    491  
    492492    def __load_hook(self, pkg): 
    493493        """ 
     
    519519 
    520520        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)) 
    528529         
    529530        finally: 
     
    544545                except Exception, err: 
    545546                    log.critical("Error while starting %s from %s:" % (plug, pkg)) 
    546                     log.critical(err) 
     547                    log.critical(generate_traceback()) 
    547548                    log.critical("Ignoring instance.") 
    548549 
  • branch/NetworkInventory/umitPlugin/Update.py

    r3835 r3956  
    1818# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    1919 
    20 from __future__ import with_statement 
    21  
    2220import os 
    23 import md5 
     21 
     22try: 
     23    from hashlib import md5 
     24except ImportError: 
     25    from md5 import md5 
    2426 
    2527from threading import RLock 
     
    177179 
    178180        if isinstance(exc, ErrorNetException): 
    179  
    180             with obj.lock: 
     181            obj.lock.acquire() 
     182 
     183            try: 
    181184                obj.status = FILE_ERROR 
    182185                obj.label = exc.reason 
     
    185188                self.__process_next_download() 
    186189                return 
     190            finally: 
     191                obj.lock.release() 
    187192         
    188193        elif isinstance(exc, StopNetException): 
     
    190195 
    191196                data = "" 
    192  
    193                 with obj.lock: 
     197                obj.lock.acquire() 
     198 
     199                try: 
    194200                    obj.label = _('Checking validity ...') 
    195201                    obj.status = FILE_CHECKING 
     
    199205 
    200206                    data = obj.fd.read() 
     207                finally: 
     208                    obj.lock.release() 
    201209                 
    202210                # 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: 
    207216                    if hasher.hexdigest() == obj.hash: 
    208217                        obj.label = _('Updated. Restart to take effect') 
     
    211220                        obj.label = _('Corrupted file.') 
    212221                        obj.status = FILE_ERROR 
     222                finally: 
     223                    obj.lock.release() 
     224 
    213225            else: 
    214                 with obj.lock: 
     226                obj.lock.acquire() 
     227 
     228                try: 
    215229                    obj.label = _('Updated. Restart to take effect') 
    216230                    obj.status = FILE_GETTED 
    217              
    218             with obj.lock: 
     231                finally: 
     232                    obj.lock.release() 
     233             
     234            obj.lock.acquire() 
     235 
     236            try: 
    219237                obj.fd.close() 
    220238                obj.fract = 1 
     239            finally: 
     240                obj.lock.release() 
    221241             
    222242            try: 
     
    233253         
    234254        elif isinstance(exc, StartNetException): 
    235             with obj.lock: 
     255            obj.lock.acquire() 
     256 
     257            try: 
    236258                try: 
    237259                    obj.status = FILE_GETTING 
     
    242264             
    243265                obj.label = _('Downloading ...') 
     266            finally: 
     267                obj.lock.release() 
    244268 
    245269        elif not exc: 
     
    268292 
    269293        if isinstance(exc, ErrorNetException): 
    270             with obj.lock: 
     294            obj.lock.acquire() 
     295 
     296            try: 
    271297                obj.status = LATEST_ERROR 
    272298                obj.label = _('Cannot find newer version (%s)') % exc.reason 
     
    274300                self.__process_next() 
    275301                return 
     302            finally: 
     303                obj.lock.release() 
    276304         
    277305        elif isinstance(exc, StopNetException): 
     
    288316                type = 1 
    289317 
    290             with obj.lock: 
     318            obj.lock.acquire() 
     319 
     320            try: 
    291321                if url and version and type >= 0: 
    292322 
     
    320350 
    321351                self.__process_next() 
     352            finally: 
     353                obj.lock.release() 
    322354 
    323355        elif not exc: