- Timestamp:
- Jun 28, 2016 7:10:33 PM (9 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 74d9780
- Parents:
- 80c2c85
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/__init__.py
refe730d r3aa2f3c 1 import sys 1 2 import os 3 from os.path import exists, expanduser, dirname, realpath, join as joinpath 4 5 def dirn(path, n): 6 path = realpath(path) 7 for _ in range(n): 8 path = dirname(path) 9 return path 2 10 3 11 # Set up config directories 4 12 def make_user_folder(): 5 path = os.path.join(os.path.expanduser("~"),'.sasview')6 if not os.path.exists(path):13 path = joinpath(expanduser("~"),'.sasview') 14 if not exists(path): 7 15 os.mkdir(path) 8 16 return path 9 17 18 10 19 def find_app_folder(): 11 # If the directory containing sasview.py exists, then we are not running 12 # frozen and the current path is the app path. 13 root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 14 path = os.path.join(root, 'sasview') 15 if os.path.exists(path): 20 # We are starting out with the following info: 21 # __file__ = .../sas/sasgui/__init__.pyc 22 # Check if the sister path .../sas/sasview exists, and use it as the 23 # app directory. This will only be the case if the app is not frozen. 24 path = joinpath(dirn(__file__, 2), 'sasview') 25 if exists(path): 16 26 return path 17 27 18 # If we are running frozen, then skip from: 19 # library.zip/sas/sasview 20 path = os.path.dirname(os.path.dirname(root)) 28 # If we are running frozen, then root is a parent directory 29 if sys.platform == 'darwin': 30 # Here is the path to the file on the mac: 31 # .../Sasview.app/Contents/Resources/lib/python2.7/site-packages.zip/sas/sasgui/__init__.pyc 32 # We want the path to the Resources directory. 33 path = dirn(__file__, 6) 34 elif os.name == 'nt': 35 # Here is the path to the file on windows: 36 # ../Sasview/library.zip/sas/sasgui/__init__.pyc 37 # We want the path to the Sasview directory. 38 path = dirn(__file__, 4) 39 else: 40 raise RuntimeError("Couldn't find the app directory") 21 41 return path 22 42
Note: See TracChangeset
for help on using the changeset viewer.