Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Changes to locate site-config
Browse files Browse the repository at this point in the history
With this commit the system for locating the site config file is as
follows:

 1. During the configure process cmake will create a file site_config.py
    in the build/python/ert_gui directory, the content of this file will
    be:

        config_file = "${SITE_CONFIG_FILE}"

     where ${SITE_CONFIG_FILE} is the variable set during the configure
     step. The generated file will be installed alongside the gert_main
     module.

 2. The gert_main module tries to import the site_config module and uses
    the config_file setting from there.

 3. If the ERT_SITE_CONFIG environment variable has been set that will
    take presedence.

With these changes it is not necessary for the frontend script to set
the ERT_SITE_CONFIG variable.

Conflicts:
	devel/python/python/ert_gui/gert_main.py
  • Loading branch information
joakim-hove committed Aug 26, 2014
1 parent 732fb0a commit f56eb56
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
11 changes: 11 additions & 0 deletions devel/python/python/ert_gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ add_subdirectory(simulation)
add_subdirectory(tools)
add_subdirectory(viewer)
add_subdirectory(widgets)

#-----------------------------------------------------------------

set(site_config_target "${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ert_gui/site_config.py")
set(destination "${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX}/ert_gui")
set(install_target "${destination}/site_config.py")

configure_file(site_config.py.in ${site_config_target})
install(FILES ${site_config_target} DESTINATION ${destination} )
install(CODE "execute_process(COMMAND ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc_file ${install_target})")

26 changes: 23 additions & 3 deletions devel/python/python/ert_gui/gert_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,22 @@

import ert_gui.widgets.util

ert_gui.widgets.util.img_prefix = os.getenv("ERT_SHARE_PATH") + "/gui/img/"
try:
import site_config
site_config_file = site_config.config_file
except ImportError:
site_config_file = None

if os.getenv("ERT_SHARE_PATH"):
ert_share_path = os.getenv("ERT_SHARE_PATH")
else:
# If the ERT_SHARE_PATH variable is not set we try to use the
# source location relative to the location of the current file;
# assuming we are in the source directory. Will not work if we are
# in an arbitrary build directory.
ert_share_path = os.path.realpath( os.path.join( os.path.dirname( os.path.abspath( __file__)) , "../../../share"))

ert_gui.widgets.util.img_prefix = ert_share_path + "/gui/img/"

from ert_gui.newconfig import NewConfigurationDialog

Expand Down Expand Up @@ -174,6 +189,10 @@ def main(argv):
app.processEvents()

strict = True

if os.getenv("ERT_SITE_CONFIG"):
site_config_file = os.getenv("ERT_SITE_CONFIG")

site_config = os.getenv("ERT_SITE_CONFIG")
if len(argv) == 1:
print("-----------------------------------------------------------------")
Expand All @@ -200,17 +219,18 @@ def main(argv):
dbase_type = new_configuration_dialog.getDBaseType()
num_realizations = new_configuration_dialog.getNumberOfRealizations()
storage_path = new_configuration_dialog.getStoragePath()

EnKFMain.createNewConfig(enkf_config, storage_path, first_case_name, dbase_type, num_realizations)
strict = False

ert = Ert(EnKFMain(enkf_config, site_config=site_config, strict=strict))
ert = Ert(EnKFMain(enkf_config, site_config=site_config_file, strict=strict))
ErtConnector.setErt(ert.ert())


splash.showMessage("Creating GUI...", Qt.AlignLeft, Qt.white)
app.processEvents()

ert = Ert(EnKFMain(enkf_config, site_config = site_config_file, strict=strict))
ErtConnector.setErt(ert.ert())

window = GertMainWindow()
window.setWidget(SimulationPanel())
Expand Down
1 change: 1 addition & 0 deletions devel/python/python/ert_gui/site_config.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config_file = "${SITE_CONFIG_FILE}"

0 comments on commit f56eb56

Please sign in to comment.