Source
__ld_library_path__ = (lambda fd: fd.readline().strip('\n').split(':'))(_os.popen(_rootdir + "/casapyinfo --exec 'echo $LD_LIBRARY_PATH'"))
import os as _os
import re as _re
import sys as _sys
#import time
from casac import casac as _casac
_homedir = _os.getenv('HOME')
if _homedir == None :
print "Environment variable HOME is not set, please set it"
_sys.exit(1)
#import casadef
##
## first set up CASAPATH
##
if _os.environ.has_key('CASAPATH') :
__casapath__ = _os.environ['CASAPATH'].split(' ')[0]
if not _os.path.exists(__casapath__ + "/data") :
raise RuntimeError, "CASAPATH environment variable is improperly set"
else :
__casapath__ = _casac.__file__
while __casapath__ and __casapath__ != "/" :
if _os.path.exists( __casapath__ + "/data") :
break
__casapath__ = _os.path.dirname(__casapath__)
if __casapath__ and __casapath__ != "/" :
_os.environ['CASAPATH']=__casapath__ + " linux local host"
else :
raise RuntimeError, "CASAPATH environment variable must be set"
#import __casac__
#cu = __casac__.utils.utils()
#xcu = __casac__.utils.utils
# this dict should transition to namespace (as with argparser)
# --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
#from casa_system import casa as config
#casa = { 'build': {
# 'time': casadef.build_time,
# 'version': cu.version_info( ),
# 'number': casadef.subversion_revision
# },
# 'source': {
# 'url': casadef.subversion_url,
# 'revision': casadef.subversion_revision
# },
# 'helpers': {
# 'logger': 'casalogger',
# 'viewer': 'casaviewer',
# 'info': None,
# 'dbus': None,
# 'ipcontroller': None,
# 'ipengine': None
# },
# 'dirs': {
# 'rc': _homedir + '/.casa',
# 'data': __casapath__ + "/data",
# 'recipes': __casapath__ + "/lib/python2.7/recipes",
# 'root': __casapath__,
# 'python': __casapath__ + "/lib/python2.7",
# 'pipeline': None,
# 'xml': __casapath__ + "/xml"
# },
# 'flags': { },
# 'files': {
# 'logfile': _os.getcwd( ) + '/casa-'+time.strftime("%Y%m%d-%H%M%S", time.gmtime())+'.log'
# },
# 'state' : {
# 'startup': True,
# 'unwritable': set( )
# }
# }
##
## next adjust the PYTHONPATH
##
def _adapt_pythonpath(searchroot):
# tarball location
guess = _os.path.join(searchroot, 'lib/python2.7/site-packages/numpy')
if _os.path.isdir(guess):
_sys.path.append(_os.path.dirname(guess))
else:
for root, dirs, files in _os.walk(searchroot):
# skip data folder which might be a network mount
if root == searchroot and 'data' in dirs:
del dirs[dirs.index('data')]
if root.endswith("/numpy"):
_sys.path.append(_os.path.dirname(root))
break