Exemplo n.º 1
0
    def setup_db(self, package_name):
        """
        Drops and re-installs the database found at "arches_<package_name>"
        WARNING: This will destroy data

        """

        db_settings = settings.DATABASES['default']
        truncate_path = os.path.join(settings.ROOT_DIR, 'db', 'install',
                                     'truncate_db.sql')
        db_settings['truncate_path'] = truncate_path

        truncate_db.create_sqlfile(db_settings, truncate_path)

        os.system(
            'psql -h %(HOST)s -p %(PORT)s -U %(USER)s -d postgres -f "%(truncate_path)s"'
            % db_settings)

        management.call_command('migrate')

        self.import_graphs(os.path.join(settings.ROOT_DIR, 'db',
                                        'system_settings',
                                        'Arches_System_Settings_Model.json'),
                           overwrite_graphs=True)
        self.import_business_data(os.path.join(settings.ROOT_DIR, 'db',
                                               'system_settings',
                                               'Arches_System_Settings.json'),
                                  overwrite=True)

        local_settings_available = os.path.isfile(
            os.path.join(settings.SYSTEM_SETTINGS_LOCAL_PATH))

        if local_settings_available == True:
            self.import_business_data(settings.SYSTEM_SETTINGS_LOCAL_PATH,
                                      overwrite=True)
Exemplo n.º 2
0
    def setup_db(self, package_name):
        """
        Drops and re-installs the database found at "arches_<package_name>"
        WARNING: This will destroy data

        """

        db_settings = settings.DATABASES['default']
        truncate_path = os.path.join(settings.ROOT_DIR, 'db', 'install', 'truncate_db.sql')
        db_settings['truncate_path'] = truncate_path

        truncate_db.create_sqlfile(db_settings, truncate_path)

        os.system('psql -h %(HOST)s -p %(PORT)s -U %(USER)s -d postgres -f "%(truncate_path)s"' % db_settings)

        self.delete_indexes()
        prepare_term_index(create=True)
        prepare_resource_relations_index(create=True)
        management.call_command('migrate')

        self.import_graphs(os.path.join(settings.ROOT_DIR, 'db', 'system_settings', 'Arches_System_Settings_Model.json'), overwrite_graphs=True)
        self.import_business_data(os.path.join(settings.ROOT_DIR, 'db', 'system_settings', 'Arches_System_Settings.json'), overwrite=True)

        local_settings_available = os.path.isfile(os.path.join(settings.SYSTEM_SETTINGS_LOCAL_PATH))

        if local_settings_available == True:
            self.import_business_data(settings.SYSTEM_SETTINGS_LOCAL_PATH, overwrite=True)
Exemplo n.º 3
0
    def setup_db(self, package_name):
        """
        Drops and re-installs the database found at "arches_<package_name>"
        WARNING: This will destroy data

        """

        db_settings = settings.DATABASES['default']
        truncate_path = os.path.join(settings.ROOT_DIR, 'db', 'install',
                                     'truncate_db.sql')
        install_path = os.path.join(settings.ROOT_DIR, 'db', 'install',
                                    'install_db.sql')
        db_settings['truncate_path'] = truncate_path
        db_settings['install_path'] = install_path

        truncate_db.create_sqlfile(db_settings, truncate_path)
        install_db.create_sqlfile(db_settings, install_path)

        os.system(
            'psql -h %(HOST)s -p %(PORT)s -U %(USER)s -d postgres -f "%(truncate_path)s"'
            % db_settings)
        os.system(
            'psql -h %(HOST)s -p %(PORT)s -U %(USER)s -d %(NAME)s -f "%(install_path)s"'
            % db_settings)

        create_default_auth_system()
Exemplo n.º 4
0
    def setup_db(self, package_name):
        """
        Drops and re-installs the database found at "arches_<package_name>"
        WARNING: This will destroy data

        """

        db_settings = settings.DATABASES['default']
        truncate_path = os.path.join(settings.ROOT_DIR, 'db', 'install', 'truncate_db.sql')  
        db_settings['truncate_path'] = truncate_path
        
        truncate_db.create_sqlfile(db_settings, truncate_path)
        
        os.system('psql -h %(HOST)s -p %(PORT)s -U %(USER)s -d postgres -f "%(truncate_path)s"' % db_settings)
        
        management.call_command('migrate') 
Exemplo n.º 5
0
    def setup_db(self, package_name):
        """
        Drops and re-installs the database found at "arches_<package_name>"
        WARNING: This will destroy data

        """

        db_settings = settings.DATABASES["default"]
        truncate_path = os.path.join(settings.ROOT_DIR, "db", "install", "truncate_db.sql")
        install_path = os.path.join(settings.ROOT_DIR, "db", "install", "install_db.sql")
        db_settings["truncate_path"] = truncate_path
        db_settings["install_path"] = install_path

        truncate_db.create_sqlfile(db_settings, truncate_path)
        install_db.create_sqlfile(db_settings, install_path)

        os.system('psql -h %(HOST)s -p %(PORT)s -U %(USER)s -d postgres -f "%(truncate_path)s"' % db_settings)
        os.system('psql -h %(HOST)s -p %(PORT)s -U %(USER)s -d %(NAME)s -f "%(install_path)s"' % db_settings)

        self.create_groups()
        self.create_users()
Exemplo n.º 6
0
def setup_db(connection):
    """
    Taken from the setup_db management command but slightly edited to run using the test database name. It will
    also run the test_setup.install() function that will edit and add concepts into the database.
    """

    test_database_name = connection.creation._get_test_db_name()

    db_settings = settings.DATABASES['default']
    db_settings['NAME'] = test_database_name

    truncate_path = os.path.join(settings.ROOT_DIR, 'db', 'install',
                                 'truncate_db.sql')
    install_path = os.path.join(settings.ROOT_DIR, 'db', 'install',
                                'install_db.sql')
    db_settings['truncate_path'] = truncate_path
    db_settings['install_path'] = install_path

    truncate_db.create_sqlfile(db_settings, truncate_path)
    install_db.create_sqlfile(db_settings, install_path)

    os.system(
        'psql -h %(HOST)s -p %(PORT)s -U %(USER)s -d postgres -f "%(truncate_path)s"'
        % db_settings)
    os.system(
        'psql -h %(HOST)s -p %(PORT)s -U %(USER)s -d %(NAME)s -f "%(install_path)s"'
        % db_settings)

    create_groups()
    create_users()

    settings.DATABASES['default']["NAME"] = test_database_name
    connection.settings_dict["NAME"] = test_database_name

    print "DATABASE CREATION STEP DONE - NOW ADDING DATA"

    test_setup.install()

    return test_database_name