import os
import signal
import crashrpt_conf
casa['state']['crash-reporter'] = False
if ( casa['flags'].crash_report or (
os.environ.has_key('CASA_USE_CRASH_REPORTER') and
os.environ['CASA_USE_CRASH_REPORTER'].upper( ) == 'TRUE')):
try:
systemTempDir = crashrpt_conf.systemTempDir
temporaryDirectoryCommon = crashrpt_conf.temporaryDirectoryCommon
temporaryDirectory = crashrpt_conf.temporaryDirectory
if not os.path.exists(temporaryDirectoryCommon):
os.makedirs(temporaryDirectoryCommon)
st = os.stat(systemTempDir)
perm = st.st_mode
os.chmod(temporaryDirectoryCommon, perm)
if not os.path.exists(temporaryDirectory):
os.makedirs(temporaryDirectory)
posterApp = casa['helpers']['crashPoster']
if posterApp is None: posterApp = ""
postingUrl = "https://casa.nrao.edu/cgi-bin/crash-report.pl"
if os.environ.has_key('CASA_CRASHREPORT_URL') :
postingUrl = os.environ['CASA_CRASHREPORT_URL']
theLogFile = casa['files']['logfile']
message = casac.utils()._crash_reporter_initialize(temporaryDirectory, posterApp, postingUrl, theLogFile)
if len (message) > 0:
if message != "no-op":
print ("***\n*** Crash reporter failed to initialize: " + message)
else:
casa['state']['crash-reporter'] = True
except Exception as e:
print "***\n*** Crash reporter initialization failed.\n***"
print "*** exception={0}\n***".format (e)