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()
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()
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()
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()
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"
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"
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))
def shutdown_session(exception): db_session.remove()
def shutdown_session(exception=None): db_session.remove()
def remove_session(exception=None): db_session.remove()
def shutdown_session(exception=None): """ Codigo para que se puede bajar la base de datos automaticamente """ db_session.remove()
def load_data(): load_sheet_music() load_users() load_items() load_trades() db_session.remove()