Ignore:
Timestamp:
Apr 26, 2011 11:20:22 AM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
60642b4
Parents:
168a845
Message:

find the path for media

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/models.py

    r5901bb9 r23ccf07  
    99# Time is needed by the log method 
    1010import time 
     11import logging 
    1112 
    1213from sans.guiframe.events import StatusEvent   
     
    1718    
    1819PLUGIN_DIR = 'plugins'  
     20path = os.path.dirname(os.path.sys.path[0]) 
     21file = os.path.join(path, "plugins.log") 
     22 
    1923 
    2024def log(message): 
    2125    """ 
    2226    """ 
    23     out = open("plugins.log", 'a') 
     27    out = open(file, 'a') 
    2428    out.write("%10g:  %s\n" % (time.clock(), message)) 
    2529    out.close() 
     
    107111    except: 
    108112        # Don't deal with bad plug-in imports. Just skip. 
     113        msg = "Could not import model plugin: %s\n" % sys.exc_value 
     114        log(msg) 
    109115        pass 
    110116    return plugins 
     
    172178        in the directory if file were modified 
    173179        """ 
     180        temp = {} 
    174181        if self.is_changed(): 
    175182            #always recompile the folder plugin 
    176183            import compileall 
    177             compileall.compile_dir(dir=PLUGIN_DIR, force=1) 
    178             dir = os.path.join(os.getcwd(), 'plugins') 
    179             log("looking for models in: %s" % str(dir)) 
    180             return _findModels(PLUGIN_DIR) 
    181         return  {} 
    182         
    183      
     184            if os.path.isdir(os.path.abspath(PLUGIN_DIR)): 
     185                dir = os.path.abspath(PLUGIN_DIR) 
     186            else: 
     187                dir = os.path.join(os.path.dirname(os.path.sys.path[0]), 'plugins') 
     188            if not os.path.isdir(dir): 
     189                log("Could not locate models plugins in: %s" % str(dir)) 
     190            else: 
     191                log("looking for models in: %s" % str(dir)) 
     192                compileall.compile_dir(dir=dir, ddir=dir, force=1, quiet=True) 
     193                return  _findModels(dir) 
     194        logging.info("pluging model : %s\n" % str(temp)) 
     195        return temp 
     196         
    184197    def _getModelList(self): 
    185198        """ 
Note: See TracChangeset for help on using the changeset viewer.