dropbox.py 文件源码

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

项目:dotfiles 作者: nfischer 项目源码 文件源码
def start_dropbox():
    db_path = os.path.expanduser(u"~/.dropbox-dist/dropboxd").encode(sys.getfilesystemencoding())
    if os.access(db_path, os.X_OK):
        f = open("/dev/null", "w")
        # we don't reap the child because we're gonna die anyway, let init do it
        a = subprocess.Popen([db_path], preexec_fn=os.setsid, cwd=os.path.expanduser("~"),
                             stderr=sys.stderr, stdout=f, close_fds=True)

        # in seconds
        interval = 0.5
        wait_for = 60
        for i in xrange(int(wait_for / interval)):
            if is_dropbox_running():
                return True
            # back off from connect for a while
            time.sleep(interval)

        return False
    else:
        return False

# Extracted and modified from os.cmd.Cmd
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号