Beispiel #1
0
def main():
    domain_name = input("What is the name of subdomain?\n")

    if domain_name is None:
        print("Please specify the name")
        main()

    add_a_sub_domain(domain_name)
    add_a_sub_domain("www." + domain_name)

    app_name = input("What is the app name?\n")

    if app_name is None:
        return

    origin = input("Add git origin\n")

    if origin is None:
        return

    port = input("Which port should application run on\n")

    if port is None:
        return

    create_app(app_name, origin, port)
	def create_backup(self, keyspace):
		app = create_app()
		app.app_context().push()

		nodetool = Nodetool()
		output, error = nodetool.do_snapshot(keyspace)
		snapshot_num = str(output).split("Snapshot directory:")[1].replace(' ','').replace("'",'').replace("\\n",'')
		directory_cass = self.cfg['server']['cassandra_data'] + '/' + keyspace + '/'
		keyspacedir = os.listdir(directory_cass)
		backup = BackupModel(snapshot_num, 'running', False, 'undefined', keyspace) 
		backup.save_to_db()
		for table in keyspacedir:
			directory_cass_snap = directory_cass + table + '/snapshots/' + snapshot_num
			if (self.cfg['s3']['s3_enabled']):
				s3 = S3Backup()
				s3.uploadDirectory(directory_cass_snap, keyspace, snapshot_num, table)
				backup.location = 's3'
				backup.state = 'Finish'
				backup.completed = True

			if (self.cfg['local_backup']['lb_enabled']):
				local_backup = LocalBackup()
				local_backup.uploadDirectory(directory_cass_snap, self.cfg['local_backup']['path'], snapshot_num , keyspace, table)
				backup.location = self.cfg['local_backup']['path']
				backup.state = 'Finish'
				backup.completed = True

		backup.save_to_db()
Beispiel #3
0
def app():
    """
    Run for each test. init_db environment specified to prevent tests being run against
    Production database even if API_ENV in .env is set to PRODUCTION.
    """
    init_db("TESTING")
    yield create_app("TESTING")
Beispiel #4
0
def test_mocking_constant_a(monkeypatch):
    word = 'return_string2'
    monkeypatch.setattr(application, 'mock_here', lambda : word)
    app = create_app().test_client()
    response = app.post('/route')
    print(response)
    assert response.data.decode('utf-8') == word
Beispiel #5
0
def run_server():
    # print '执行到了这里...2'
    # if len(sys.argv) != 1 and sys.argv[1][:6] == '--port':
    #     port = sys.argv[1].rsplit('=')[1]
    print 'SERVE ON PORT %s' % 8000
    application = create_app()
    application.listen(8000)
    ioloop = tornado.ioloop.IOLoop.instance()
    ioloop.start()
    def setUp(self):
        """Define test variables and initialize app."""
        self.app = create_app("testing")
        self.client = self.app.test_client()
        self.app_context = self.app.app_context()

        with self.app_context:
            update = UpdateDb(xml_file_path='data/test_feed.xml')
            update.recreate_db()
Beispiel #7
0
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import sys
from flask import render_template, request, url_for, redirect
import config, create_app

app = create_app.create_app(app_config=config.DevelopmentConfig)
db = SQLAlchemy(app)


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)

    def __init__(self, username, email):
        self.username = username
        self.email = email

    def __repr__(self):
        return '<User %r>' % self.username


@app.route('/')
def index():
    myUser = User.query.all()
    return render_template('add_user.html', myUser=myUser)


@app.route('/post_user', methods=['POST'])
def post_user():
Beispiel #8
0
 def setUp(self):
     self.app = create_app(mode='TEST').test_client()
     self.db = db
 def create_app(self):
     app = create_app("flask_config.Testing")
     return app
Beispiel #10
0
import contextlib
import time
import rq
from redis import Redis
from create_app import create_app
import multiprocessing
from datetime import datetime

app = create_app(config_name='default')
app_obj = app.get('app')
Base = app.get('Base')
db_session = app.get('db_session')


def process_tasks():
    from models import StatusEnum, Task
    queue = rq.Queue('drweb-tasks', connection=Redis.from_url('redis://'))
    with app_obj.app_context():
        while True:
            job = queue.dequeue()
            if job:
                job.meta['status'] = StatusEnum.RUN
                job.meta['start_time'] = datetime.utcnow()
                job.meta['process_name'] = multiprocessing.current_process(
                ).name
                job.save_meta()
                Task.update_by_job(job)
                start_time = time.time()
                queue.run_job(job)
                job.meta['status'] = StatusEnum.COMPLETE
                job.meta['work_time'] = time.time() - start_time
Beispiel #11
0
from gevent import monkey
monkey.patch_all()

import logging

from create_app import create_app
"""
runs the flask app
"""
app = create_app('etc.settings')
logging.root.setLevel(logging.DEBUG)
logging.disable(0)
Beispiel #12
0
#!/usr/bin/env python3

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from create_app import create_app

__version__ = "0.1.0"
__author__ = "github.com/don-kanaille"

# Create & Initialize Flask app
app = create_app(mode='DEVELOP')

if __name__ == '__main__':
    app.run()
Beispiel #13
0
from flask import request, redirect, url_for
from create_app import create_app
from dotenv import load_dotenv

from controllers.auth import auth_api
from controllers.weather_info import weather_info_api
from controllers.sms import sms_api
from controllers.blog_api import blog_api

from providers.sms_provider import formulate_message, get_location

application = create_app()

load_dotenv()  # load env vars

application.register_blueprint(weather_info_api)

application.register_blueprint(auth_api)

application.register_blueprint(sms_api, url_prefix='/sms')

application.register_blueprint(weather_info_api)

application.register_blueprint(blog_api)


@application.route('/chat', methods=['POST'])
def reply_chat():
    req_data = request.get_json()
    # longitude,latitude = get_location(req_data['msg'])
    return {'msg': formulate_message(req_data['msg'])}
Beispiel #14
0
from flask import render_template, jsonify, request, redirect, url_for
from create_app import create_app
from models.category import Category
from models.vacancy import Vacancy

app = create_app('development')


@app.errorhandler(404)
def page_not_found(error):
    return redirect(url_for('search_page.index'))


if __name__ == "__main__":
    app.run(host='0.0.0.0')
Beispiel #15
0
from create_app import create_app, db

app = create_app()
app.app_context().push()
# db.create_all(app=create_app())

if __name__ == '__main__':

    app.run(host='0.0.0.0', port=8092, debug=True)
Beispiel #16
0
from create_app import create_app, socketio
import os

app = create_app(debug=True)
socketio.init_app(app)

if __name__ == '__main__':
    #port = int(os.environ.get("PORT", 5000))
    #app.run(host='0.0.0.0', port=port, debug=True)
    socketio.run(app)
Beispiel #17
0
from create_app import create_app

app = create_app()

if __name__ == "__main__":
    app.run(
        host=app.config["HOST"],
        port=app.config["PORT"],
        workers=app.config["WORKERS"],
        debug=(app.config["API_ENV"] != "PRODUCTION"),
    )
Beispiel #18
0
def init_app(app_config, get_db_container):
    with get_db_container as postgres:
        init_db(app_config.API_ENV)
        yield create_app(app_config)
"""
app.py
====================================
Main file that holds the entry point for this server application.
"""

from create_app import create_app
'''
To run this server in development
    $ export FLASK_APP=`pwd`/app.py
    $ export FLASK_DEBUG=1
creating flask app instance

parameters could be
    config.development
    config.testing
    config.production

depending on that input the app will be initialized with the
corresponding database queries files and database driver
'''

# Set config file accordingly
app = create_app('config.development')

if __name__ == '__main__':
    app.run(host='localhost',
            port=app.config['PORT'],
            debug=app.config['FLASK_DEBUG'])
Beispiel #20
0
import os
import config
from create_app import create_app
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = create_app(config.DevelopmentConfig)
db = SQLAlchemy(app)
import logging
from create_app import create_app
from configuration import get_config

logger = logging.getLogger(__name__)

app = create_app(get_config())

if __name__ == "__main__":
    app.run(debug=True, use_reloader=True)
Beispiel #22
0
# TODO Dadra and Nagar Haveli and Daman and Diu
# TODO Add Navbar

df = pd.read_csv('state_wise_daily.csv')
df = clean_raw_data(df)

india_df = get_india_df(df, vaccine_df)

state_population_df = pd.read_csv('population.csv')

state_metrics_df = get_state_metrics_df(df, vaccine_df, state_population_df)
state_metrics_df = get_modified_state_metrics_df(state_metrics_df)

date_wise_metrics = get_date_wise_metrics(df, state_population_df, vaccine_df)

india_geojson = json.load(open("states_india.geojson", "r"))
india_geojson = modify_geojson(india_geojson)

moving_avg_df = date_wise_metrics.copy()
moving_avg_df = moving_avg_df.rolling(7).mean()

date_mask = moving_avg_df.index >= '2020-07-01'
app = create_app(moving_avg_df[date_mask], state_metrics_df, india_df,
                 india_geojson)

server = app.server
# if in_production:
#     server = app.server
# else:
#     app.run_server()
Beispiel #23
0
from create_app import create_app

myapp, db, migrate = create_app(__name__)

from app.views import unauth, auth, general

myapp.register_blueprint(unauth.api)
myapp.register_blueprint(auth.api)
myapp.register_blueprint(general.http)

if __name__ == '__main__':
    myapp.run()
Beispiel #24
0
def init_app(app_config):
    # Re-initializes local postgres DB before each test
    init_db(app_config.API_ENV)
    yield create_app(app_config)
Beispiel #25
0
# -*- coding: utf-8 -*-

#---------------------------------------------------------------------------
#  Copyright (c) 2018-present, Lenovo. All rights reserved.
#  Licensed under BSD, see COPYING.BSD file for details.
#---------------------------------------------------------------------------

import os
import logging
from config import config
from create_app import create_app
from urls import init_urls
import fcntl
import time

cfg = config[os.getenv('FLASK_CONFIG') or 'default']
app = create_app(cfg)
init_urls(app)

if __name__ == '__main__':
    app.run()