Example #1
0
    """
    if db_queries.get_user_id(data["user_email"]) is not None:
        db_queries.add_user_submitted_image(data["recipe_id"], [data["image"]])


@app.route("/")
def index():
    """
    to index.html
    """
    models.db.create_all()
    return flask.render_template("index.html")


@app.route("/about")
def user_page():
    """
    to about.html
    """
    return flask.render_template("about.html")


if __name__ == "__main__":
    db_utils.init_db(app)
    socketio.run(
        app,
        host=os.getenv("IP", "0.0.0.0"),
        port=int(os.getenv("PORT", 8080)),
        debug=True,
    )
Example #2
0
def _run_on_start():
    init_db(app)
Example #3
0
def create_new_db():
    db_path = gui_create_db()
    init_db(db_path)
    return db_path
Example #4
0
 def setUp(self):
     self.db_f, ff.app.config['DATABASE'] = tempfile.mkstemp()
     ff.app.testing = True
     self.app = ff.app.test_client()
     self.db = init_db(ff.app.config['DATABASE'])
Example #5
0
# limitations under the License.

from datetime import datetime
from db_utils import init_db
import sys
import time

if len(sys.argv) < 5:
    print 'You must specify 4 arguments:'
    print '1. The MySQL DB user name'
    print '2. The MySQL DB password'
    print '3. The start datetime in the format: %Y-%m-%d %H:%M:%S'
    print '4. The finish datetime in the format: %Y-%m-%d %H:%M:%S'
    sys.exit(1)

db = init_db('mysql://' + sys.argv[1] + ':' + sys.argv[2] +
             '@localhost/terracotta')
start_time = datetime.fromtimestamp(
    time.mktime(time.strptime(sys.argv[3], '%Y-%m-%d %H:%M:%S')))
finish_time = datetime.fromtimestamp(
    time.mktime(time.strptime(sys.argv[4], '%Y-%m-%d %H:%M:%S')))


def total_seconds(delta):
    return (delta.microseconds +
            (delta.seconds + delta.days * 24 * 3600) * 1000000) / 1000000


total_idle_time = 0
for hostname, host_id in db.select_host_ids().items():
    prev_timestamp = start_time
    prev_state = 1
Example #6
0
from flask import Flask
import os, json, atexit
from db_utils import init_db, add_user, close_db

app = Flask(__name__, static_url_path='')
port = int(os.getenv('PORT', 8000))

init_db()


@app.route('/user/add/<name>')
def user_add(name):
    data = {'name': name}
    result = add_user(data)
    return result


@atexit.register
def shutdown():
    close_db()


if __name__ == "__main__":
    app.run(host='0.0.0.0', port=port, debug=True)
Example #7
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.

from datetime import datetime
from db_utils import init_db
import sys
import time


if len(sys.argv) < 5:
    print 'You must specify 4 arguments:'
    print '1. The MySQL DB user name'
    print '2. The MySQL DB password'
    print '3. The start datetime in the format: %Y-%m-%d %H:%M:%S'
    print '4. The finish datetime in the format: %Y-%m-%d %H:%M:%S'
    sys.exit(1)

db = init_db(
    'mysql://' + sys.argv[1] + ':' + sys.argv[2] + '@localhost/spe')
start_time = datetime.fromtimestamp(
    time.mktime(time.strptime(sys.argv[3], '%Y-%m-%d %H:%M:%S')))
finish_time = datetime.fromtimestamp(
    time.mktime(time.strptime(sys.argv[4], '%Y-%m-%d %H:%M:%S')))

print "VM migrations: " + str(
    len(db.select_vm_migrations(start_time, finish_time)))
Example #8
0
 def create_app(self):
     app = Flask(__name__)
     app.config["TESTING"] = True
     app.config["SQLALCHEMY_DATABASE_URI"] = self.SQLALCHEMY_DATABASE_URI
     db_utils.init_db(app)
     return app
Example #9
0
#encoding=utf-8
import db_utils
import os
from utils import *
try:
    db_utils.init_db(db_utils.db_info_test)
except:
    print "db init error"
    exit(-1)

import tornado.web
import tornado.ioloop
import router
import tornado.autoreload
from views import *
import tornado.httpserver

settings = dict(
    template_path=os.path.join(os.path.dirname(__file__), "templates"),
    static_path=os.path.join(os.path.dirname(__file__), "static"),
    cookie_secret="!EAFQ@#$RDASDasdfasdf23412341#!@#!%#@$%",
    debug=True,
)
application = tornado.web.Application(router.route.get_routes(), **settings)

if __name__ == '__main__':
    # start tornado server
    load_config()
    server = tornado.httpserver.HTTPServer(application)
    server.listen(8888)
    instance = tornado.ioloop.IOLoop.instance()
from datetime import datetime
from db_utils import init_db
import sys
import time


if len(sys.argv) < 5:
    print 'You must specify 4 arguments:'
    print '1. The MySQL DB user name'
    print '2. The MySQL DB password'
    print '3. The start datetime in the format: %Y-%m-%d %H:%M:%S'
    print '4. The finish datetime in the format: %Y-%m-%d %H:%M:%S'
    sys.exit(1)

db = init_db(
    'mysql://' + sys.argv[1] + ':' + sys.argv[2] + '@localhost/terracotta')
start_time = datetime.fromtimestamp(
    time.mktime(time.strptime(sys.argv[3], '%Y-%m-%d %H:%M:%S')))
finish_time = datetime.fromtimestamp(
    time.mktime(time.strptime(sys.argv[4], '%Y-%m-%d %H:%M:%S')))


def total_seconds(delta):
    return (delta.microseconds +
            (delta.seconds + delta.days * 24 * 3600) * 1000000) / 1000000

total_idle_time = 0
for hostname, host_id in db.select_host_ids().items():
    prev_timestamp = start_time
    prev_state = 1
    states = {0: [], 1: []}