'Figure out what kind of state the codeintel database is in'

def do_database_info(self, request, driver):

    try:
        if (not os.path.exists(os.path.join(driver.mgr.db.base_dir, 'VERSION'))):
            log.debug('Database    does    not    exist')
            driver.send(state='preload-needed')
            return
        if (not os.path.isdir(os.path.join(driver.mgr.db.base_dir, 'db', 'stdlibs'))):
            log.debug('Database    does    not    have    stdlibs')
            driver.send(state='preload-needed')
            return
        driver.mgr.db.check()
        (state, details) = driver.mgr.db.upgrade_info()
        if (state == Database.UPGRADE_NOT_NECESSARY):
            std_libs = driver.mgr.db.get_stdlibs_zone()
            std_lib_langs = set()
            for lang in self._get_stdlib_langs(driver):
                for (ver, name) in std_libs.vers_and_names_from_lang(lang):
                    lib_path = os.path.join(std_libs.base_dir, name)
                    if os.path.exists(lib_path):
                        break
                else:
                    log.debug('no    stdlib    found    for    %s', lang)
                    driver.send(state='preload-needed')
                    break
            else:
                driver.send(state='ready')
        elif (state == Database.UPGRADE_NECESSARY):
            driver.send(state='upgrade-needed')
        elif (state == Database.UPGRADE_NOT_POSSIBLE):
            driver.send(state='upgrade-blocked', **{'state-detail': details})
    except Exception:
        log.exception('Error    looking    up    database    info')
        driver.send(state='broken', state_detail='Unexpected    error    getting    DB    upgrade    info')
