Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions code/reposadolib/reposadocommon.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,33 @@
import warnings
from xml.parsers.expat import ExpatError

def get_main_dir():
def get_main_dir(follow_symlinks=False):
'''Returns the directory name of the script or the directory name of the exe if py2exe was used
Code from http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe
'''
if (hasattr(sys, "frozen") or hasattr(sys, "importers") or imp.is_frozen("__main__")):
return os.path.dirname(sys.executable)
return os.path.dirname(sys.argv[0])
path = ''
if (follow_symlinks):
path = os.path.dirname(os.path.realpath(sys.argv[0]))
else:
path = os.path.dirname(sys.argv[0])
return path

def prefsFilePath():
'''Returns path to our preferences file.'''
return os.path.join(get_main_dir(), 'preferences.plist')
prefsFile = ''
try:
with open(os.path.join(get_main_dir(), 'preferences.plist')) as f: pass
prefsFile = os.path.join(get_main_dir(), 'preferences.plist')
except IOError as e:
try:
with open(os.path.join(os.path.realpath(get_main_dir(True)), 'preferences.plist')) as f: pass
prefsFile = os.path.join(os.path.realpath(get_main_dir(True)), 'preferences.plist')
except IOError as e:
pass
return prefsFile



def pref(prefname):
Expand Down