示例#1
0
    def test_quantity_records_downloaded_and_saved_are_the_same(self):
        max_records = 100
        pages = math.ceil(max_records / 100)
        extra_registers = max_records % 100
        max_registers_per_page = 100
        start_from_id = 1

        for p in range(pages):
            if p + 1 == pages:
                start_from_id = seed(extra_registers, start_from_id)
            else:
                start_from_id = seed(max_registers_per_page, start_from_id)

        self.assertGreater(start_from_id, 1)
示例#2
0
def refresh_db(app=None,models=None,seed=None):
    if app is None:
        from flask_tasks import get_app,settings
        app = get_app(settings.TestConfig,add_default_extensions=False)
    if models is None:
        from flask_tasks import models
    if seed is None:
        from seed import seed

    ctx = app.test_request_context()
    ctx.push()
    
    models.BaseMixin.metadata.bind = models.BaseMixin.engine
    models.BaseMixin.engine.echo = True      
    models.BaseMixin.metadata.drop_all()
    models.BaseMixin.metadata.create_all()
    seed()

    ctx.pop()
示例#3
0
def main():

  app = Flask(__name__)
  app.config['SESSION_TYPE'] = env['SESSION_TYPE']
  app.config.from_object(__name__)
  app.secret_key = env['SESSION_SECRET']
  Session(app)
  app.config['DEBUG'] = env['DEBUG']
  app.config['SQLALCHEMY_DATABASE_URI'] = env['DATABASE_URI']
  app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
  app.register_blueprint(routes)
  db.init_app(app)
  with app.app_context():
    db.create_all()
    if env['SEED']:
      db.reflect()
      db.drop_all()
      db.create_all()
      seed(db)
  app.run(host=env['SERVER_HOST'], port=env['SERVER_PORT'])
#------------------------------------------------------------------#
示例#4
0
def seeds_gen(level):
    seeds = []

    for i in range(len(level)):
        if level[i] == 8:
            s = seed()
            s.geometry.x = i % 40 * 30
            s.geometry.y = i // 40 * 30
            s.ball = pygame.image.load('pellet.gif')
            s.mode = 1
            seeds.append(s)

        if level[i] == 9:
            s = seed()
            s.geometry.x = i % 40 * 30
            s.geometry.y = i // 40 * 30
            s.ball = pygame.image.load('fruit.png')
            s.mode = 2
            seeds.append(s)

    return seeds
示例#5
0
 def setUp(self):
     # runs before every test case
     global jimid
     # with sqlite3.connect(Account.dbpath) as conn:
     #     cur = conn.cursor()
     #     SQL = f"DELETE FROM {Account.tablename}"
     #     cur.execute(SQL)
     #     SQL = f"""INSERT INTO {Account.tablename}(first, last, username, password_hash, balance, email)
     #     VALUES ("Jim", "Love", "JimmyLove", null, 0, "*****@*****.**")"""
     #     cur.execute(SQL)
     #     jimid = cur.lastrowid
     pks = seed.seed(TESTDBPATH)
     jimid = pks['jimid']
示例#6
0
def finished():
    finished = input("Are you finished? ")
    if finished in yes:
        exit()
        return True
    if finished in no:
        usize = usersize()
        uinput = userinput(usize)

        generate(usize, seed(uinput), state(),
                 userpunc("Use puncuations? (Y/N):"))
        return False
    else:
        return False
示例#7
0
from schema import schema
from seed import seed


schema()
seed()
示例#8
0
 def setup_data_database(self):
     connection_string_data = 'sqlite:///db/data.db'
     seed.seed(connection_string_data)
     return connection_string_data
示例#9
0
from app import db
from seed import seed

from models import *

if __name__ == "__main__":
    print("Dropping database tables...")
    db.drop_all()
    print("Creating database tables...")
    db.create_all()
    print("Seeding database tables...")
    seed(db)
    print("Committing...")
    db.session.commit()
    print("Completed!")
示例#10
0
from run import db
import math
import sys
from seed import seed

if len(sys.argv) > 1:
    total = int(sys.argv[1])
else:
    total = 150

pages = math.ceil(total / 100)
extra_registers = total % 100
print("Pages:{}".format(pages))
max_registers_per_page = 100
start_from_id = 1
print(pages)

db.drop_all()
db.create_all()
db.session.commit()

for p in range(pages):
    print("Starting from id:{} page {}".format(start_from_id, p))
    if p + 1 == pages:
        start_from_id = seed(extra_registers, start_from_id)
    else:
        start_from_id = seed(max_registers_per_page, start_from_id)
def seed_database():
    seed(Session())
示例#12
0
def seed_all():
    seed(db)
示例#13
0
def run():
    schema()
    seed()
示例#14
0
 def setUp(self):
     create_db('_test.db')
     seed('_test.db')
示例#15
0
# from render import render
# from world import world
#
#
# world = world(1920, 1080)
# world.create(12)
# render(world)

from seed import seed

seed(1)
示例#16
0
def seedContent(request):
    if request.user.is_authenticated():
        logout(request)
    seed.seed()
    return HttpResponseRedirect('/')
示例#17
0
文件: main.py 项目: madmaze/crawlr
#!/usr/bin/env python

import seed
import clientTools
import mongoConfig as mc

cT = clientTools.clientTools()
loopCnt=1
requestSize=10
skipCnt=0
while loopCnt<100:
    urls = cT.client("<request|"+str(requestSize)+">")
    if "<none>" not in urls:
        todoList = urls.strip('<>\n').split('|')
        #print todoList
        for todo in todoList:
            if todo != "":
                print "processing: ",todo
                s = seed.seed(url=todo,domain="tumblr.com",userAgent=mc.uA)
                if s.crawl() < 0:
                    skipCnt+=1
        loopCnt+=1
    else:
        print "could not get new set of urls"
    print "requests done: %d / skipped: %d" % ((loopCnt*requestSize),skipCnt)
示例#18
0
sensorMoments = db["sensorMoments"]
worldObjects = db["worldObjects"]  # Objects with locations
runs = db[
    "runs"]  # Run organizes the entire experience for each individual run
# Runs has: run id, user id, start_time, list of locations in lat, lng, end time, list of moments played, list of speeds, last distance run to moment
defaultStories = db["defaultStories"]
nudgeStories = db["nudgeStories"]

users = set()  # Keep track of user ids. Hacky fix.

# Fill server database with hardcoded moments/objectt
if len(sys.argv) > 2:
    seedFlag = sys.argv[2]
    if seedFlag == 'seed':
        print("seeding database")
        seed(moments, worldObjects)
    elif seedFlag == 'default':
        print("seeding w/ default")
        seedDefault(defaultStories)
    elif seedFlag == 'nudge':
        print("seeding w/ nudge")
        seedNudge(nudgeStories)


@app.route('/')
def index():
    return 'hs4x'


def generate_userId():
    randId = random.randint(1, 1001)
示例#19
0
from models.species import Species
from models.users import Users

print("Reading config...")
config = configparser.ConfigParser()
config.read("config.ini")

bot = commands.Bot(command_prefix=config["discordbot"]["CommandPrefix"])
bot.add_cog(Game(bot))
bot.add_cog(Birth(bot))
bot.add_cog(Shop(bot))
bot.add_cog(Ping(bot))

print("Starting database...")

seed.seed()
db = SqliteDatabase("main.db")
db.connect()


@bot.event
async def on_ready():
    print("Logged in as")
    print(bot.user.name)
    print(bot.user.id)


def run_event_loop():
    schedule.every(10).minutes.do(trigger, client=bot)
    while True:
        schedule.run_pending()
 def setUp(self):
     """ the setup method must be called setup """
     TodoItem.dbpath = DBPATH
     schema(DBPATH)
     seed(DBPATH)