Changeset 64beda4 in sasview


Ignore:
Timestamp:
Jan 29, 2014 12:18:29 PM (11 years ago)
Author:
Peter Parker
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:
d2564a5
Parents:
e090c624
Message:

Correctly find the default categories file on py2exe-deployed versions of SasView?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sans/guiframe/CategoryInstaller.py

    r16bd5ca r64beda4  
    4949        returns the dir where default_cat.p should be 
    5050        """ 
    51         # The default categories file is usually found with the code 
     51        # The default categories file is usually found with the code, except 
     52        # when deploying using py2app (it will be in Contents/Resources), or 
     53        # py2exe (it will be in the exec dir). 
    5254        import sans.sansview 
    5355        cat_file = "default_categories.p" 
    54         dir, file_name = os.path.split(sans.sansview.__file__) 
    55         cat_file_path = os.path.join(dir, cat_file) 
    56         if os.path.isfile(cat_file_path): 
    57             cat_file_dir = os.path.dirname(cat_file_path) 
    58             return cat_file_dir 
    5956         
    60         # When deploying using py2app, the default categories file 
    61         # can be found in Contents/Resources 
    62         cat_file_path = os.path.join(os.path.dirname(sys.executable), '..', 'Resources', 'default_categories.p') 
    63         if os.path.isfile(cat_file_path): 
    64             cat_file_dir = os.path.dirname(cat_file_path) 
    65             return cat_file_dir 
    66          
     57        possible_cat_file_paths = [ 
     58            os.path.join(os.path.split(sans.sansview.__file__)[0], cat_file),           # Source 
     59            os.path.join(os.path.dirname(sys.executable), '..', 'Resources', cat_file), # Mac 
     60            os.path.join(os.path.dirname(sys.executable), cat_file)                     # Windows 
     61        ] 
     62 
     63        for path in possible_cat_file_paths: 
     64            if os.path.isfile(path): 
     65                return os.path.dirname(path) 
     66             
    6767        raise RuntimeError('CategoryInstaller: Could not find folder containing default categories') 
    6868 
Note: See TracChangeset for help on using the changeset viewer.