from IPython.terminal.prompts import Prompts, Token
print "failed to load casa:\n", e
print "failed to load matplotlib:\n", e
print "sys.path =", "\n\t".join(sys.path)
from casa_system import casa
if not os.environ.has_key('OMP_NUM_THREADS'):
os.environ['OMP_NUM_THREADS'] = str(max(1,multiprocessing.cpu_count()-2))
def in_prompt_tokens(self, cli=None):
return [(Token.Prompt, 'CASA <'),
(Token.PromptNum, str(self.shell.execution_count)),
_ip.prompts = _Prompt(_ip)
def true_false_handler(self, etype, value, tb, tb_offset=None):
if type(etype) is type(NameError):
if str(value) == "name 'T' is not defined" or \
str(value) == "name 'F' is not defined" or \
str(value) == "name 'true' is not defined" or \
str(value) == "name 'false' is not defined" :
print "------------------------------------------------------------------------------"
print "Warning: CASA no longer defines T/true and F/false as synonyms for True/False"
print "------------------------------------------------------------------------------"
self.execution_count += 1
self.showtraceback((etype, value, tb), tb_offset=tb_offset)
_ip.set_custom_exc((BaseException,), true_false_handler)
if os.environ.has_key('CASAPATH') :
__casapath__ = os.environ['CASAPATH'].split(' ')[0]
__casaarch__ = os.environ['CASAPATH'].split(' ')[1]
if not os.path.exists(__casapath__ + "/data") :
print "DEBUG: CASAPATH = %s" % (__casapath__)
print "Unable to find the data repository directory in your CASAPATH. Please fix."
casa['dirs']['root'] = __casapath__
casa['dirs']['data'] = __casapath__ + "/data"
if os.path.exists(__casapath__ + "/lib/python2.7/start_casa.py"):
casa['dirs']['python'] = __casapath__ + "/lib/python2.7"
elif os.path.exists(__casapath__ + "/Resources/python/start_casa.py"):
casa['dirs']['python'] = __casapath__ + "/Resources/python"
elif os.path.exists(__casapath__ + "/" + __casaarch__ + "/lib/python2.7/start_casa.py"):
casa['dirs']['python'] = __casapath__ + "/" + __casaarch__ + "/lib/python2.7"
if casa['dirs']['python'] is not None:
casa['dirs']['recipes'] = casa['dirs']['python'] + "/recipes"
if os.path.exists(__casapath__ + "/" + __casaarch__ + "/xml"):