예제 #1
0
def init():
    """initialize database and directories"""
    try:
        remakedir(settings.DATA_DIR_PATH)
        remakedir(settings.DEMO_DIR_PATH)
        remakedir(settings.THUMBNAIL_DIR_PATH)
    except:
        print sys.exc_info()
        
    try:
        if os.path.exists(settings.DB_PATH):
            os.remove(settings.DB_PATH)
        init_db()
        if getpwuid(os.getuid())[0] == 'root':
            os.chown(settings.DB_PATH, apache_uid, apache_gid)
    except:
        print sys.exc_info()

    try:
        role_admin = UserRole('admin', 'for administrators')
        db_session.add(role_admin)

        user_admin = User('admin', role=role_admin)
        db_session.add(user_admin)

        db_session.commit()
        db_session.remove()

    except:
        print sys.exc_info()
예제 #2
0
파일: manage.py 프로젝트: planset/templa
def init():
    """initialize database and directories"""
    try:
        remakedir(settings.DATA_DIR_PATH)
        remakedir(settings.DEMO_DIR_PATH)
        remakedir(settings.THUMBNAIL_DIR_PATH)
    except:
        print sys.exc_info()

    try:
        if os.path.exists(settings.DB_PATH):
            os.remove(settings.DB_PATH)
        init_db()
        if getpwuid(os.getuid())[0] == "root":
            os.chown(settings.DB_PATH, apache_uid, apache_gid)
    except:
        print sys.exc_info()

    try:
        role_admin = UserRole("admin", "for administrators")
        db_session.add(role_admin)

        user_admin = User("admin", role=role_admin)
        db_session.add(user_admin)

        db_session.commit()
        db_session.remove()

    except:
        print sys.exc_info()
예제 #3
0
    def tearDownClass(cls):

        if cls.client:
            cls.client.get("{}/{}".format(cls.server_url, 'testing/shutdown'))
            cls.client.close()

            db_session.remove()
            cls.meta_db.drop_all()
            if 'sqlite' in cls.config_obj.SQLALCHEMY_DATABASE_URI:
                os.remove(os.path.join(cls.config_obj.BASE_DIR, cls.config_obj.db_path))

            cls.app_context.pop()
예제 #4
0
    def tearDown(self):
        """
        Tests if another client is defined.  If it is, destroy it
        :return: None
        """
        if hasattr(self, 'other_client'):
            try:
                self.other_client.close()
            except ConnectionRefusedError:
                pass

        self.go_to('auth/logout')
        db_session.remove()
        self.meta_db.drop_all()
예제 #5
0
def adminpassword():
    """set admin password"""
    admin_username = "******"

    password = getpass.getpass()
    if len(password)<8:
        print "dame"
        return

    admin = User.query.get(1)

    if not admin:
        userrole = UserRole.query.get('admin')
        admin = User(admin_username, userrole)
        db_session.add(admin)
    
    admin.set_password(password)

    db_session.commit()
    db_session.remove()

    print "update successfully"
예제 #6
0
파일: manage.py 프로젝트: planset/templa
def adminpassword():
    """set admin password"""
    admin_username = "******"

    password = getpass.getpass()
    if len(password) < 8:
        print "dame"
        return

    admin = User.query.get(1)

    if not admin:
        userrole = UserRole.query.get("admin")
        admin = User(admin_username, userrole)
        db_session.add(admin)

    admin.set_password(password)

    db_session.commit()
    db_session.remove()

    print "update successfully"
예제 #7
0
 def tearDown(self):
     db_session.remove()
     self.meta_db.drop_all()
     if 'sqlite' in self.config_obj.SQLALCHEMY_DATABASE_URI:
         os.remove(os.path.join(self.config_obj.BASE_DIR, self.config_obj.db_path))
예제 #8
0
def shutdown_session(exception):
    db_session.remove()
예제 #9
0
파일: __init__.py 프로젝트: planset/templa
def shutdown_session(exception=None):
    db_session.remove()
예제 #10
0
파일: __init__.py 프로젝트: theanht1/nd-004
 def remove_session(exception=None):
     db_session.remove()
예제 #11
0
 def shutdown_session(exception=None):
     """
     Codigo para que se puede bajar la base de datos automaticamente
     """
     db_session.remove()
예제 #12
0
def load_data():
    load_sheet_music()
    load_users()
    load_items()
    load_trades()
    db_session.remove()