Esempio n. 1
0
    def listen_channel(self, login):
        self.emit('message', 'Listened...')
        client = redis.StrictRedis()
        pubsub = client.pubsub()
        pubsub.subscribe('global:%s' % login)
        for msg in pubsub.listen():
            if msg['type'] == 'message':
                import json
                commanddata = json.loads(msg['data'])
                if commanddata['type'] == 'UPSTREAMFINISHED':
                    from bakery.app import app
                    from bakery.project.models import Project
                    from flask import g
                    _ = '{% from "macros/dashboard.html" import project_actions %}{{ project_actions(repo) }}'

                    ctx = app.test_request_context('/')
                    ctx.push()

                    tml = app.jinja_env.from_string(_)
                    p = Project.query.filter_by(id=commanddata['project_id']).first()
                    g.user = p.login
                    r = tml.render({'repo': p})

                    commanddata.update({'html': r})
                    self.emit('message', json.dumps(commanddata))
                else:
                    self.emit('message', msg['data'])
Esempio n. 2
0
#
# See AUTHORS.txt for the list of Authors and LICENSE.txt for the License.

from __future__ import print_function

import os
import sys
import requests
from bs4 import BeautifulSoup

sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))

from bakery.app import db, app
from bakery.models import FontStats

ctx = app.test_request_context("/")
ctx.push()

r = requests.get("http://www.google.com/fonts/stats?key=WebFonts2010")

if r.status_code != 200:
    print("Wrong download code", file=sys.stderr)
    sys.exit(1)

soup = BeautifulSoup(r.text)

c = soup.find("div", "container")

for i in c.find_all("div", "row")[1:]:
    family, total, month, week, yesterday, rate = [k.text for k in i.find_all("div", "column")]
Esempio n. 3
0
# coding: utf-8
# Copyright 2013 The Font Bakery Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# See AUTHORS.txt for the list of Authors and LICENSE.txt for the License.
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))

from bakery.app import db, app, register_blueprints
register_blueprints(app)

ctx = app.test_request_context('/')
ctx.push()
print(db)
db.drop_all()
db.create_all()
ctx.pop()
Esempio n. 4
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# See AUTHORS.txt for the list of Authors and LICENSE.txt for the License.

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))

from bakery.app import app, db

ctx = app.test_request_context('/')
ctx.push()

from bakery.models import User

user = User.get_or_init(login='******')
user.name = 'Offline User'
user.email = '*****@*****.**'
user.github_access_token = 'fake'

db.session.add(user)
db.session.commit()

ctx.pop()