Changeset 212bfc2 in sasview for src/sas/sasgui/guiframe/customdir.py
- Timestamp:
- Oct 7, 2016 5:11:40 PM (8 years ago)
- 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b61bd57
- Parents:
- 60df6c1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/customdir.py
rd85c194 r212bfc2 1 1 # Setup and find Custom config dir 2 import sys3 2 import os.path 4 3 import shutil 5 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller6 4 7 5 CONF_DIR = 'config' … … 12 10 Find and return user/.sasview dir 13 11 """ 14 dir = os.path.join(os.path.expanduser("~"), 15 ("." + APPLICATION_NAME)) 16 return dir 12 return os.path.join(os.path.expanduser("~"), ("." + APPLICATION_NAME)) 17 13 18 14 def _find_customconf_dir(): … … 22 18 """ 23 19 u_dir = _find_usersasview_dir() 24 dir = os.path.join(u_dir, CONF_DIR) 25 26 return dir 20 return os.path.join(u_dir, CONF_DIR) 27 21 28 22 def _setup_conf_dir(path): … … 30 24 Setup the custom config dir and cat file 31 25 """ 32 dir = _find_customconf_dir()26 conf_dir = _find_customconf_dir() 33 27 # If the plugin directory doesn't exist, create it 34 if not os.path.isdir(dir): 35 os.makedirs(dir) 36 file = os.path.join(dir, "custom_config.py") 37 cat_file = CategoryInstaller.get_user_file() 38 # If the user category file doesn't exist copy the default to 39 # the user directory 40 if not os.path.isfile(cat_file): 41 try: 42 default_cat_file = CategoryInstaller.get_default_file() 43 if os.path.isfile(default_cat_file): 44 shutil.copyfile(default_cat_file, cat_file) 45 else: 46 print "Unable to find/copy default cat file" 47 except: 48 print "Unable to copy default cat file to the user dir." 28 if not os.path.isdir(conf_dir): 29 os.makedirs(conf_dir) 30 config_file = os.path.join(conf_dir, "custom_config.py") 49 31 50 32 # Place example user models as needed 51 33 try: 52 if not os.path.isfile( file):53 shutil.copyfile(os.path.join(path, "custom_config.py"),file)34 if not os.path.isfile(config_file): 35 shutil.copyfile(os.path.join(path, "custom_config.py"), config_file) 54 36 except: 55 37 # Check for data path next to exe/zip file. … … 63 45 temp_path = os.path.join(f_dir, "custom_config.py") 64 46 if os.path.isfile(temp_path): 65 shutil.copyfile(temp_path, file)47 shutil.copyfile(temp_path, config_file) 66 48 is_dir = True 67 49 break 68 50 if not is_dir: 69 51 raise 70 71 return dir 72 73 52 return conf_dir 53 54 74 55 class SetupCustom(object): 75 56 """ … … 81 62 def setup_dir(self, path): 82 63 return _setup_conf_dir(path) 83 84 85 86 87
Note: See TracChangeset
for help on using the changeset viewer.