gnome.py 文件源码

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

项目:start_jupyter_cm 作者: hyperspy 项目源码 文件源码
def add_jupyter_here():
    if not os.path.exists(NPATH):
        print("Nothing done. Currently only Gnome with Nautilus as file ",
              "manager is supported.")
        return
    if not os.path.exists(SPATH):
        os.makedirs(SPATH)

    logo_path = os.path.expandvars(os.path.join(
        os.path.dirname(__file__), 'icons'))
    logos = {'qtconsole': os.path.join(logo_path, 'jupyter-qtconsole.png'),
             'notebook': os.path.join(logo_path, 'jupyter.png')}
    for terminal in ["qtconsole", "notebook"]:
        script_path = os.path.join(SPATH, "Jupyter %s here" % terminal)
        if not os.path.exists(script_path):
            with open(script_path, "w") as f:
                f.write(script % (terminal, terminal))
            st = os.stat(script_path)
            os.chmod(script_path, st.st_mode | stat.S_IEXEC)
            call(['gio', 'set', '-t', 'string', '%s' % script_path,
                  'metadata::custom-icon', 'file://%s' % logos[terminal]])
            print('Jupyter %s here created.' % terminal)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号