Ignore:
Timestamp:
07/29/10 19:13:46 (14 years ago)
Author:
Kana Sugimoto
Message:

New Development: Yes

JIRA Issue: No (test merging alma branch)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s):

Description:


Location:
branches/mergetest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/mergetest

  • branches/mergetest/python/__init__.py

    r1739 r1779  
    99    from asap.compatibility import wraps as wraps_dec
    1010
    11 # Set up AIPSPATH and first time use of asap i.e. ~/.asap/*
     11# Set up CASAPATH and first time use of asap i.e. ~/.asap/*
    1212plf = None
    1313if sys.platform == "linux2":
     
    2626    if os.path.exists(os.environ["ASAPDATA"]):
    2727        asapdata = os.environ["ASAPDATA"]
    28 # use AIPSPATH if defined and "data" dir present
    29 if not os.environ.has_key("AIPSPATH") or \
    30         not os.path.exists(os.environ["AIPSPATH"].split()[0]+"/data"):
    31     os.environ["AIPSPATH"] = "%s %s somwhere" % ( asapdata, plf)
     28# use CASAPATH if defined and "data" dir present
     29if not os.environ.has_key("CASAPATH") or \
     30        not os.path.exists(os.environ["CASAPATH"].split()[0]+"/data"):
     31    os.environ["CASAPATH"] = "%s %s somwhere" % ( asapdata, plf)
    3232# set up user space
    3333userdir = os.environ["HOME"]+"/.asap"
     
    3535    print 'First time ASAP use. Setting up ~/.asap'
    3636    os.mkdir(userdir)
    37     shutil.copyfile(asapdata+"/data/ipythonrc-asap", userdir+"/ipythonrc-asap")
    38     shutil.copyfile(asapdata+"/data/ipy_user_conf.py",
    39                     userdir+"/ipy_user_conf.py")
     37    #shutil.copyfile(asapdata+"/data/ipythonrc-asap", userdir+"/ipythonrc-asap")
     38    # commented out by TT on 2009.06.23 for casapy use
     39    ##shutil.copyfile(asapdata+"/data/ipy_user_conf.py",
     40    ##                userdir+"/ipy_user_conf.py")
    4041    f = file(userdir+"/asapuserfuncs.py", "w")
    4142    f.close()
    4243    f = file(userdir+"/ipythonrc", "w")
    4344    f.close()
    44 else:
     45# commented out by TT on 2009.06.23 for casapy use
     46##else:
    4547    # upgrade to support later ipython versions
    46     if not os.path.exists(userdir+"/ipy_user_conf.py"):
    47         shutil.copyfile(asapdata+"/data/ipy_user_conf.py",
    48                         userdir+"/ipy_user_conf.py")
     48    ##if not os.path.exists(userdir+"/ipy_user_conf.py"):
     49    ##    shutil.copyfile(asapdata+"/data/ipy_user_conf.py",
     50    ##                    userdir+"/ipy_user_conf.py")
    4951
    5052# remove from namespace
     
    110112    'plotter.histogram'  : [False, _validate_bool],
    111113    'plotter.papertype'  : ['A4', str],
    112     'plotter.axesformatting' : ['mpl', str],
     114    ## for older Matplotlib version
     115    #'plotter.axesformatting' : ['mpl', str],
     116    'plotter.axesformatting' : ['asap', str],
    113117
    114118    # scantable
     
    218222        tup = line.split(':',1)
    219223        if len(tup) !=2:
    220             print ('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname))
     224            #print ('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname))
     225            asaplog.push('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname))
     226            print_log('WARN')
    221227            continue
    222228
     
    224230        key = key.strip()
    225231        if not defaultParams.has_key(key):
    226             print ('Bad key "%s" on line %d in %s' % (key, cnt, fname))
     232            #print ('Bad key "%s" on line %d in %s' % (key, cnt, fname))
     233            asaplog.push('Bad key "%s" on line %d in %s' % (key, cnt, fname))
     234            print_log('WARN')
    227235            continue
    228236
     
    234242        try: cval = converter(val)   # try to convert to proper type or raise
    235243        except ValueError, msg:
    236             print ('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, msg))
     244            #print ('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, msg))
     245            asaplog.push('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, str(msg)))
     246            print_log('WARN')
    237247            continue
    238248        else:
     
    366376    return wrap_it
    367377
    368 def print_log():
    369     log = asaplog.pop().strip()
    370     if len(log) and rcParams['verbose']: print log
     378def print_log(level='INFO'):
     379    from taskinit import casalog
     380    log = asaplog.pop()
     381    #if len(log) and rcParams['verbose']: print log
     382    if len(log) and rcParams['verbose']: casalog.post( log, priority=level )
    371383    return
    372384
     
    391403from simplelinefinder import simplelinefinder
    392404from linecatalog import linecatalog
     405from interactivemask import interactivemask
    393406from opacity import skydip
    394407from opacity import model as opacity_model
     
    400413        if gui:
    401414            import matplotlib
    402             matplotlib.use("TkAgg")
     415            if not matplotlib.sys.modules['matplotlib.backends']: matplotlib.use("TkAgg")
    403416        from matplotlib import pylab
    404417        xyplotter = pylab
     
    406419        del gui
    407420    except ImportError:
    408         print "Matplotlib not installed. No plotting available"
     421        #print "Matplotlib not installed. No plotting available"
     422        asaplog.post( "Matplotlib not installed. No plotting available")
     423        print_log('WARN')
    409424
    410425__date__ = '$Date$'.split()[1]
    411 __version__  = '$Revision$'
     426__version__  = '3.0.0 alma'
     427# nrao casapy specific, get revision number
     428#__revision__ = ' unknown '
     429casapath=os.environ["CASAPATH"].split()
     430#svninfo.txt path
     431if os.path.isdir(casapath[0]+'/'+casapath[1]+'/python/2.5/asap'):
     432    # for casa developer environment (linux or darwin)
     433    revinfo=casapath[0]+'/'+casapath[1]+'/python/2.5/asap/svninfo.txt'
     434else:
     435    # for end-user environments
     436    if casapath[1]=='darwin':
     437        revinfo=casapath[0]+'/Resources/python/asap/svninfo.txt'
     438    else:
     439        revinfo=casapath[0]+'/lib/python2.5/asap/svninfo.txt'
     440if os.path.isfile(revinfo):
     441    f = file(revinfo)
     442    f.readline()
     443    revsionno=f.readline()
     444    f.close()
     445    del f
     446    __revision__ = revsionno.rstrip()
     447else:
     448    __revision__ = ' unknown '
    412449
    413450def is_ipython():
    414451    return 'IPython' in sys.modules.keys()
    415 
    416452if is_ipython():
    417453    def version(): print  "ASAP %s(%s)"% (__version__, __date__)
Note: See TracChangeset for help on using the changeset viewer.