Changeset 1080


Ignore:
Timestamp:
07/25/06 09:34:03 (18 years ago)
Author:
mar637
Message:

move all the environment set-up into python asap module. only detect ipython and run with profile in shell script

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/asap

    r731 r1080  
    3434echo "Loading ASAP..."
    3535
    36 prefix='/usr/local'
     36ip="`which ipython`"
     37p="`which python`"
    3738
    38 # check if user set
    39 if [ "x${ASAPDATA}" == "x" ]; then
    40     ASAPDATA="${prefix}/share/asap"
    41     export ASAPDATA
    42 fi
    43 
    44 if [ ! -d "${ASAPDATA}" ]; then
    45     echo "Couldn't locate the asap data directory"
    46     echo "Please set ASAPDATA"
    47     #ASAPDATA="/nfs/aips++"
    48     #export ASAPDATA
    49     #exit 1
    50 fi
    51 
    52 # Keep casa measures happy
    53 if test -d "${ASAPDATA}/data" ; then
    54     platform='linux_gnu'
    55     if [ `uname -s` == 'Darwin' ]; then
    56         platform='darwin'
    57     fi
    58     AIPSPATH="${ASAPDATA} ${platform} somewhere localhost"
    59     export AIPSPATH
    60 else
    61     echo "Couldn't find the ASAP data directory"
    62     exit 1
    63 fi
    64 
    65 # started for the first time
    66 ASAPUSERDIR="${HOME}/.asap"; export ASAPUSERDIR
    67 if [ ! -d ${ASAPUSERDIR} ]; then
    68     echo 'First time ASAP use. Setting up ~/.asap'
    69     mkdir "${ASAPUSERDIR}"
    70     cp "${ASAPDATA}/ipythonrc-asap" "${ASAPUSERDIR}/"
    71     echo "#Dummy placeholder. All info is in ipythonrc-asap" > "${ASAPUSERDIR}/ipythonrc"
    72     touch "${ASAPUSERDIR}/asapuserfuncs.py"
    73 fi
    74 
    75 ip="`which ipython`"
    76 
     39# no ipython installation - run without all the goodies
    7740if [ ! -x "$ip" ]; then
    7841    echo "Can't find, or no execute permissions for 'ipython'"
    7942    echo "Running asap through 'python':"
    80     p="`which python`"
    8143    $p -c 'from asap import *'
    8244else
    83     $ip -ipythondir "${ASAPUSERDIR}" -p 'asap' $*
     45    # if run for the first time set-up ipythonrc profile and ~/.asap
     46    if [ ! -d "${HOME}/.asap" ]; then
     47        $p -c "import asap"
     48    fi
     49    # now execute ipython using the profile
     50    $ip -ipythondir "${HOME}/.asap" -p 'asap' $*
    8451fi
  • trunk/python/__init__.py

    r1076 r1080  
    33
    44"""
    5 import os,sys
     5import os,sys,shutil, platform
     6
     7# Set up AIPSPATH and first time use of asap i.e. ~/.asap/*
     8plf = None
     9if sys.platform == "linux2":
     10    if platform.architecture()[0] == '64bit':
     11        plf = 'linux_64b'
     12    else:
     13        plf = 'linux_gnu'
     14elif sys.platform == 'darwin':
     15    plf = 'darwin'
     16else:
     17    # Shouldn't happen - default to linux
     18    plf = 'linux'
     19asapdata = __path__[-1]
     20os.environ["AIPSPATH"] = "%s %s somwhere" % ( asapdata, plf)
     21userdir = os.environ["HOME"]+"/.asap"
     22if not os.path.exists(userdir):
     23    print 'First time ASAP use. Setting up ~/.asap'
     24    os.mkdir(userdir)
     25    shutil.copyfile(asapdata+"/data/ipythonrc-asap", userdir+"/ipythonrc-asap")
     26    f = file(userdir+"/asapuserfuncs.py", "w")
     27    f.close()
     28    f = file(userdir+"/ipythonrc", "w")
     29    f.close()
     30del asapdata, userdir, shutil, platform
    631
    732def _validate_bool(b):
     
    165190        val = val.strip()
    166191        try: cval = converter(val)   # try to convert to proper type or raise
    167         except Exception, msg:
     192        except ValueError, msg:
    168193            print ('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, msg))
    169194            continue
     
    295320
    296321from asapmath import *
    297 from scantable import *
     322from scantable import scantable
    298323from asaplinefind import *
    299324#from asapfit import *
Note: See TracChangeset for help on using the changeset viewer.