Changeset 96814e1 in sasview


Ignore:
Timestamp:
Dec 15, 2011 11:15:21 AM (13 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
ca6481c
Parents:
8ff5cb3
Message:

Re #3 Move plugin directory for models to the user's home directory

Location:
fittingview/src/sans/perspectives/fitting
Files:
4 added
1 edited

Legend:

Unmodified
Added
Removed
  • fittingview/src/sans/perspectives/fitting/models.py

    r916f5c0 r96814e1  
    1111import logging 
    1212import py_compile 
     13import shutil 
    1314from sans.guiframe.events import StatusEvent   
    1415# Explicitly import from the pluginmodel module so that py2exe 
     
    7172def find_plugins_dir(): 
    7273    """ 
    73     Find path of the plugins dir 
    74     """ 
    75     dir = os.path.abspath(PLUGIN_DIR) 
     74        Find path of the plugins directory. 
     75        The plugin directory is located in the user's home directory. 
     76    """ 
     77    dir = os.path.join(os.path.expanduser("~"),'.sansview',PLUGIN_DIR) 
     78     
     79    # If the plugin directory doesn't exist, create it 
    7680    if not os.path.isdir(dir): 
    77         dir = os.path.join(os.getcwd(), PLUGIN_DIR) 
    78     if not os.path.isdir(dir): 
    79         dir = os.path.join(os.path.dirname(__file__), PLUGIN_DIR) 
    80     if not os.path.isdir(dir): 
    81         dir = os.path.join(os.path.dirname(os.path.sys.path[0]), PLUGIN_DIR) 
     81        os.makedirs(dir) 
     82         
     83    # Place example user models as needed 
     84    if not os.path.isfile(os.path.join(dir,"testmodel.py")): 
     85        shutil.copy(os.path.join(os.path.dirname(__file__),"plugin_models","testmodel.py"), dir) 
     86    if not os.path.isfile(os.path.join(dir,"testmodel_2.py")): 
     87        shutil.copy(os.path.join(os.path.dirname(__file__),"plugin_models","testmodel_2.py"), dir) 
     88    if not os.path.isfile(os.path.join(dir,"sum_p1_p2.py")): 
     89        shutil.copy(os.path.join(os.path.dirname(__file__),"plugin_models","sum_p1_p2.py"), dir) 
     90         
    8291    return dir 
    8392 
     
    471480        """ 
    472481        is_modified = False 
    473         if os.path.isdir(PLUGIN_DIR): 
    474             temp =  os.path.getmtime(PLUGIN_DIR) 
     482        plugin_dir = find_plugins_dir() 
     483        if os.path.isdir(plugin_dir): 
     484            temp =  os.path.getmtime(plugin_dir) 
    475485            if  self.last_time_dir_modified != temp: 
    476486                is_modified = True 
Note: See TracChangeset for help on using the changeset viewer.