Esempio n. 1
0
 def setUp(self):
     db.create_all()
     classification_1 = Classification("Brachinite", "Primitive Achondrite", "Stony", "Unknown", 1)
     classification_2 = Classification("Chassignites", "Achondrite", "Stony", "Mars", 1)
     db.session.add(classification_1)
     db.session.add(classification_2)
     db.session.commit()
Esempio n. 2
0
 def setUp(self):
     db.create_all()
     meteorite_1 = Meteorite("Aachen", 21.0, "L", 1880, "Algeria", 50.775000, 6.083330, "50.775000, 6.083330")
     meteorite_2 = Meteorite("Aarhus", 720.0, "H", 1951, "Germany", 56.183330, 10.233330, "56.183330, 10.233330")
     db.session.add(meteorite_1)
     db.session.add(meteorite_2)
     db.session.commit()
Esempio n. 3
0
 def setUp(self):
     db.create_all()
     country1 = Country("SE", "Sweden", 10, 7, 10000000, "u1")
     country2 = Country("US", "United States", 18, 10, 300000000, "u2")
     db.session.add(country1)
     db.session.add(country2)
     db.session.commit()
Esempio n. 4
0
 def setUp(self):
     db.create_all()
     self.loc1 = Location(**_LOCDICTS[0])
     self.loc2 = Location(**_LOCDICTS[1])
     db.session.add(self.loc1)
     db.session.add(self.loc2)
     db.session.commit()
Esempio n. 5
0
 def setUp(self):
     db.create_all()
     self.cat1 = Category(**_CATDICTS[0])
     self.cat2 = Category(**_CATDICTS[1])
     db.session.add(self.cat1)
     db.session.add(self.cat2)
     db.session.commit()
Esempio n. 6
0
 def setUp(self):
     db.create_all()
     country_1 = Country("Australia", 7692000, "-25.274398, 133.775136", "None", 1)
     country_2 = Country("France", 643801, "46.227638, 22.13749", "None", 1)
     db.session.add(country_1)
     db.session.add(country_2)
     db.session.commit()
Esempio n. 7
0
def createdb():
    db.drop_all()
    db.create_all()
    populateClassifications('classes.json')
    populateCountries('countries.json')
    populateMeteorites('meteorites.json')
    populateRelations()
Esempio n. 8
0
 def setUp(self):
     db.create_all()
     track = Track("Drop the Game", "Flume, Chet Faker", "2013-11-12", "Lockjaw", "cover_url", 1923800, "asjklgmbn", "id",1,"https:yes","http:whynot")
     track2 = Track("Landed on Mars", "Atlas Bound", "2015-03-18", "Landed on Mars", "cover_url_2", 224000, "iuhmfgakuek", "id",2,"http:no","http:why")
     db.session.add(track)
     db.session.add(track2)
     db.session.commit()
Esempio n. 9
0
 def setUp(self):
     db.create_all()
     prize1 = Prize("Physics", 1991, 2, "motivation1", "u1")
     prize2 = Prize("Peace", 1950, 1, "motivation2", "u2")
     db.session.add(prize1)
     db.session.add(prize2)
     db.session.commit()
Esempio n. 10
0
 def setUp(self):
     db.create_all()
     self.rest1 = Restaurant(**_RESTDICTS[0])
     self.rest2 = Restaurant(**_RESTDICTS[1])
     db.session.add(self.rest1)
     db.session.add(self.rest2)
     db.session.commit()
Esempio n. 11
0
 def setUp(self):
     db.create_all()
     laureate1 = Laureate("John Doe", 1, "1956-11-2", "M", "u1", 1)
     laureate2 = Laureate("Jane Doe", 2, "1939-4-7", "F", "u2", 1)
     db.session.add(laureate1)
     db.session.add(laureate2)
     db.session.commit()
Esempio n. 12
0
 def setUp(self):
     db.create_all()
     artist = Artist("Atlas Bound", 8, "Lullaby", "Landed on Mars", 42, "alsjdflkasjd", "http","http://www.google.com","http://yo.com",1)
     artist2 = Artist("Chet Faker", 20, "1998 Melbourne Edition", "Drop the Game",76, "asffagd", "http","http://imgur.com","http:lol",100)
     db.session.add(artist)
     db.session.add(artist2)
     db.session.commit()
Esempio n. 13
0
 def setUp(self):
     db.create_all()
     album = Album("1998 Melbourne Edition", "Chet Faker", "2015-05-18", "45:21", 5, "asdfasdf", "http","http:yayay.com","http:hey.com","hasdfasf")
     album2 = Album("Lullaby", "Atlas Bound", "2016-03-18", "29:10", 1, "oiuohkjt", "http","http://yahoo.com","http://aol.com",'hadfasdf')
     db.session.add(album)
     db.session.add(album2)
     db.session.commit()
Esempio n. 14
0
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = BaseTest.SQLALCHEMY_DATABASE_URI
     with app.app_context():
         db.init_app(app)
         db.create_all()
     self.app = app.test_client()
     self.app_context = app.app_context
Esempio n. 15
0
def install():
    db.drop_all()
    db.create_all()

    # Sample data
    from toilet.models import Category, Tag, Toilet

    cat_public = Category('public')
    db.session.add(cat_public)
    cat_commercial = Category('commercial')
    db.session.add(cat_commercial)
    cat_paid = Category('paid')
    db.session.add(cat_paid)
    cat_code = Category('code')
    db.session.add(cat_code)

    tag_disabled = Tag('disabled')
    db.session.add(tag_disabled)

    t_sihlpost = Toilet('Sihlpost', 47.375312, 8.532493)
    t_sihlpost.category = cat_commercial
    t_sihlpost.tags.append(tag_disabled)
    db.session.add(t_sihlpost)
    db.session.commit()

    return 'Installed'
Esempio n. 16
0
 def setUp(self):
     # Make sure the database exists
     # Get a test client
     with app.app_context():
         db.create_all()
     # Get a test client
     self.app = app.test_client
     self.app_context = app.app_context
Esempio n. 17
0
def create_db():
    """
    This command is used to initialize the database and insert the data scraped     """

    app.config['SQLALCHEMY_ECHO'] = True
    db.drop_all()
    db.create_all()
    init_db()
    db.session.commit()
Esempio n. 18
0
 def setUp(self):
     # Make sure database exists
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
     with app.app_context():
         db.init_app(app)
         db.create_all()
     # Get a test client
     self.app = app.test_client()
     self.app_context = app.app_context
Esempio n. 19
0
def init_db():
    print('Building models.')
    db.create_all()
    print('Done.')
    # Create some sample users
    from models import User
    user1 = User(username='******', password='******', name='Foo Bar')
    user2 = User(username='******', password='******', name='Admin')
    db.session.add(user1)
    db.session.add(user2)
    db.session.commit()
Esempio n. 20
0
def create_app():
    """
    creats a flask app with configs and connect db
    """
    app = Flask(__name__)
    app.config.from_object('config')
    app.jinja_env.add_extension('jinja2.ext.loopcontrols')
    app.jinja_env.globals.update(get_score_color=util.get_score_color)
    app.jinja_env.globals.update(score_prediction=util.score_prediction)
    db.init_app(app)
    with app.app_context():
        db.create_all()
    return app
Esempio n. 21
0
def create_app(config_filename=None):
    app = Flask(__name__)
    app.config.from_pyfile(config_filename or 'config.py')

    from db import db
    db.init_app(app)
    db.app = app

    db.create_all()

    from views import dashboard
    app.register_blueprint(dashboard)

    return app
Esempio n. 22
0
def create_app(app):
    #config
    app.config.from_object(os.environ['APP_SETTINGS'])

    #models
    db.init_app(app)
    ma.init_app(app)

    with app.app_context():

        from models.book import Book
        from models.author import Author
        from models.rating import Rating
        from models.category import Category
        from models.user import User
        from models.log import ReadingLog
        db.create_all()
        db.session.commit()

        #create endpoints
        app.register_blueprint(endpoints)
Esempio n. 23
0
 def setUp(self):
     db.create_all()
     laureate1 = Laureate("Yuan", 1, "1956-11-2", "M", "u1", 1)
     laureate1.search_text = "yuan taiwan"
     laureate2 = Laureate("Yuan", 2, "1939-4-7", "F", "u2", 1)
     laureate2.search_text = "yuan"
     prize1 = Prize("Physics", 1991, 2, "motivation1", "u1")
     prize1.search_text = "one yuan"
     prize2 = Prize("Physics", 1991, 2, "motivation1", "u1")
     prize2.search_text = "taiwan one yuan"
     country1 = Country("SE", "Sweden", 10, 7, 10000000, "u1")
     country1.search_text = "taiwan ldksfjsl;fkjsd yuan"
     country2 = Country("SR", "Sweden", 10, 7, 10000000, "u1")
     country2.search_text = "two yuan"
     db.session.add(laureate1)
     db.session.add(laureate2)
     db.session.add(prize1)
     db.session.add(prize2)
     db.session.add(country1)
     db.session.add(country2)
     db.session.commit()
Esempio n. 24
0
def add_user():
    db.create_all()

    form = UserForm()

    if form.validate_on_submit():
        logging.warning("weeee")
        new_user = User()

        new_user.username = form.username.data
        new_user.salt = hexlify(os.urandom(128)).decode("ascii")

        password = form.password.data

        # Default properties for N, r, p (see http://hackage.haskell.org/package/scrypt-0.3.2/docs/Crypto-Scrypt.html)
        h1 = scrypt.hash(password, new_user.salt, buflen=128)
        logging.warning(hexlify(h1))

        new_user.hash = hexlify(h1).decode("ascii")

        db.session.add(new_user)
        db.session.commit()

    return render_template("add-user.html", form=form)
Esempio n. 25
0
 def setUp(self):
     self.app = setupApp(True).test_client()
     db.drop_all()
     db.create_all()
     self.register(self.account_admin_info)
Esempio n. 26
0
def create_tables():
    db.drop_all()
    db.create_all()
Esempio n. 27
0
def crear_base_de_datos():
    db.init_app(app)
    db.create_all(app=app)
Esempio n. 28
0
def setup():
    """Set up the file system, GPG, and database."""
    create_directories()
    init_gpg()
    db.create_all()
Esempio n. 29
0
def create_tables():
    db.create_all(
    )  #creates data.db and ALL freaking table unless they exist already
Esempio n. 30
0
def initdb():
    """
    Creates all database tables.
    """
    db.create_all()
    print 'Initialized the database.'
Esempio n. 31
0
def create_tables() -> None:
    db.create_all()
Esempio n. 32
0
def main():
    with app.app_context():
        db.create_all()
Esempio n. 33
0
def db_create():
    db.create_all()
Esempio n. 34
0
def index_page():
    print(request.query_string)
    db.create_all()
    form = Template()
    # print(DBObject.query.all())
    # print(DBObject.query.order_by(DBObject.sitename.desc()).all())
    # print(DBObject.query.filter(DBObject.sitename.like('spidere%')).all())
    # print(DBObject.query.get(2).sitename)
    # if "Logoname" not in session and "sitename" not in session:
    #     session["Logoname"] = "spidereyes.png"
    #     session["sitename"] = "spidereyes"
    if request.method == "POST":
        data = form.data
        print(form.data)

        if form.validate_on_submit():  #提交数据有效
            session["sitename"] = data["Sitename"]
            filename = form.Logo.data.filename
            if filename:
                DBobject1 = DBObject(sitename=form.Sitename.data,
                                     pic_url=form.Logo.data.filename)
                session["Logoname"] = filename
                form.Logo.data.save(
                    os.path.join(app.config["UPLOAD_PATH"], filename))
            else:
                if "Logoname" in session:
                    DBobject1 = DBObject(sitename=session["sitename"],
                                         pic_url=session["Logoname"])
                else:
                    DBobject1 = DBObject(
                        sitename=session["sitename"],
                        pic_url=DBObject.query.filter_by(id=2).first().pic_url)
            db.session.add(DBobject1)
            db.session.commit()
            return redirect("/index")
        else:  #提交数据无效
            if "Logoname" in session and "sitename" in session:
                return render_template("settings.html",
                                       form=form,
                                       name=session['Logoname'],
                                       sitename=session["sitename"],
                                       desc_value="abcdefg")
            elif "Logoname" in session:
                return render_template(
                    "settings.html",
                    form=form,
                    name=session['Logoname'],
                    sitename=DBObject.query.filter_by(id=2).first().sitename,
                    desc_value="abcdefg")
            elif "sitename" in session:
                return render_template(
                    "settings.html",
                    form=form,
                    name=DBObject.query.filter_by(id=2).first().pic_url,
                    sitename=session['sitename'],
                    desc_value="abcdefg")
            else:
                return render_template(
                    "settings.html",
                    form=form,
                    name=DBObject.query.filter_by(id=2).first().pic_url,
                    sitename=DBObject.query.filter_by(id=2).first().sitename,
                    desc_value="abcdefg")
    else:  #get请求
        if "Logoname" in session and "sitename" in session:
            return render_template("settings.html",
                                   form=form,
                                   name=session['Logoname'],
                                   sitename=session["sitename"],
                                   desc_value="abcdefg")
        elif "Logoname" in session:
            return render_template(
                "settings.html",
                form=form,
                name=session['Logoname'],
                sitename=DBObject.query.filter_by(id=2).first().sitename,
                desc_value="abcdefg")
        elif "sitename" in session:
            return render_template(
                "settings.html",
                form=form,
                name=DBObject.query.filter_by(id=2).first().pic_url,
                sitename=session['sitename'],
                desc_value="abcdefg")
        else:
            return render_template(
                "settings.html",
                form=form,
                name=DBObject.query.filter_by(id=2).first().pic_url,
                sitename=DBObject.query.filter_by(id=2).first().sitename,
                desc_value="abcdefg")
Esempio n. 35
0
def before_first_request_func():
    db.create_all()
Esempio n. 36
0
 def setUp(self):
     with app.app_context():
         db.create_all()
     # Get a test client
     self.app = app.test_client
     self.app_context = app.app_context
Esempio n. 37
0
 def get(self):
     db.create_all()
     return {"message": "creating db."}, 201
Esempio n. 38
0
def create_tables():
    # Create tables
    db.create_all()
    # Load data from Challenge File
    load_dataset()
Esempio n. 39
0
File: app.py Progetto: b9007/Python
 def create_tables():
     db.create_all()
Esempio n. 40
0
    def sd_servers(self):
        logging.info("Starting SecureDrop servers (session expiration = %s)",
                     self.session_expiration)

        # Patch the two-factor verification to avoid intermittent errors
        logging.info("Mocking models.Journalist.verify_token")
        with mock.patch("models.Journalist.verify_token", return_value=True):
            logging.info("Mocking source_app.main.get_entropy_estimate")
            with mock.patch("source_app.main.get_entropy_estimate",
                            return_value=8192):

                try:
                    signal.signal(signal.SIGUSR1,
                                  lambda _, s: traceback.print_stack(s))

                    source_port = self._unused_port()
                    journalist_port = self._unused_port()

                    self.source_location = "http://127.0.0.1:%d" % source_port
                    self.journalist_location = "http://127.0.0.1:%d" % journalist_port

                    self.source_app = source_app.create_app(config)
                    self.journalist_app = journalist_app.create_app(config)
                    self.journalist_app.config["WTF_CSRF_ENABLED"] = True

                    self.__context = self.journalist_app.app_context()
                    self.__context.push()

                    env.create_directories()
                    db.create_all()
                    self.gpg = env.init_gpg()

                    # Add our test user
                    try:
                        valid_password = "******"
                        user = Journalist(username="******",
                                          password=valid_password,
                                          is_admin=True)
                        user.otp_secret = "HFFHBDSUGYSAHGYCVSHVSYVCZGVSG"
                        db.session.add(user)
                        db.session.commit()
                    except IntegrityError:
                        logging.error("Test user already added")
                        db.session.rollback()

                    # This user is required for our tests cases to login
                    self.admin_user = {
                        "name":
                        "journalist",
                        "password": ("correct horse battery staple"
                                     " profanity oil chewy"),
                        "secret":
                        "HFFHBDSUGYSAHGYCVSHVSYVCZGVSG",
                    }

                    self.admin_user["totp"] = pyotp.TOTP(
                        self.admin_user["secret"])

                    def start_journalist_server(app):
                        app.run(port=journalist_port,
                                debug=True,
                                use_reloader=False,
                                threaded=True)

                    self.source_process = Process(
                        target=lambda: self.start_source_server(source_port))

                    self.journalist_process = Process(
                        target=lambda: start_journalist_server(self.
                                                               journalist_app))

                    self.source_process.start()
                    self.journalist_process.start()

                    for tick in range(30):
                        try:
                            requests.get(self.source_location, timeout=1)
                            requests.get(self.journalist_location, timeout=1)
                        except Exception:
                            time.sleep(0.25)
                        else:
                            break
                    yield
                finally:
                    try:
                        self.source_process.terminate()
                    except Exception as e:
                        logging.error("Error stopping source app: %s", e)

                    try:
                        self.journalist_process.terminate()
                    except Exception as e:
                        logging.error("Error stopping source app: %s", e)

                    env.teardown()
                    self.__context.pop()
Esempio n. 41
0
def setup_function():
    print("setup")
    db.create_all()
    initialize_db()
    print("done")
Esempio n. 42
0
import json
from db import db, Workout
from flask import Flask, request

db_filename = "workout.db"
app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///%s' % db_filename
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_ECHO'] = True

db.init_app(app)
with app.app_context():
    db.create_all()


@app.route("/")
@app.route("/api/workouts/")
def get_workouts():
    workouts = Workout.query.all()
    result = {
        'success': True,
        'data': [workout.serialize() for workout in workouts]
    }
    return json.dumps(result), 200


@app.route("/api/workouts/<string:workout_body_part>/")
def get_workouts_by_part(workout_body_part):
    workouts = Workout.query.filter_by(body_part=workout_body_part).all()
    if workouts is not None:
Esempio n. 43
0
def create_tables():  # create db with tables before first request
    db.create_all()
Esempio n. 44
0
def create_tables():
    db.create_all()  #only creates table it sees.
Esempio n. 45
0
def create_tables():
	# this will create the defined DB and tables. only really works when you can create here...
	db.create_all()
Esempio n. 46
0
 def setUp(self):  # działa przed metodą testów
     with app.app_context():
         db.create_all()
     self.app = app.test_client
     self.app_context = app.app_context
Esempio n. 47
0
def create_tables():
    db.create_all()  # заменяет модуль create_tables
Esempio n. 48
0
def init_db():
    from db import db

    db.create_all()
Esempio n. 49
0
def create_tabel():
    db.create_all()
Esempio n. 50
0
def create_db():
    db.create_all()
Esempio n. 51
0
def gentables():
    db.create_all()
    print('TABLES GENERATED')
Esempio n. 52
0
 def create_tables():
     db.create_all()
Esempio n. 53
0
def create_tables():
    print('Creating tables')
    db.create_all()
Esempio n. 54
0
def create_my_table():
    db.create_all()
Esempio n. 55
0
 def run(self):
     db.create_all()
Esempio n. 56
0
 def setUp(self):
     with app.app_context():
         db.create_all()
     # Get a test client
     self.app = app.test_client
     self.app_context = app.app_context
Esempio n. 57
0
    Before running this file note the following:
        - If there is already an 'app.db' file any new values added to this file
        will add on to the existing database.

        - To create a new fresh database, move the 'app.db' file and save it 
        somewhere else. DO NOT delete it. Keep it as a backup so you don't 
        lose your old database. After, running this file will make a new
        'app.db' file in this directory and will contain all the information
        currently in this file.
"""

# Creates the database using the model in db.py
# Only use the following code to create a new database.
from db import db
db.create_all()


from db import Device, Edge
# Adding Nodes to the database.
elsa = Device('Elsa', 'Node')
db.session.add(elsa)

aurora = Device('Aurora', 'Node')
db.session.add(aurora)

belle = Device('Belle', 'Node')
db.session.add(belle)

# Adding some test sensors to the database
alpha = Device('Alpha', 'Sensor')
Esempio n. 58
0
def db_setup(app):
    with app.app_context():
        db.create_all()
Esempio n. 59
0
    def setUp(self):
        self.app = setupApp(True).test_client()
        db.drop_all()
        db.create_all()

        response = self.app.post('api/account',
                                 data=dict(name='test',
                                           lastname='test',
                                           email='test',
                                           password='******'),
                                 follow_redirects=True)

        account = AccountModel.query.first()
        account.type = 2

        account.save_to_db()

        response = self.app.post('api/login',
                                 data=dict(email='test', password='******'),
                                 follow_redirects=True)

        self.my_id = json.loads(response.data)['id']
        self.token = json.loads(response.data)['token']

        self.auth = {
            'Authorization':
            'Basic ' +
            base64.b64encode(bytes(
                str(self.my_id) + ":" + self.token, 'ascii')).decode('ascii')
        }

        self.app.post('api/account/1/address',
                      data=dict(label_name="Mi casa",
                                name="test",
                                surnames="tests",
                                street="La calle de mi casa",
                                number=32,
                                cp="08431",
                                city="Mi city",
                                province="Mi provincia",
                                telf=123456),
                      headers=self.auth,
                      follow_redirects=True)

        self.app.post('api/account/1/card',
                      data=dict(card_owner="test",
                                number="4567",
                                date="12/2025",
                                payment_method="Visa"),
                      headers=self.auth,
                      follow_redirects=True)

        self.add_book()

        self.app.post('api/order/1',
                      data=dict(date="29/11/2020 10:50",
                                total=1.,
                                shipping=1.,
                                taxes=1.,
                                state=0,
                                send_type=0,
                                card_id=1,
                                address_id=1),
                      headers=self.auth,
                      follow_redirects=True)

        self.app.post('/api/article-order/1',
                      data=dict(price=1, quant=1, id_book=1),
                      headers=self.auth,
                      follow_redirects=True)
Esempio n. 60
0
def create_tables():
    # note that SQLAlchemy would only create tables it can see here
    db.create_all()