# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
-PROJECT(Salome_SALOME C CXX)
+PROJECT(Salome_SALOME_Profile C CXX)
# Ensure a proper linker behavior:
CMAKE_POLICY(SET CMP0003 NEW)
SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH "Install path: SALOME Python scripts")
# Specific to SALOME:
-SET(SALOME_SALOME_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/salome" CACHE PATH "Install path: SALOME SALOME specific data")
-SET(SALOME_SALOME_INSTALL_DOC_GUI "${SALOME_INSTALL_DOC}/gui/${PROJECT_NAME_UC}" CACHE PATH "Install path: SALOME SALOME gui documentation")
-SET(SALOME_SALOME_HTML_STATIC_PATH "${SALOME_SALOME_INSTALL_DOC_GUI}/_static" CACHE PATH "Install path: SALOME SALOME html static data")
+SET(SALOME_SALOME_PROFILE_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/salome_profile" CACHE PATH "Install path: SALOME SALOME specific data")
+SET(SALOME_SALOME_PROFILE_INSTALL_DOC_GUI "${SALOME_INSTALL_DOC}/gui/${PROJECT_NAME_UC}" CACHE PATH "Install path: SALOME SALOME gui documentation")
+SET(SALOME_SALOME_PROFILE_HTML_STATIC_PATH "${SALOME_SALOME_PROFILE_INSTALL_DOC_GUI}/_static" CACHE PATH "Install path: SALOME SALOME html static data")
MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_PYTHON)
# Sources
# ========
-#ADD_SUBDIRECTORY( src ) # JCC 29/08/2017 #spns 8090
+ADD_SUBDIRECTORY( src )
ADD_SUBDIRECTORY( resources )
-#ADD_SUBDIRECTORY( doc )
+ADD_SUBDIRECTORY( doc )
# Additional files
# ================
SET(_salome_context_BASHRC
${KERNEL_ROOT_DIR}/bin/salome/appliskel/.bashrc
)
-FILE(TO_CMAKE_PATH ${CMAKE_INSTALL_PREFIX} _SALOME_ROOT_DIR)
-SALOME_INSTALL_SCRIPTS("${_salome_context_BASHRC}" ${_SALOME_ROOT_DIR})
+FILE(TO_CMAKE_PATH ${CMAKE_INSTALL_PREFIX} _SALOME_PROFILE_ROOT_DIR)
+SALOME_INSTALL_SCRIPTS("${_salome_context_BASHRC}" ${_SALOME_PROFILE_ROOT_DIR})
--- /dev/null
+# Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+SALOME_CONFIGURE_FILE(conf.py.in conf.py)
+
+SET(_cmd_options -c ${CMAKE_CURRENT_BINARY_DIR} -b html -d doctrees -D latex_paper_size=a4 ${CMAKE_CURRENT_SOURCE_DIR} html)
+SALOME_GENERATE_ENVIRONMENT_SCRIPT(_cmd env_script "${SPHINX_EXECUTABLE}" "${_cmd_options}")
+
+ADD_CUSTOM_TARGET(html_docs COMMAND ${_cmd})
+
+INSTALL(CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target html_docs)")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ DESTINATION ${SALOME_SALOME_PROFILE_INSTALL_DOC_GUI})
+
+SET(make_clean_files html doctrees)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${make_clean_files}")
--- /dev/null
+This directory contains the sources of SALOME's documentation
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# The contents of this file are pickled, so don't put values in the namespace
+# that aren't pickleable (module imports are okay, they're removed automatically).
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If your extensions are in another directory, add it here. If the directory
+# is relative to the documentation root, use os.path.abspath to make it
+# absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# General configuration
+# ---------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = 'salome'
+copyright = '2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE, ASTEK INDUSTRIE'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '@SALOMESALOME_MAJOR_VERSION@.@SALOMESALOME_MINOR_VERSION@'
+# The full version, including alpha/beta/rc tags.
+release = '@SALOMESALOME_VERSION@'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['.build','ref','images','CVS']
+
+# A list of glob-style patterns that should be excluded when looking for source
+# files. They are matched against the source file names relative to the
+# source directory, using slashes as directory separators on all platforms.
+exclude_patterns = ['**/CVS']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+
+# Options for HTML output
+# -----------------------
+
+# The theme to use for HTML and HTML Help pages. Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = '@SPHINX_THEME@'
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['@SALOME_SALOME_PROFILE_INSTALL_DOC_GUI@/_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+html_use_modindex = False
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, the reST sources are included in the HTML build as _sources/<name>.
+#html_copy_source = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'salomedoc'
+
+
+# Options for LaTeX output
+# ------------------------
+
+# The paper size ('letter' or 'a4').
+latex_paper_size = 'a4'
+
+# The font size ('10pt', '11pt' or '12pt').
+latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, document class [howto/manual]).
+latex_documents = [
+ ('index', 'salome.tex', 'SALOME User Documentation', 'A. Ribes', 'manual')
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+latex_use_modindex = False
--- /dev/null
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SALOME's documentation
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+Outline
+===========================
+
+
+.. toctree::
+ :maxdepth: 1
+
+ intro.rst
+ link.rst
--- /dev/null
+Introduction
+==========================================
+
+Welcome to SALOME's documentation!
--- /dev/null
+Link
+==========================================
+
+A sample pdf file can be found :download:`here <../resources/doc/sample.pdf>`
)
# --- rules ---
-INSTALL(FILES ${SALOME_PROFILE_RESOURCES_FILES} DESTINATION ${SALOME_SALOME_INSTALL_RES_DATA})
+INSTALL(FILES ${SALOME_PROFILE_RESOURCES_FILES} DESTINATION ${SALOME_SALOME_PROFILE_INSTALL_RES_DATA})
# --- config ---
-SALOME_CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/SalomeApp.xml.in ${CMAKE_CURRENT_BINARY_DIR}/SalomeApp.xml INSTALL ${SALOME_SALOME_INSTALL_RES_DATA})
+SALOME_CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/SalomeApp.xml.in ${CMAKE_CURRENT_BINARY_DIR}/SalomeApp.xml INSTALL ${SALOME_SALOME_PROFILE_INSTALL_RES_DATA})
# --- sub-directories ---
ADD_SUBDIRECTORY( doc )
<parameter name="standalone" value=""/>
</section>
<section name="splash">
- <parameter name="image" value="%SALOME_ROOT_DIR%/share/salome/resources/salome/splash.png"/>
+ <parameter name="image" value="%SALOME_ROOT_DIR%/share/salome/resources/salome_profile/splash.png"/>
<parameter name="text_colors" value="#ffffff|#000000"/>
<parameter name="show_percents" value="yes"/>
<parameter name="show_progress" value="yes"/>
<parameter name="font" value="Xirod,12,normal"/>
</section>
<section name="resources">
- <parameter name="LightApp" value="%SALOME_ROOT_DIR%/share/salome/resources/salome"/>
+ <parameter name="LightApp" value="%SALOME_ROOT_DIR%/share/salome/resources/salome_profile"/>
</section>
</document>
sample.pdf
)
-INSTALL(FILES ${_bin_DOCUMENTS} DESTINATION ${SALOME_SALOME_INSTALL_DOC_GUI})
+INSTALL(FILES ${_bin_DOCUMENTS} DESTINATION ${SALOME_SALOME_PROFILE_INSTALL_DOC_GUI})
--- /dev/null
+# Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# --- sub-directories ---
+ADD_SUBDIRECTORY( tests )
+ADD_SUBDIRECTORY( resources )
--- /dev/null
+# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import ConfigParser
+import os
+import logging
+import re
+from io import StringIO
+import subprocess
+from salomeContextUtils import SalomeContextException #@UnresolvedImport
+
+logging.basicConfig()
+logConfigParser = logging.getLogger(__name__)
+
+ADD_TO_PREFIX = 'ADD_TO_'
+UNSET_KEYWORD = 'UNSET'
+
+
+def _expandSystemVariables(key, val):
+ expandedVal = os.path.expandvars(val) # expand environment variables
+ # Search for not expanded variables (i.e. non-existing environment variables)
+ pattern = re.compile('\${ ( [^}]* ) }', re.VERBOSE) # string enclosed in ${ and }
+ expandedVal = pattern.sub(r'', expandedVal) # remove matching patterns
+
+ if not "DLIM8VAR" in key: # special case: DISTENE licence key can contain double clons (::)
+ expandedVal = _trimColons(expandedVal)
+ return expandedVal
+#
+
+# :TRICKY: So ugly solution...
+class MultiOptSafeConfigParser(ConfigParser.SafeConfigParser):
+ def __init__(self):
+ ConfigParser.SafeConfigParser.__init__(self)
+
+ # copied from python 2.6.8 Lib.ConfigParser.py
+ # modified (see code comments) to handle duplicate keys
+ def _read(self, fp, fpname):
+ """Parse a sectioned setup file.
+
+ The sections in setup file contains a title line at the top,
+ indicated by a name in square brackets (`[]'), plus key/value
+ options lines, indicated by `name: value' format lines.
+ Continuations are represented by an embedded newline then
+ leading whitespace. Blank lines, lines beginning with a '#',
+ and just about everything else are ignored.
+ """
+ cursect = None # None, or a dictionary
+ optname = None
+ lineno = 0
+ e = None # None, or an exception
+ while True:
+ line = fp.readline()
+ if not line:
+ break
+ lineno = lineno + 1
+ # comment or blank line?
+ if line.strip() == '' or line[0] in '#;':
+ continue
+ if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR":
+ # no leading whitespace
+ continue
+ # continuation line?
+ if line[0].isspace() and cursect is not None and optname:
+ value = line.strip()
+ if value:
+ cursect[optname].append(value)
+ # a section header or option header?
+ else:
+ # is it a section header?
+ mo = self.SECTCRE.match(line)
+ if mo:
+ sectname = mo.group('header')
+ if sectname in self._sections:
+ cursect = self._sections[sectname]
+ elif sectname == ConfigParser.DEFAULTSECT:
+ cursect = self._defaults
+ else:
+ cursect = self._dict()
+ cursect['__name__'] = sectname
+ self._sections[sectname] = cursect
+ # So sections can't start with a continuation line
+ optname = None
+ # no section header in the file?
+ elif cursect is None:
+ raise ConfigParser.MissingSectionHeaderError(fpname, lineno, line)
+ # an option line?
+ else:
+ mo = self.OPTCRE.match(line)
+ if mo:
+ optname, vi, optval = mo.group('option', 'vi', 'value')
+ optname = self.optionxform(optname.rstrip())
+ # This check is fine because the OPTCRE cannot
+ # match if it would set optval to None
+ if optval is not None:
+ if vi in ('=', ':') and ';' in optval:
+ # ';' is a comment delimiter only if it follows
+ # a spacing character
+ pos = optval.find(';')
+ if pos != -1 and optval[pos-1].isspace():
+ optval = optval[:pos]
+ optval = optval.strip()
+ # ADD THESE LINES
+ splittedComments = optval.split('#')
+ s = _expandSystemVariables(optname, splittedComments[0])
+ optval = s.strip().strip("'").strip('"')
+ #if len(splittedComments) > 1:
+ # optval += " #" + " ".join(splittedComments[1:])
+ # END OF ADD
+ # allow empty values
+ if optval == '""':
+ optval = ''
+ # REPLACE following line (original):
+ #cursect[optname] = [optval]
+ # BY THESE LINES:
+ # Check if this optname already exists
+ if (optname in cursect) and (cursect[optname] is not None):
+ cursect[optname][0] += ','+optval
+ else:
+ cursect[optname] = [optval]
+ # END OF SUBSTITUTION
+ else:
+ # valueless option handling
+ cursect[optname] = optval
+ else:
+ # a non-fatal parsing error occurred. set up the
+ # exception but keep going. the exception will be
+ # raised at the end of the file and will contain a
+ # list of all bogus lines
+ if not e:
+ e = ConfigParser.ParsingError(fpname)
+ e.append(lineno, repr(line))
+ # if any parsing errors occurred, raise an exception
+ if e:
+ raise e
+
+ # join the multi-line values collected while reading
+ all_sections = [self._defaults]
+ all_sections.extend(self._sections.values())
+ for options in all_sections:
+ for name, val in options.items():
+ if isinstance(val, list):
+ options[name] = '\n'.join(val)
+ #
+
+
+# Parse configuration file
+# Input: filename, and a list of reserved keywords (environment variables)
+# Output: a list of pairs (variable, value), and a dictionary associating a list of user-defined values to each reserved keywords
+# Note: Does not support duplicate keys in a same section
+def parseConfigFile(filename, reserved = None):
+ if reserved is None:
+ reserved = []
+ config = MultiOptSafeConfigParser()
+ config.optionxform = str # case sensitive
+
+ # :TODO: test file existence
+
+ # Read config file
+ try:
+ config.read(filename)
+ except ConfigParser.MissingSectionHeaderError:
+ logConfigParser.error("No section found in file: %s"%(filename))
+ return []
+
+ try:
+ return __processConfigFile(config, reserved, filename)
+ except ConfigParser.InterpolationMissingOptionError, e:
+ msg = "A variable may be undefined in SALOME context file: %s\nParser error is: %s\n"%(filename, e)
+ raise SalomeContextException(msg)
+#
+
+def __processConfigFile(config, reserved = None, filename="UNKNOWN FILENAME"):
+ # :TODO: may detect duplicated variables in the same section (raise a warning)
+ # or even duplicate sections
+
+ if reserved is None:
+ reserved = []
+ unsetVariables = []
+ outputVariables = []
+ # Get raw items for each section, and make some processing for environment variables management
+ reservedKeys = [ADD_TO_PREFIX+str(x) for x in reserved] # produce [ 'ADD_TO_reserved_1', 'ADD_TO_reserved_2', ..., ADD_TO_reserved_n ]
+ reservedValues = dict([str(i),[]] for i in reserved) # create a dictionary in which keys are the 'ADD_TO_reserved_i' and associated values are empty lists: { 'reserved_1':[], 'reserved_2':[], ..., reserved_n:[] }
+ sections = config.sections()
+ for section in sections:
+ entries = config.items(section, raw=False) # use interpolation
+ if len(entries) == 0: # empty section
+ logConfigParser.warning("Empty section: %s in file: %s"%(section, filename))
+ pass
+ for key,val in entries:
+ if key in reserved:
+ logConfigParser.error("Invalid use of reserved variable: %s in file: %s"%(key, filename))
+ elif key == UNSET_KEYWORD:
+ unsetVariables += val.replace(',', ' ').split()
+ else:
+ expandedVal = _expandSystemVariables(key, val)
+
+ if key in reservedKeys:
+ shortKey = key[len(ADD_TO_PREFIX):]
+ vals = expandedVal.split(',')
+ reservedValues[shortKey] += vals
+ # remove left&right spaces on each element
+ vals = [v.strip(' \t\n\r') for v in vals]
+ else:
+ outputVariables.append((key, expandedVal))
+ pass
+ pass # end if key
+ pass # end for key,val
+ pass # end for section
+
+ # remove duplicate values
+ outVars = []
+ for (var, values) in outputVariables:
+ vals = values.split(',')
+ vals = list(set(vals))
+ outVars.append((var, ','.join(vals)))
+
+ return unsetVariables, outVars, reservedValues
+#
+
+def _trimColons(var):
+ v = var
+ # Remove leading and trailing colons (:)
+ pattern = re.compile('^:+ | :+$', re.VERBOSE)
+ v = pattern.sub(r'', v) # remove matching patterns
+ # Remove multiple colons
+ pattern = re.compile('::+', re.VERBOSE)
+ v = pattern.sub(r':', v) # remove matching patterns
+ return v
+#
--- /dev/null
+# Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+INCLUDE(UseQtExt)
+
+# --- resources ---
+
+# resource files / to be processed by lrelease
+SET(_ts_RESOURCES
+ LightApp_images.ts
+ LightApp_msg_en.ts
+ LightApp_msg_fr.ts
+ LightApp_msg_ja.ts
+)
+
+# --- rules ---
+
+QT_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${SALOME_SALOME_PROFILE_INSTALL_RES_DATA}")
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+<context>
+ <name>@default</name>
+ <message>
+ <source>APP_DEFAULT_ICO</source>
+ <translation>app_icon.png</translation>
+ </message>
+ <message>
+ <source>ICO_ABOUT</source>
+ <translation>icon_about.png</translation>
+ </message>
+ <message>
+ <source>ABOUT</source>
+ <translation>about.png</translation>
+ </message>
+ <message>
+ <source>APP_BASE_LOGO</source>
+ <translation>app_logo.png</translation>
+ </message>
+</context>
+</TS>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+<context>
+ <name>@default</name>
+ <message>
+ <source>ABOUT_COPYRIGHT</source>
+ <translation>Copyright (C)</translation>
+ </message>
+ <message>
+ <source>ABOUT_CAPTION</source>
+ <translation>About SALOME</translation>
+ </message>
+ <message>
+ <source>APP_NAME</source>
+ <translation>SALOME </translation>
+ </message>
+ <message>
+ <source>APP_VERSION</source>
+ <translation>V8.3.0</translation>
+ </message>
+ <message>
+ <source>ABOUT_LICENSE</source>
+ <translation>License description</translation>
+ </message>
+ <message>
+ <source>ABOUT_VERSION</source>
+ <translation>Version 8.3.0</translation>
+ </message>
+ <message>
+ <source>ABOUT_TITLE</source>
+ <translation>SALOME</translation>
+ </message>
+</context>
+</TS>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="fr_FR">
+<context>
+ <name>@default</name>
+ <message>
+ <source>ABOUT_COPYRIGHT</source>
+ <translation>Copyright (C)</translation>
+ </message>
+ <message>
+ <source>ABOUT_CAPTION</source>
+ <translation>A propos de SALOME</translation>
+ </message>
+ <message>
+ <source>APP_NAME</source>
+ <translation>SALOME </translation>
+ </message>
+ <message>
+ <source>APP_VERSION</source>
+ <translation>V8.3.0</translation>
+ </message>
+ <message>
+ <source>ABOUT_LICENSE</source>
+ <translation>Description de la licence</translation>
+ </message>
+ <message>
+ <source>ABOUT_VERSION</source>
+ <translation>Version 8.3.0</translation>
+ </message>
+ <message>
+ <source>ABOUT_TITLE</source>
+ <translation>SALOME</translation>
+ </message>
+</context>
+</TS>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
+ <context>
+ <name>@default</name>
+ <message>
+ <source>ABOUT_COPYRIGHT</source>
+ <translation>Copyright (C)</translation>
+ </message>
+ <message>
+ <source>ABOUT_CAPTION</source>
+ <translation>About SALOME</translation>
+ </message>
+ <message>
+ <source>APP_NAME</source>
+ <translation>SALOME </translation>
+ </message>
+ <message>
+ <source>APP_VERSION</source>
+ <translation>V8.3.0</translation>
+ </message>
+ <message>
+ <source>ABOUT_LICENSE</source>
+ <translation>License description</translation>
+ </message>
+ <message>
+ <source>ABOUT_VERSION</source>
+ <translation>Version 8.3.0</translation>
+ </message>
+ <message>
+ <source>ABOUT_TITLE</source>
+ <translation>SALOME</translation>
+ </message>
+ </context>
+</TS>
--- /dev/null
+# Copyright (C) 2013-2017 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+import sys
+import logging
+import ConfigParser
+
+from parseConfigFile import parseConfigFile
+
+import tempfile
+import pickle
+import subprocess
+import platform
+
+from salomeContextUtils import SalomeContextException
+
+def usage():
+ msg = '''\
+Usage: salome [command] [options] [--config=<file,folder,...>]
+
+Commands:
+=========
+ start Start a new SALOME instance.
+ context Initialize SALOME context. Current environment is extended.
+ shell Initialize SALOME context, attached to the last created SALOME
+ instance if any, and executes scripts passed as command arguments.
+ User works in a Shell terminal. SALOME environment is set but
+ application is not started.
+ connect Connect a Python console to the active SALOME instance.
+ kill <port(s)> Terminate SALOME instances running on given ports for current user.
+ Port numbers must be separated by blank characters.
+ killall Terminate *all* SALOME running instances for current user.
+ Do not start a new one.
+ test Run SALOME tests.
+ info Display some information about SALOME.
+ doc <module(s)> Show online module documentation (if available).
+ Module names must be separated by blank characters.
+ help Show this message.
+
+If no command is given, default is start.
+
+Command options:
+================
+ Use salome <command> --help to show help on command. Available for the
+ following commands: start, shell, connect, test, info.
+
+--config=<file,folder,...>
+==========================
+ Initialize SALOME context from a list of context files and/or a list
+ of folders containing context files. The list is comma-separated, whithout
+ any blank characters.
+'''
+
+ print msg
+#
+
+"""
+The SalomeContext class in an API to configure SALOME context then
+start SALOME using a single python command.
+
+"""
+class SalomeContext:
+ """
+ Initialize context from a list of configuration files
+ identified by their names.
+ These files should be in appropriate .cfg format.
+ """
+ def __init__(self, configFileNames=0):
+ self.getLogger().setLevel(logging.INFO)
+ #it could be None explicitely (if user use multiples setVariable...for standalone)
+ if configFileNames is None:
+ return
+ configFileNames = configFileNames or []
+ if len(configFileNames) == 0:
+ raise SalomeContextException("No configuration files given")
+
+ reserved=['PATH', 'DYLD_FALLBACK_LIBRARY_PATH', 'DYLD_LIBRARY_PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'MANPATH', 'PV_PLUGIN_PATH', 'INCLUDE', 'LIBPATH', 'SALOME_PLUGINS_PATH', 'LIBRARY_PATH']
+ for filename in configFileNames:
+ basename, extension = os.path.splitext(filename)
+ if extension == ".cfg":
+ self.__setContextFromConfigFile(filename, reserved)
+ else:
+ self.getLogger().error("Unrecognized extension for configuration file: %s", filename)
+ #
+
+ def __loadMPI(self, module_name):
+ print "Trying to load MPI module: %s..."%module_name,
+ try:
+ out, err = subprocess.Popen(["modulecmd", "python", "load", module_name], stdout=subprocess.PIPE).communicate()
+ exec out # define specific environment variables
+ print " OK"
+ except:
+ print " ** Failed **"
+ pass
+ #
+
+ def runSalome(self, args):
+ import os
+ # Run this module as a script, in order to use appropriate Python interpreter
+ # according to current path (initialized from context files).
+ mpi_module_option = "--with-mpi-module="
+ mpi_module = [x for x in args if x.startswith(mpi_module_option)]
+ if mpi_module:
+ mpi_module = mpi_module[0][len(mpi_module_option):]
+ self.__loadMPI(mpi_module)
+ args = [x for x in args if not x.startswith(mpi_module_option)]
+ else:
+ mpi_module = os.getenv("SALOME_MPI_MODULE_NAME", None)
+ if mpi_module:
+ self.__loadMPI(mpi_module)
+
+ absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','')
+ env_copy = os.environ.copy()
+ proc = subprocess.Popen(['python', os.path.join(absoluteAppliPath,"bin","salome","salomeContext.py"), pickle.dumps(self), pickle.dumps(args)], shell=False, close_fds=True, env=env_copy)
+ out, err = proc.communicate()
+ return out, err, proc.returncode
+ #
+
+ """Append value to PATH environment variable"""
+ def addToPath(self, value):
+ self.addToVariable('PATH', value)
+ #
+
+ """Append value to LD_LIBRARY_PATH environment variable"""
+ def addToLdLibraryPath(self, value):
+ if platform.system() == 'Windows':
+ self.addToVariable('PATH', value)
+ elif platform.system() == 'Darwin':
+ if "LAPACK" in value:
+ self.addToVariable('DYLD_FALLBACK_LIBRARY_PATH', value)
+ else:
+ self.addToVariable('DYLD_LIBRARY_PATH', value)
+ else:
+ self.addToVariable('LD_LIBRARY_PATH', value)
+ #
+
+ """Append value to DYLD_LIBRARY_PATH environment variable"""
+ def addToDyldLibraryPath(self, value):
+ self.addToVariable('DYLD_LIBRARY_PATH', value)
+ #
+
+ """Append value to PYTHONPATH environment variable"""
+ def addToPythonPath(self, value):
+ self.addToVariable('PYTHONPATH', value)
+ #
+
+ """Set environment variable to value"""
+ def setVariable(self, name, value, overwrite=False):
+ env = os.getenv(name, '')
+ if env and not overwrite:
+ self.getLogger().error("Environment variable already existing (and not overwritten): %s=%s", name, value)
+ return
+
+ if env:
+ self.getLogger().debug("Overwriting environment variable: %s=%s", name, value)
+
+ value = os.path.expandvars(value) # expand environment variables
+ self.getLogger().debug("Set environment variable: %s=%s", name, value)
+ os.environ[name] = value
+ #
+
+ """Unset environment variable"""
+ def unsetVariable(self, name):
+ if os.environ.has_key(name):
+ del os.environ[name]
+ #
+
+ """Append value to environment variable"""
+ def addToVariable(self, name, value, separator=os.pathsep):
+ if value == '':
+ return
+
+ value = os.path.expandvars(value) # expand environment variables
+ self.getLogger().debug("Add to %s: %s", name, value)
+ env = os.getenv(name, None)
+ if env is None:
+ os.environ[name] = value
+ else:
+ os.environ[name] = value + separator + env
+ #
+
+ ###################################
+ # This begins the private section #
+ ###################################
+
+ def __parseArguments(self, args):
+ if len(args) == 0 or args[0].startswith("-"):
+ return None, args
+
+ command = args[0]
+ options = args[1:]
+
+ availableCommands = {
+ 'start' : '_runAppli',
+ 'context' : '_setContext',
+ 'shell' : '_runSession',
+ 'connect' : '_runConsole',
+ 'kill' : '_kill',
+ 'killall' : '_killAll',
+ 'test' : '_runTests',
+ 'info' : '_showInfo',
+ 'doc' : '_showDoc',
+ 'help' : '_usage',
+ 'coffee' : '_makeCoffee',
+ 'car' : '_getCar',
+ }
+
+ if not command in availableCommands.keys():
+ command = "start"
+ options = args
+
+ return availableCommands[command], options
+ #
+
+ """
+ Run SALOME!
+ Args consist in a mandatory command followed by optionnal parameters.
+ See usage for details on commands.
+ """
+ def _startSalome(self, args):
+ import os
+ import sys
+ try:
+ from setenv import add_path
+ absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH')
+ path = os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome"))
+ add_path(path, "PYTHONPATH")
+ path = os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome", "appliskel"))
+ add_path(path, "PYTHONPATH")
+
+ except:
+ pass
+
+ command, options = self.__parseArguments(args)
+ sys.argv = options
+
+ if command is None:
+ if args and args[0] in ["-h","--help","help"]:
+ usage()
+ sys.exit(0)
+ # try to default to "start" command
+ command = "_runAppli"
+
+ try:
+ res = getattr(self, command)(options) # run appropriate method
+ return res or (None, None)
+ except SystemExit, returncode:
+ if returncode != 0:
+ self.getLogger().error("SystemExit %s in method %s.", returncode, command)
+ sys.exit(returncode)
+ except StandardError:
+ self.getLogger().error("Unexpected error:")
+ import traceback
+ traceback.print_exc()
+ sys.exit(1)
+ except SalomeContextException, e:
+ self.getLogger().error(e)
+ sys.exit(1)
+ #
+
+ def __setContextFromConfigFile(self, filename, reserved=None):
+ if reserved is None:
+ reserved = []
+ try:
+ unsetVars, configVars, reservedDict = parseConfigFile(filename, reserved)
+ except SalomeContextException, e:
+ msg = "%s"%e
+ self.getLogger().error(msg)
+ sys.exit(1)
+
+ # unset variables
+ for var in unsetVars:
+ self.unsetVariable(var)
+
+ # set context
+ for reserved in reservedDict:
+ a = filter(None, reservedDict[reserved]) # remove empty elements
+ a = [ os.path.realpath(x) for x in a ]
+ reformattedVals = os.pathsep.join(a)
+ if reserved in ["INCLUDE", "LIBPATH"]:
+ self.addToVariable(reserved, reformattedVals, separator=' ')
+ else:
+ self.addToVariable(reserved, reformattedVals)
+ pass
+
+ for key,val in configVars:
+ self.setVariable(key, val, overwrite=True)
+ pass
+
+ pythonpath = os.getenv('PYTHONPATH','').split(os.pathsep)
+ pythonpath = [ os.path.realpath(x) for x in pythonpath ]
+ sys.path[:0] = pythonpath
+ #
+
+ def _runAppli(self, args=None):
+ if args is None:
+ args = []
+ # Initialize SALOME environment
+ sys.argv = ['runSalome'] + args
+ import setenv
+ setenv.main(True, exeName="salome start")
+
+ import runSalome
+ runSalome.runSalome()
+ #
+
+ def _setContext(self, args=None):
+ salome_context_set = os.getenv("SALOME_CONTEXT_SET")
+ if salome_context_set:
+ print "***"
+ print "*** SALOME context has already been set."
+ print "*** Enter 'exit' (only once!) to leave SALOME context."
+ print "***"
+ return
+
+ os.environ["SALOME_CONTEXT_SET"] = "yes"
+ print "***"
+ print "*** SALOME context is now set."
+ print "*** Enter 'exit' (only once!) to leave SALOME context."
+ print "***"
+
+ cmd = ["/bin/bash"]
+ proc = subprocess.Popen(cmd, shell=False, close_fds=True)
+ return proc.communicate()
+ #
+
+ def _runSession(self, args=None):
+ if args is None:
+ args = []
+ sys.argv = ['runSession'] + args
+ import runSession
+ params, args = runSession.configureSession(args, exe="salome shell")
+
+ sys.argv = ['runSession'] + args
+ import setenv
+ setenv.main(True)
+
+ return runSession.runSession(params, args)
+ #
+
+ def _runConsole(self, args=None):
+ if args is None:
+ args = []
+ # Initialize SALOME environment
+ sys.argv = ['runConsole']
+ import setenv
+ setenv.main(True)
+
+ import runConsole
+ return runConsole.connect(args)
+ #
+
+ def _kill(self, args=None):
+ if args is None:
+ args = []
+ ports = args
+ if not ports:
+ print "Port number(s) not provided to command: salome kill <port(s)>"
+ return
+
+ from multiprocessing import Process
+ from killSalomeWithPort import killMyPort
+ import tempfile
+ for port in ports:
+ with tempfile.NamedTemporaryFile():
+ p = Process(target = killMyPort, args=(port,))
+ p.start()
+ p.join()
+ pass
+ #
+
+ def _killAll(self, unused=None):
+ try:
+ import PortManager # mandatory
+ from multiprocessing import Process
+ from killSalomeWithPort import killMyPort
+ ports = PortManager.getBusyPorts()['this']
+
+ if ports:
+ import tempfile
+ for port in ports:
+ with tempfile.NamedTemporaryFile():
+ p = Process(target = killMyPort, args=(port,))
+ p.start()
+ p.join()
+ except ImportError:
+ # :TODO: should be declared obsolete
+ from killSalome import killAllPorts
+ killAllPorts()
+ pass
+ #
+
+ def _runTests(self, args=None):
+ if args is None:
+ args = []
+ sys.argv = ['runTests']
+ import setenv
+ setenv.main(True)
+
+ import runTests
+ return runTests.runTests(args, exe="salome test")
+ #
+
+ def _showSoftwareVersions(self, softwares=None):
+ config = ConfigParser.SafeConfigParser()
+ absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH')
+ filename = os.path.join(absoluteAppliPath, "sha1_collections.txt")
+ versions = {}
+ max_len = 0
+ with open(filename) as f:
+ for line in f:
+ try:
+ software, version, sha1 = line.split()
+ versions[software.upper()] = version
+ if len(software) > max_len:
+ max_len = len(software)
+ except:
+ pass
+ pass
+ pass
+ if softwares:
+ for soft in softwares:
+ if versions.has_key(soft.upper()):
+ print soft.upper().rjust(max_len), versions[soft.upper()]
+ else:
+ import collections
+ od = collections.OrderedDict(sorted(versions.items()))
+ for name, version in od.iteritems():
+ print name.rjust(max_len), versions[name]
+ pass
+
+ def _showInfo(self, args=None):
+ if args is None:
+ args = []
+
+ usage = "Usage: salome info [options]"
+ epilog = """\n
+Display some information about SALOME.\n
+Available options are:
+ -p,--ports Show the list of busy ports (running SALOME instances).
+ -s,--softwares [software(s)] Show the list and versions of SALOME softwares.
+ Software names must be separated by blank characters.
+ If no software is given, show version of all softwares.
+ -v,--version Show running SALOME version.
+ -h,--help Show this message.
+"""
+ if not args:
+ args = ["--version"]
+
+ if "-h" in args or "--help" in args:
+ print usage + epilog
+ return
+
+ if "-p" in args or "--ports" in args:
+ import PortManager
+ ports = PortManager.getBusyPorts()
+ this_ports = ports['this']
+ other_ports = ports['other']
+ if this_ports or other_ports:
+ print "SALOME instances are running on the following ports:"
+ if this_ports:
+ print " This application:", this_ports
+ else:
+ print " No SALOME instances of this application"
+ if other_ports:
+ print " Other applications:", other_ports
+ else:
+ print " No SALOME instances of other applications"
+ else:
+ print "No SALOME instances are running"
+
+ if "-s" in args or "--softwares" in args:
+ if "-s" in args:
+ index = args.index("-s")
+ else:
+ index = args.index("--softwares")
+ indexEnd=index+1
+ while indexEnd < len(args) and args[indexEnd][0] != "-":
+ indexEnd = indexEnd + 1
+ self._showSoftwareVersions(softwares=args[index+1:indexEnd])
+
+ if "-v" in args or "--version" in args:
+ print "Running with python", platform.python_version()
+ self._runAppli(["--version"])
+ #
+
+ def _showDoc(self, args=None):
+ if args is None:
+ args = []
+
+ modules = args
+ if not modules:
+ print "Module(s) not provided to command: salome doc <module(s)>"
+ return
+
+ appliPath = os.getenv("ABSOLUTE_APPLI_PATH")
+ if not appliPath:
+ raise SalomeContextException("Unable to find application path. Please check that the variable ABSOLUTE_APPLI_PATH is set.")
+ baseDir = os.path.join(appliPath, "share", "doc", "salome")
+ for module in modules:
+ docfile = os.path.join(baseDir, "gui", module.upper(), "index.html")
+ if not os.path.isfile(docfile):
+ docfile = os.path.join(baseDir, "tui", module.upper(), "index.html")
+ if not os.path.isfile(docfile):
+ docfile = os.path.join(baseDir, "dev", module.upper(), "index.html")
+ if os.path.isfile(docfile):
+ out, err = subprocess.Popen(["xdg-open", docfile]).communicate()
+ else:
+ print "Online documentation is not accessible for module:", module
+
+ def _usage(self, unused=None):
+ usage()
+ #
+
+ def _makeCoffee(self, unused=None):
+ print " ("
+ print " ) ("
+ print " ___...(-------)-....___"
+ print " .-\"\" ) ( \"\"-."
+ print " .-\'``\'|-._ ) _.-|"
+ print " / .--.| `\"\"---...........---\"\"` |"
+ print " / / | |"
+ print " | | | |"
+ print " \\ \\ | |"
+ print " `\\ `\\ | |"
+ print " `\\ `| SALOME |"
+ print " _/ /\\ 4 EVER /"
+ print " (__/ \\ <3 /"
+ print " _..---\"\"` \\ /`\"\"---.._"
+ print " .-\' \\ / \'-."
+ print " : `-.__ __.-\' :"
+ print " : ) \"\"---...---\"\" ( :"
+ print " \'._ `\"--...___...--\"` _.\'"
+ print " \\\"\"--..__ __..--\"\"/"
+ print " \'._ \"\"\"----.....______.....----\"\"\" _.\'"
+ print " `\"\"--..,,_____ _____,,..--\"\"`"
+ print " `\"\"\"----\"\"\"`"
+ print ""
+ print " SALOME is working for you; what else?"
+ print ""
+ sys.exit(0)
+ #
+
+ def _getCar(self, unused=None):
+ print " _____________"
+ print " ..---:::::::-----------. ::::;;."
+ print " .\'\"\"\"\"\"\" ;; \\ \":."
+ print " .\'\' ; \\ \"\\__."
+ print " .\' ;; ; \\\\\";"
+ print " .\' ; _____; \\\\/"
+ print " .\' :; ;\" \\ ___:\'."
+ print " .\'--........................... : = ____:\" \\ \\"
+ print " ..-\"\" \"\"\"\' o\"\"\" ; ; :"
+ print " .--\"\" .----- ..----... _.- --. ..-\" ; ; ; ;"
+ print " .\"\"_- \"--\"\"-----\'\"\" _-\" .-\"\" ; ; .-."
+ print " .\' .\' SALOME .\" .\" ; ; /. |"
+ print " /-./\' 4 EVER <3 .\" / _.. ; ; ;;;|"
+ print " : ;-.______ / _________==. /_ \\ ; ; ;;;;"
+ print " ; / | \"\"\"\"\"\"\"\"\"\"\".---.\"\"\"\"\"\"\" : /\" \". |; ; _; ;;;"
+ print " /\"-/ | / / / / ;|; ;-\" | ;\';"
+ print ":- : \"\"\"----______ / / ____. . .\"\'. ;; .-\"..T\" ."
+ print "\'. \" ___ \"\": \'\"\"\"\"\"\"\"\"\"\"\"\"\"\" . ; ; ;; ;.\" .\" \'--\""
+ print " \", __ \"\"\" \"\"---... :- - - - - - - - - \' \' ; ; ; ;;\" .\""
+ print " /. ; \"\"\"---___ ; ; ; ;|.\"\""
+ print " : \": \"\"\"----. .-------. ; ; ; ;:"
+ print " \\ \'--__ \\ \\ \\ / | ; ;;"
+ print " \'-.. \"\"\"\"---___ : .______..\\ __/..-\"\"| ; ; ;"
+ print " \"\"--.. \"\"\"--\" m l s . \". . ;"
+ print " \"\"------... ..--\"\" \" :"
+ print " \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" \\ /"
+ print " \"------\""
+ print ""
+ print " Drive your simulation properly with SALOME!"
+ print ""
+ sys.exit(0)
+ #
+
+ # Add the following two methods since logger is not pickable
+ # Ref: http://stackoverflow.com/questions/2999638/how-to-stop-attributes-from-being-pickled-in-python
+ def __getstate__(self):
+ d = dict(self.__dict__)
+ if hasattr(self, '_logger'):
+ del d['_logger']
+ return d
+ #
+ def __setstate__(self, d):
+ self.__dict__.update(d) # I *think* this is a safe way to do it
+ #
+ # Excluding self._logger from pickle operation imply using the following method to access logger
+ def getLogger(self):
+ if not hasattr(self, '_logger'):
+ self._logger = logging.getLogger(__name__)
+ #self._logger.setLevel(logging.DEBUG)
+ #self._logger.setLevel(logging.WARNING)
+ self._logger.setLevel(logging.ERROR)
+ return self._logger
+ #
+
+if __name__ == "__main__":
+ if len(sys.argv) == 3:
+ context = pickle.loads(sys.argv[1])
+ args = pickle.loads(sys.argv[2])
+
+ (out, err) = context._startSalome(args)
+ if out:
+ sys.stdout.write(out)
+ if err:
+ sys.stderr.write(err)
+ else:
+ usage()
+#
--- /dev/null
+#! /usr/bin/env python
+
+# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+import sys
+import glob
+import subprocess
+import re
+import socket
+import json
+
+"""
+Define a specific exception class to manage exceptions related to SalomeContext
+"""
+class SalomeContextException(Exception):
+ """Report error messages to the user interface of SalomeContext."""
+#
+
+def __listDirectory(path):
+ allFiles = []
+ for root, dirs, files in os.walk(path):
+ cfgFiles = glob.glob(os.path.join(root,'*.cfg'))
+ allFiles += cfgFiles
+
+ return allFiles
+#
+
+def __getConfigFileNamesDefault():
+ absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','')
+ if not absoluteAppliPath:
+ return []
+
+ envdDir = absoluteAppliPath + '/env.d'
+ if not os.path.isdir(envdDir):
+ return []
+
+ return __listDirectory(envdDir)
+#
+
+def __getEnvironmentFileNames(args, optionPrefix, checkExistence):
+ # special case: extra configuration/environment files are provided by user
+ # Search for command-line argument(s) <optionPrefix>=file1,file2,..., filen
+ # Search for command-line argument(s) <optionPrefix>=dir1,dir2,..., dirn
+ configArgs = [ str(x) for x in args if str(x).startswith(optionPrefix) ]
+
+ args = [ x for x in args if not x.startswith(optionPrefix) ]
+ allLists = [ x.replace(optionPrefix, '') for x in configArgs ]
+
+ configFileNames = []
+ unexisting = []
+ for currentList in allLists:
+ elements = currentList.split(',')
+ for elt in elements:
+ elt = os.path.realpath(os.path.expanduser(elt))
+ if os.path.isdir(elt):
+ configFileNames += __listDirectory(elt)
+ else:
+ if checkExistence and not os.path.isfile(elt):
+ unexisting += [elt]
+ else:
+ configFileNames += [elt]
+
+ return configFileNames, args, unexisting
+#
+
+def getConfigFileNames(args, checkExistence=False):
+ configOptionPrefix = "--config="
+ configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
+ if len(configArgs) == 0:
+ configFileNames, unexist = __getConfigFileNamesDefault(), []
+ else:
+ # get configuration filenames
+ configFileNames, args, unexist = __getEnvironmentFileNames(args, configOptionPrefix, checkExistence)
+
+ return configFileNames, args, unexist
+#
+
+def __getScriptPath(scriptName, searchPathList):
+ scriptName = os.path.expanduser(scriptName)
+ if os.path.isabs(scriptName):
+ return scriptName
+
+ if searchPathList is None or len(searchPathList) == 0:
+ return None
+
+ for path in searchPathList:
+ fullName = os.path.join(path, scriptName)
+ if os.path.isfile(fullName) or os.path.isfile(fullName+".py"):
+ return fullName
+
+ return None
+#
+
+class ScriptAndArgs:
+ # script: the command to be run, e.g. python <script.py>
+ # args: its input parameters
+ # out: its output parameters
+ def __init__(self, script=None, args=None, out=None):
+ self.script = script
+ self.args = args
+ self.out = out
+ #
+ def __repr__(self):
+ msg = "\n# Script: %s\n"%self.script
+ msg += " * Input: %s\n"%self.args
+ msg += " * Output: %s\n"%self.out
+ return msg
+ #
+#
+class ScriptAndArgsObjectEncoder(json.JSONEncoder):
+ def default(self, obj):
+ if isinstance(obj, ScriptAndArgs):
+ # to be easily parsed in GUI module (SalomeApp_Application)
+ # Do not export output arguments
+ return {obj.script:obj.args or []}
+ else:
+ return json.JSONEncoder.default(self, obj)
+#
+
+def getShortAndExtraArgs(args=None):
+ if args is None:
+ args = []
+ try:
+ pos = args.index("--") # raise a ValueError if not found
+ short_args = args[:pos]
+ extra_args = args[pos:] # include "--"
+ except ValueError:
+ short_args = args
+ extra_args = []
+ pass
+
+ return short_args, extra_args
+#
+
+# Return an array of ScriptAndArgs objects
+def getScriptsAndArgs(args=None, searchPathList=None):
+ if args is None:
+ args = []
+ short_args, extra_args = getShortAndExtraArgs(args)
+ args = short_args
+
+ if searchPathList is None:
+ searchPathList = sys.path
+
+ # Syntax of args: script.py [args:a1,a2=val,an] ... script.py [args:a1,a2=val,an]
+ scriptArgs = []
+ currentKey = None
+ argsPrefix = "args:"
+ outPrefix = "out:"
+ callPython = False
+ afterArgs = False
+ currentScript = None
+
+ for i in range(len(args)):
+ elt = os.path.expanduser(args[i])
+ isDriver = (elt == "driver") # special case for YACS scheme execution
+
+ if elt.startswith(argsPrefix):
+ if not currentKey or callPython:
+ raise SalomeContextException("args list must follow corresponding script file in command line.")
+ elt = elt.replace(argsPrefix, '')
+ # Special process if some items of 'args:' list are themselves lists
+ # Note that an item can be a list, but not a list of lists...
+ # So we can have something like this:
+ # myscript.py args:['file1','file2'],val1,"done",[1,2,3],[True,False],"ok"
+ # With such a call, an elt variable contains the string representing ['file1','file2'],val1,"done",[1,2,3],[True,False],"ok" that is '[file1,file2],val1,done,[1,2,3],[True,False],ok'
+ # We have to split elt to obtain: ['[file1,file2]','val1','done','[1,2,3]','[True,False]','ok']
+ contains_list = re.findall('(\[[^\]]*\])', elt)
+ if contains_list:
+ extracted_args = []
+ x = elt.split(",")
+ # x is ['[file1', 'file2]', 'val1', 'done', '[1', '2', '3]', '[True', 'False]', 'ok']
+ list_begin_indices = [i for i in xrange(len(x)) if x[i].startswith('[')] # [0, 4, 7]
+ list_end_indices = [i for i in xrange(len(x)) if x[i].endswith(']')] # [1, 6, 8]
+ start = 0
+ for lbeg, lend in zip(list_begin_indices,list_end_indices): # [(0, 1), (4, 6), (7, 8)]
+ if lbeg > start:
+ extracted_args += x[start:lbeg]
+ pass
+ extracted_args += [','.join(x[lbeg:lend+1])]
+ start = lend+1
+ pass
+ if start < len(x):
+ extracted_args += x[start:len(x)]
+ pass
+ scriptArgs[len(scriptArgs)-1].args = extracted_args
+ pass
+ else: # a single split is enough
+ scriptArgs[len(scriptArgs)-1].args = [os.path.expanduser(x) for x in elt.split(",")]
+ pass
+ currentKey = None
+ callPython = False
+ afterArgs = True
+ elif elt.startswith(outPrefix):
+ if (not currentKey and not afterArgs) or callPython:
+ raise SalomeContextException("out list must follow both corresponding script file and its args in command line.")
+ elt = elt.replace(outPrefix, '')
+ scriptArgs[len(scriptArgs)-1].out = [os.path.expanduser(x) for x in elt.split(",")]
+ currentKey = None
+ callPython = False
+ afterArgs = False
+ elif elt.startswith("python"):
+ callPython = True
+ afterArgs = False
+ else:
+ if not os.path.isfile(elt) and not os.path.isfile(elt+".py"):
+ eltInSearchPath = __getScriptPath(elt, searchPathList)
+ if eltInSearchPath is None or (not os.path.isfile(eltInSearchPath) and not os.path.isfile(eltInSearchPath+".py")):
+ if elt[-3:] == ".py":
+ raise SalomeContextException("Script not found: %s"%elt)
+ scriptArgs.append(ScriptAndArgs(script=elt))
+ continue
+ elt = eltInSearchPath
+
+ if elt[-4:] != ".hdf":
+ if elt[-3:] == ".py" or isDriver:
+ currentScript = os.path.abspath(elt)
+ elif os.path.isfile(elt+".py"):
+ currentScript = os.path.abspath(elt+".py")
+ else:
+ currentScript = os.path.abspath(elt) # python script not necessary has .py extension
+ pass
+
+ if currentScript and callPython:
+ currentKey = "python "+currentScript
+ scriptArgs.append(ScriptAndArgs(script=currentKey))
+ callPython = False
+ elif currentScript:
+ if isDriver:
+ currentKey = currentScript
+ scriptArgs.append(ScriptAndArgs(script=currentKey))
+ callPython = False
+ elif not os.access(currentScript, os.X_OK):
+ currentKey = "python "+currentScript
+ scriptArgs.append(ScriptAndArgs(script=currentKey))
+ else:
+ ispython = False
+ try:
+ fn = open(currentScript)
+ for i in xrange(10): # read only 10 first lines
+ ln = fn.readline()
+ if re.search("#!.*python"):
+ ispython = True
+ break
+ pass
+ fn.close()
+ except:
+ pass
+ if not ispython and currentScript[-3:] == ".py":
+ currentKey = "python "+currentScript
+ else:
+ currentKey = currentScript
+ pass
+ scriptArgs.append(ScriptAndArgs(script=currentKey))
+ # CLOSE elif currentScript
+ afterArgs = False
+ # end for loop
+
+ if len(extra_args) > 1: # syntax: -- program [options] [arguments]
+ command = extra_args[1]
+ command_args = extra_args[2:]
+ scriptArgs.append(ScriptAndArgs(script=command, args=command_args))
+ pass
+
+ return scriptArgs
+#
+
+# Formatting scripts and args as a Bash-like command-line:
+# script1.py [args] ; script2.py [args] ; ...
+# scriptArgs is a list of ScriptAndArgs objects; their output parameters are omitted
+def formatScriptsAndArgs(scriptArgs=None):
+ if scriptArgs is None:
+ return ""
+ commands = []
+ for sa_obj in scriptArgs:
+ cmd = sa_obj.script
+ if sa_obj.args:
+ cmd = " ".join([cmd]+sa_obj.args)
+ commands.append(cmd)
+
+ sep = " ; "
+ if sys.platform == "win32":
+ sep = " & "
+ command = sep.join(["%s"%x for x in commands])
+ return command
+#
+
+# Ensure OMNIORB_USER_PATH is defined. This variable refers to a folder in which
+# SALOME will write omniOrb configuration files.
+# If OMNIORB_USER_PATH is already set, only checks write access to associated directory ;
+# an exception is raised if check fails. It allows users for choosing a specific folder.
+# Else the function sets OMNIORB_USER_PATH this way:
+# - If APPLI environment variable is set, OMNIORB_USER_PATH is set to ${APPLI}/USERS.
+# The function does not check USERS folder existence or write access. This folder
+# must exist ; this is the case if SALOME virtual application has been created using
+# appli_gen.py script.
+# - Else OMNIORB_USER_PATH is set to user home directory.
+def setOmniOrbUserPath():
+ omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
+ if omniorbUserPath:
+ if not os.access(omniorbUserPath, os.W_OK):
+ raise Exception("Unable to get write access to directory: %s"%omniorbUserPath)
+ pass
+ else:
+ homePath = os.path.realpath(os.path.expanduser('~'))
+ #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
+ defaultOmniorbUserPath = homePath
+ if os.getenv("APPLI"):
+ defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
+ pass
+ os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
+#
+
+def getHostname():
+ return socket.gethostname().split('.')[0]
+#
--- /dev/null
+# Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# --- scripts ---
+
+# scripts / static
+SET(_bin_SCRIPTS
+ helloWorld.py
+)
+
+# --- rules ---
+SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_SCRIPT_PYTHON})
+
--- /dev/null
+This directory contains the tests of SALOME
--- /dev/null
+print "Hello world"