Changeset ea5fa58 in sasview for sansguiframe
- Timestamp:
- Sep 20, 2012 1:22:02 PM (12 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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- bda809e
- Parents:
- b71a53b
- Location:
- sansguiframe/src/sans/guiframe
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/CategoryInstaller.py
rdf7a7e3 rea5fa58 6 6 7 7 @author kieranrcampbell@gmail.com 8 8 @modified by NIST/MD sanview team 9 9 """ 10 10 … … 14 14 from collections import defaultdict 15 15 16 user_file= 'serialized_cat.p'16 USER_FILE = 'serialized_cat.p' 17 17 18 18 class CategoryInstaller: … … 47 47 returns the dir where default_cat.p should be 48 48 """ 49 import sans.dataloader.readers 50 return sans.dataloader.readers.get_data_path() 49 from sans import sansview as sasview 50 app_path = os.path.dirname(sasview.__file__) 51 return app_path 51 52 52 53 @staticmethod … … 55 56 returns the users sansview config dir 56 57 """ 57 return os.path.join(os.path.expanduser("~"), 58 ".sansview") 58 return os.path.join(os.path.expanduser("~"), ".sasview") 59 59 60 60 @staticmethod … … 95 95 def get_user_file(): 96 96 """ 97 returns the user data file, eg .sa nsview/serialized_cat.p97 returns the user data file, eg .sasview/serialized_cat.p 98 98 """ 99 99 return os.path.join(CategoryInstaller._get_home_dir(), 100 user_file)100 USER_FILE) 101 101 102 102 @staticmethod … … 107 107 """ 108 108 return os.path.join(\ 109 CategoryInstaller._get_default_cat_p_dir, 110 "default_categories.p") 109 CategoryInstaller._get_default_cat_p_dir(), "default_categories.p") 111 110 112 111 @staticmethod … … 128 127 serialized_file = CategoryInstaller.get_user_file() 129 128 else: 130 serialized_file = os.path.join(homedir, user_file)129 serialized_file = os.path.join(homedir, USER_FILE) 131 130 132 131 if os.path.exists(serialized_file): -
sansguiframe/src/sans/guiframe/CategoryManager.py
rdf7a7e3 rea5fa58 16 16 import wx 17 17 import sys 18 import os 18 19 from wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixin 19 20 from collections import defaultdict … … 290 291 cat_file = open(CategoryInstaller.get_user_file(), 'wb') 291 292 292 pickle.dump( self.master_category_dict, 293 cat_file ) 293 pickle.dump( self.master_category_dict, cat_file ) 294 294 295 295 … … 299 299 """ 300 300 try: 301 cat_file = open(CategoryInstaller.get_user_file(), 302 'rb') 303 self.master_category_dict = pickle.load(cat_file) 304 301 file = CategoryInstaller.get_user_file() 302 if os.path.isfile(file): 303 cat_file = open(file, 'rb') 304 self.master_category_dict = pickle.load(cat_file) 305 else: 306 cat_file = open(CategoryInstaller.get_default_file(), 'rb') 307 self.master_category_dict = pickle.load(cat_file) 305 308 except IOError: 306 309 print 'Problem reading in category file. Please review' … … 421 424 vbox.Add(self.ok_button, flag = wx.ALL | wx.ALIGN_RIGHT, 422 425 border = 10) 423 424 425 self.current_categories.SetSelection(0)426 427 if self.current_categories.GetCount() > 0: 428 self.current_categories.SetSelection(0) 426 429 self.new_text.Disable() 427 430 self.SetSizer(vbox) … … 494 497 return ret 495 498 496 497 498 499 500 499 if __name__ == '__main__': 501 500 … … 510 509 app.MainLoop() 511 510 512 -
sansguiframe/src/sans/guiframe/__init__.py
rdf7a7e3 rea5fa58 70 70 for f in findall(path): 71 71 data_files.append(('media/guiframe_media', [f])) 72 path = get_media_path(media="catdata")73 for f in findall(path):74 data_files.append(('.', [f]))75 72 76 73 return data_files -
sansguiframe/src/sans/guiframe/customdir.py
r94d6752 rea5fa58 3 3 import os.path 4 4 import shutil 5 from sans.guiframe.CategoryInstaller import CategoryInstaller 5 6 6 7 CONF_DIR = 'config' 7 8 APPLICATION_NAME = 'sasview' 9 10 def _find_usersasview_dir(): 11 """ 12 Find and return user/.sasview dir 13 """ 14 dir = os.path.join(os.path.expanduser("~"), 15 ("." + APPLICATION_NAME)) 16 return dir 8 17 9 18 def _find_customconf_dir(): … … 12 21 The plugin directory is located in the user's home directory. 13 22 """ 14 dir = os.path.join(os.path.expanduser("~"),15 ("." + APPLICATION_NAME), CONF_DIR)23 u_dir = _find_usersasview_dir() 24 dir = os.path.join(u_dir, CONF_DIR) 16 25 17 26 return dir … … 19 28 def _setup_conf_dir(path): 20 29 """ 21 Setup the custom config dir 30 Setup the custom config dir and cat file 22 31 """ 23 32 dir = _find_customconf_dir() … … 26 35 os.makedirs(dir) 27 36 file = os.path.join(dir, "custom_config.py") 37 u_dir = _find_usersasview_dir() 38 cat_file = os.path.join(u_dir, "serialized_cat.p") 39 # Place example user models as needed 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." 49 28 50 # Place example user models as needed 29 51 try:
Note: See TracChangeset
for help on using the changeset viewer.