config.py 文件源码

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

项目:gcMapExplorer 作者: rjdkmr 项目源码 文件源码
def cleanScratch():
    """ Clean scratch directory.

    It checks whether any other gcMapExplorer process is running. In case,
    when only one process (i.e. current) is running, all files with "gcx"
    prefix will be deleted from default scratch directory.

    """
    config = getConfig()
    count = 0
    for pid in psutil.pids():
        p = None
        try:
            p = psutil.Process(pid)
        except psutil.NoSuchProcess:
            pass

        if p is not None:
            if 'gcMapExplorer' in p.name():
                count += 1

    # If only one gcMapExplorer is running, it is the current one
    if count == 1:
        for f in os.listdir(config['Dirs']['WorkingDirectory']):
            if not os.path.isfile(f):
                continue
            basename = os.path.basename(f)
            base = os.path.splitext(basename)[0]
            if "gcx" in base:
                try:
                    print(' Removing File: {0}'.format(f))
                    os.remove(f)
                except IOError:
                    pass

        print('     ... Finished Cleaning')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号