示例#1
0
def dts_init():
    u"""数据库初始化"""
    u"""首先执行数据库的初始化工作"""
    db.create_all()
    Role.insert_roles()
    BugStatus.insert_bug_status()
    print u"数据库初始化成功"
示例#2
0
def dts_init():
    u"""数据库初始化"""
    u"""首先执行数据库的初始化工作"""
    db.create_all()
    Role.insert_roles()
    BugStatus.insert_bug_status()
    print u'数据库初始化成功'
示例#3
0
def install(username=None, password=None, email=None):
    """Installs DTS with all necessary data."""

    print("Creating default data...")
    try:
        Role.insert_roles()
        BugStatus.insert_bug_status()
    except IntegrityError:
        print("Couldn't create the default data because it already exist!")
        if prompt_bool("Found an existing database."
                       "Do you want to recreate the database? (y/n)"):
            db.session.rollback()
            db.drop_all()
            db.create_all()
            print("Creating DataBase Default Data...")
            Role.insert_roles()
            BugStatus.insert_bug_status()
        else:
            sys.exit(0)
    except OperationalError:
        print("No database found.")
        if prompt_bool("Do you want to create the database now? (y/n)"):
            db.session.rollback()
            db.drop_all()
            db.create_all()
            print("Creating DataBase Default Data...")
            Role.insert_roles()
            BugStatus.insert_bug_status()
        else:
            sys.exit(0)

    print("Creating admin user...")
    if username and password and email:
        User.create_admin_user(username=username,
                               password=password,
                               email=email)
    else:
        create_admin()

    dir_create()
    print("Congratulations! DTS has been successfully installed")
示例#4
0
def install(username=None, password=None, email=None):
    """Installs DTS with all necessary data."""

    print ("Creating default data...")
    try:
        Role.insert_roles()
        BugStatus.insert_bug_status()
    except IntegrityError:
        print ("Couldn't create the default data because it already exist!")
        if prompt_bool("Found an existing database." "Do you want to recreate the database? (y/n)"):
            db.session.rollback()
            db.drop_all()
            db.create_all()
            print ("Creating DataBase Default Data...")
            Role.insert_roles()
            BugStatus.insert_bug_status()
        else:
            sys.exit(0)
    except OperationalError:
        print ("No database found.")
        if prompt_bool("Do you want to create the database now? (y/n)"):
            db.session.rollback()
            db.drop_all()
            db.create_all()
            print ("Creating DataBase Default Data...")
            Role.insert_roles()
            BugStatus.insert_bug_status()
        else:
            sys.exit(0)

    print ("Creating admin user...")
    if username and password and email:
        User.create_admin_user(username=username, password=password, email=email)
    else:
        create_admin()

    dir_create()
    print ("Congratulations! DTS has been successfully installed")