Changeset 1779 for branches/mergetest/python/__init__.py
- Timestamp:
- 07/29/10 19:13:46 (14 years ago)
- Location:
- branches/mergetest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mergetest
- Property svn:mergeinfo changed
-
branches/mergetest/python/__init__.py
r1739 r1779 9 9 from asap.compatibility import wraps as wraps_dec 10 10 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/* 12 12 plf = None 13 13 if sys.platform == "linux2": … … 26 26 if os.path.exists(os.environ["ASAPDATA"]): 27 27 asapdata = os.environ["ASAPDATA"] 28 # use AIPSPATH if defined and "data" dir present29 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 29 if 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) 32 32 # set up user space 33 33 userdir = os.environ["HOME"]+"/.asap" … … 35 35 print 'First time ASAP use. Setting up ~/.asap' 36 36 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") 40 41 f = file(userdir+"/asapuserfuncs.py", "w") 41 42 f.close() 42 43 f = file(userdir+"/ipythonrc", "w") 43 44 f.close() 44 else: 45 # commented out by TT on 2009.06.23 for casapy use 46 ##else: 45 47 # 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") 49 51 50 52 # remove from namespace … … 110 112 'plotter.histogram' : [False, _validate_bool], 111 113 'plotter.papertype' : ['A4', str], 112 'plotter.axesformatting' : ['mpl', str], 114 ## for older Matplotlib version 115 #'plotter.axesformatting' : ['mpl', str], 116 'plotter.axesformatting' : ['asap', str], 113 117 114 118 # scantable … … 218 222 tup = line.split(':',1) 219 223 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') 221 227 continue 222 228 … … 224 230 key = key.strip() 225 231 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') 227 235 continue 228 236 … … 234 242 try: cval = converter(val) # try to convert to proper type or raise 235 243 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') 237 247 continue 238 248 else: … … 366 376 return wrap_it 367 377 368 def print_log(): 369 log = asaplog.pop().strip() 370 if len(log) and rcParams['verbose']: print log 378 def 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 ) 371 383 return 372 384 … … 391 403 from simplelinefinder import simplelinefinder 392 404 from linecatalog import linecatalog 405 from interactivemask import interactivemask 393 406 from opacity import skydip 394 407 from opacity import model as opacity_model … … 400 413 if gui: 401 414 import matplotlib 402 matplotlib.use("TkAgg")415 if not matplotlib.sys.modules['matplotlib.backends']: matplotlib.use("TkAgg") 403 416 from matplotlib import pylab 404 417 xyplotter = pylab … … 406 419 del gui 407 420 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') 409 424 410 425 __date__ = '$Date$'.split()[1] 411 __version__ = '$Revision$' 426 __version__ = '3.0.0 alma' 427 # nrao casapy specific, get revision number 428 #__revision__ = ' unknown ' 429 casapath=os.environ["CASAPATH"].split() 430 #svninfo.txt path 431 if 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' 434 else: 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' 440 if 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() 447 else: 448 __revision__ = ' unknown ' 412 449 413 450 def is_ipython(): 414 451 return 'IPython' in sys.modules.keys() 415 416 452 if is_ipython(): 417 453 def version(): print "ASAP %s(%s)"% (__version__, __date__)
Note:
See TracChangeset
for help on using the changeset viewer.