def _post_initial(self, msg): os_info = read_os_release() _, _, release, _, _ = os.uname() python_vs, _ = sys_version.split("\n") ecl_v = EclVersion() res_v = ResVersion() logged_fields = { "status": "init", "python_sys_path": list(map(pad_nonexisting, sys.path)), "pythonpath": list( map(pad_nonexisting, os.environ.get("PYTHONPATH", "").split(":"))), "res_version": res_v.versionString(), "ecl_version": ecl_v.versionString(), "LSB_ID": os_info.get("LSB_ID", ""), "LSB_VERSION_ID": os_info.get("LSB_VERSION_ID", ""), "python_version": python_vs, "kernel_version": release, } job_list = [j.name() for j in msg.jobs] logged_fields.update({"jobs": job_list}) self._post_message(msg.timestamp, extra_fields=logged_fields)
def __init__(self, module_file="jobs.py", json_file="jobs.json", error_url=None, log_url=None): self._job_map = {} self.simulation_id = "" self.ert_pid = "" self._log_url = log_url if log_url is None: self._log_url = error_url self._data_root = None if json_file is not None and os.path.isfile(json_file): self._loadJson(json_file) else: self._loadModule(module_file) self.start_time = dt.now() self.max_runtime = 0 # This option is currently sleeping self.short_sleep = 2 # Sleep between status checks self.node = socket.gethostname() pw_entry = pwd.getpwuid(os.getuid()) self.user = pw_entry.pw_name os_info = _read_os_release() _, _, release, _, _ = os.uname() python_vs, _ = sys_version.split('\n') ecl_v = EclVersion() res_v = ResVersion() logged_fields = { "status": "init", "python_sys_path": map(pad_nonexisting, sys.path), "pythonpath": map(pad_nonexisting, os.environ.get('PYTHONPATH', '').split(':')), "res_version": res_v.versionString(), "ecl_version": ecl_v.versionString(), "LSB_ID": os_info.get('LSB_ID', ''), "LSB_VERSION_ID": os_info.get('LSB_VERSION_ID', ''), "python_version": python_vs, "kernel_version": release, } logged_fields.update({"jobs": self._job_map.values()}) self.postMessage(extra_fields=logged_fields) cond_unlink("EXIT") cond_unlink(self.EXIT_file) cond_unlink(self.STATUS_file) cond_unlink(self.OK_file) self.initStatusFile() if self._data_root: os.environ["DATA_ROOT"] = self._data_root self.information = logged_fields
def __init__(self, parent): super(Debug, self).__init__("debug", parent) self.addShellFunction(name="site_config", function=Debug.siteConfig, help_message="Show the path to the current site_config") self.addShellFunction(name="version", function=Debug.version, help_message="Show the internalized ert version number") self.addShellFunction(name="timestamp", function=Debug.timestamp, help_message="Show the build timestamp") self.addShellFunction(name="git_commit", function=Debug.gitCommit, help_message="Show the git commit") self.addShellFunction(name="info", function=Debug.info, help_message="Shows site_config, version, timestamp and Git Commit") self.addShellFunction(name="last_plugin_result", function=Debug.lastPluginResult, help_message="Shows the last plugin result.") self.addShellFunction(name="eval", function=Debug.eval, help_arguments="<Python expression>", help_message="Evaluate a Python expression. The last plugin result is defined as: x") self.shellContext()["debug"] = self self.__last_plugin_result = None self.__local_variables = {} self.__version = EclVersion( )
class Debug(ErtShellCollection): def __init__(self, parent): super(Debug, self).__init__("debug", parent) self.addShellFunction(name="site_config", function=Debug.siteConfig, help_message="Show the path to the current site_config") self.addShellFunction(name="version", function=Debug.version, help_message="Show the internalized ert version number") self.addShellFunction(name="timestamp", function=Debug.timestamp, help_message="Show the build timestamp") self.addShellFunction(name="git_commit", function=Debug.gitCommit, help_message="Show the git commit") self.addShellFunction(name="info", function=Debug.info, help_message="Shows site_config, version, timestamp and Git Commit") self.addShellFunction(name="last_plugin_result", function=Debug.lastPluginResult, help_message="Shows the last plugin result.") self.addShellFunction(name="eval", function=Debug.eval, help_arguments="<Python expression>", help_message="Evaluate a Python expression. The last plugin result is defined as: x") self.shellContext()["debug"] = self self.__last_plugin_result = None self.__local_variables = {} self.__version = EclVersion( ) def setLastPluginResult(self, result): self.__last_plugin_result = result @assertConfigLoaded def siteConfig(self, line): print("Site Config: %s" % self.ert().siteConfig().getLocation()) def version(self, line): print("Version: %s" % self.__version.versionString()) def timestamp(self, line): print("Timestamp: %s" % self.__version.getBuildTime()) def gitCommit(self, line): print("Git Commit: %s" % self.__version.getGitCommit(True)) @assertConfigLoaded def info(self, line): print("Site Config: %s" % self.ert().siteConfig().getLocation()) print("Version: %s" % self.__version.versionString()) print("Timestamp: %s" % self.__version.getBuildTime()) print("Git Commit: %s" % self.__version.getGitCommit(True)) def lastPluginResult(self, line): print("Last plugin result: %s" % self.__last_plugin_result) def eval(self, line): line = line.strip() if len(line) > 0: self.__local_variables["x"] = self.__last_plugin_result try: exec(line, self.__local_variables) except Exception as e: print("Error: The expression caused an exception!") print(e) else: print("Error: A python expression is required!")