コード例 #1
0
ファイル: tasks.py プロジェクト: roozbehp/fontbakery
def refresh_repositories(username, token):
    from bakery.app import github
    from bakery.github import GithubSessionAPI, GithubSessionException
    from bakery.settings.models import ProjectCache
    _github = GithubSessionAPI(github, token)
    try:
        repos = _github.get_repo_list()
        ProjectCache.refresh_repos(repos, username)
    except GithubSessionException, ex:
        print(ex.message)
コード例 #2
0
ファイル: views.py プロジェクト: roozbehp/fontbakery
def update():
    """Update the list of the user's github repos"""
    if g.user is not None:
        if g.user.login != u'offline':
            _github = GithubSessionAPI(github, g.user.token)
            try:
                _repos = _github.get_repo_list()
                ProjectCache.refresh_repos(_repos, g.user.login)
                if _repos:
                    flash(_('Repositories refreshed.'))
            except GithubSessionException, ex:
                flash(ex.message)
        else:
            flash(_('Offline user has no Github account.'))
コード例 #3
0
ファイル: views.py プロジェクト: roozbehp/fontbakery
def repos():
    # pylint:disable-msg=E1101
    cache = ProjectCache.get_user_cache(g.user.login)
    myprojects = Project.query.filter_by(
        login=g.user.login, is_github=True).all()
    mygit = Project.query.filter_by(login=g.user.login, is_github=False).all()

    p = {}
    if myprojects:
        for i in myprojects:
            p[i.full_name] = i
    # import ipdb; ipdb.set_trace()
    return render_template('settings/index.html',
                           cache=cache, projects=p, gitprojects=mygit)
コード例 #4
0
ファイル: views.py プロジェクト: pathumego/fontbakery
def splash():
    # Splash page, if user is logged in then show dashboard
    if g.user is None:
        return render_template('splash.html')
    else:
        projects = Project.query.filter_by(login=g.user.login).all()
        cache = ProjectCache.get_user_cache(g.user.login)
        if cache:
            import json
            _func = lambda x: {"url": x['git_url'], "name": x['full_name']}
            cache = json.dumps(map(_func, cache.data))
        else:
            cache = []
        return render_template('dashboard.html', repos=projects, cache=cache)
コード例 #5
0
ファイル: views.py プロジェクト: roozbehp/fontbakery
def splash():
    # Splash page, if user is logged in then show dashboard
    if g.user is None:
        return render_template("splash.html")
    else:
        projects = Project.query.order_by(Project.id.desc())
        cache = ProjectCache.get_user_cache(g.user.login)
        if cache:
            import json

            _func = lambda x: {"url": x["git_url"], "name": x["full_name"]}
            cache = json.dumps(unique(map(_func, cache.data), "name"))
        else:
            cache = []

        datadir_sizes = get_directory_sizes(app.config["DATA_ROOT"])
        datadir_sizes = [{"key": item[0], "value": item[1]} for item in datadir_sizes]
        return render_template("dashboard.html", repos=projects, cache=cache, datadir_sizes=datadir_sizes)