casapy.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:jupyter-casa 作者: aardk 项目源码 文件源码
def casalogger(logfile=''):
    """
    Spawn a new casalogger using logfile as the filename.
    You should only call this if the casalogger dies or you close it
    and restart it again.

    Note: if you changed the name of the log file using casalog.setlogfile
    you will need to respawn casalogger with the new log filename. Eventually,
    we will figure out how to signal the casalogger with the new name but not
    for a while.
    """

    if logfile == '':
        if casa.has_key('files') and casa['files'].has_key('logfile') :
            logfile = casa['files']['logfile']
        else:
            casa['files']['logfile'] = os.getcwd( ) + '/casa.log'
            logfile = 'casa.log'

    pid=9999
    if (os.uname()[0]=='Darwin'):
        if casa['helpers']['logger'] == 'console':
           os.system("open -a console " + logfile)
        else:
           # XCode7 writes debug messages to stderr, which then end up in the
           # Casa console. Hence the stderr is directed to devnull
           #pid=os.spawnvp(os.P_NOWAIT,casa['helpers']['logger'],[casa['helpers']['logger'], logfile])
           DEVNULL = open(os.devnull, 'w')
           pid = Popen([casa['helpers']['logger'],logfile], stderr=DEVNULL).pid
           #pid = Popen([casa['helpers']['logger'],logfile], stdin=PIPE, stdout=FNULL, stderr=STDOUT).pid

    elif (os.uname()[0]=='Linux'):
        pid=os.spawnlp(os.P_NOWAIT,casa['helpers']['logger'],casa['helpers']['logger'],logfile)
    else:
        print 'Unrecognized OS: No logger available'

    if (pid!=9999): logpid.append(pid)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号