--- /dev/null
+# Copyright (C) 2012-2015 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
+#
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
+PROJECT(Salome_SALOME_Profile C CXX)
+
+# Ensure a proper linker behavior:
+CMAKE_POLICY(SET CMP0003 NEW)
+
+# Versioning
+# ===========
+# Project name, upper case
+STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
+
+SET(${PROJECT_NAME_UC}_MAJOR_VERSION 0)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 0)
+SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
+SET(${PROJECT_NAME_UC}_VERSION
+ ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
+
+# Find KERNEL
+# ===========
+SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
+IF(EXISTS ${KERNEL_ROOT_DIR})
+ LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
+ INCLUDE(SalomeMacros)
+ FIND_PACKAGE(SalomeKERNEL REQUIRED)
+ KERNEL_WITH_CORBA() # check whether KERNEL builded with CORBA
+ELSE(EXISTS ${KERNEL_ROOT_DIR})
+ MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
+ENDIF(EXISTS ${KERNEL_ROOT_DIR})
+
+# User options
+# ============
+OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
+OPTION(SALOME_BUILD_DOC "Generate SALOME SALOME documentation" ON)
+
+IF(SALOME_BUILD_TESTS)
+ ENABLE_TESTING()
+ENDIF()
+
+# KERNEL optionals:
+IF(SALOME_BUILD_DOC)
+ FIND_PACKAGE(SalomePython)
+ FIND_PACKAGE(SalomeSphinx)
+ SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
+ENDIF()
+
+
+# Find GUI
+# ===========
+
+SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
+IF(EXISTS ${GUI_ROOT_DIR})
+ LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
+ FIND_PACKAGE(SalomeGUI REQUIRED)
+ FULL_GUI(TRUE) # check whether GUI builded in full mode and with CORBA
+ ADD_DEFINITIONS(${GUI_DEFINITIONS})
+ INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
+ELSE(EXISTS ${GUI_ROOT_DIR})
+ MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR")
+ENDIF(EXISTS ${GUI_ROOT_DIR})
+
+# Qt4
+FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
+INCLUDE(${QT_USE_FILE})
+
+# Directories
+# (default values taken from KERNEL)
+# ===========
+SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH "Install path: SALOME Python scripts")
+
+# Specific to SALOME:
+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)
+
+INSTALL(CODE "FILE(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/USERS)")
+
+# Sources
+# ========
+ADD_SUBDIRECTORY( src )
+ADD_SUBDIRECTORY( resources )
+ADD_SUBDIRECTORY( doc )
+
+# Additional files
+# ================
+SET(_salome_context_API_SCRIPTS
+ ${KERNEL_ROOT_DIR}/bin/salome/salomeContext.py
+ ${KERNEL_ROOT_DIR}/bin/salome/salomeContextUtils.py
+ ${KERNEL_ROOT_DIR}/bin/salome/parseConfigFile.py
+)
+SALOME_INSTALL_SCRIPTS("${_salome_context_API_SCRIPTS}" ${SALOME_INSTALL_SCRIPT_PYTHON})
--- /dev/null
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+\f
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+\f
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
--- /dev/null
+# Copyright (C) 2012-2015 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-2015 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 = 'default'
+
+# 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>`
--- /dev/null
+# Copyright (C) 2012-2015 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
+#
+
+# --- resources ---
+SET(SALOME_PROFILE_RESOURCES_FILES
+ app_icon.png
+ splash.png
+ about.png
+ icon_about.png
+ app_logo.png
+)
+
+# --- rules ---
+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_PROFILE_INSTALL_RES_DATA})
+
+# --- sub-directories ---
+ADD_SUBDIRECTORY( doc )
--- /dev/null
+<?xml version='1.0' encoding='utf-8'?>
+<document>
+ <section name="launch">
+ <parameter name="gui" value="yes"/>
+ <parameter name="splash" value="yes"/>
+ <parameter name="file" value="no"/>
+ <parameter name="key" value="no"/>
+ <parameter name="interp" value="no"/>
+ <parameter name="logger" value="no"/>
+ <parameter name="xterm" value="no"/>
+ <parameter name="portkill" value="no"/>
+ <parameter name="killall" value="no"/>
+ <parameter name="noexcepthandler" value="no"/>
+ <parameter name="pyModules" value=""/>
+ <parameter name="embedded" value="SalomeAppEngine,study,cppContainer,registry,moduleCatalog"/>
+ <parameter name="standalone" value=""/>
+ </section>
+ <section name="splash">
+ <parameter name="image" value="%SALOME_PROFILE_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="show_message" value="yes"/>
+ <parameter name="font" value="Xirod,12,normal"/>
+ </section>
+ <section name="resources">
+ <parameter name="LightApp" value="%SALOME_PROFILE_ROOT_DIR%/share/salome/resources/salome_profile"/>
+ </section>
+</document>
--- /dev/null
+# Copyright (C) 2012-2015 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_DOCUMENTS
+ sample.pdf
+)
+
+INSTALL(FILES ${_bin_DOCUMENTS} DESTINATION ${SALOME_SALOME_PROFILE_INSTALL_DOC_GUI})
--- /dev/null
+This directory contains binaries of SALOME's documentation
--- /dev/null
+# Copyright (C) 2012-2015 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-2015 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
+#
+
+# This class is used to parse .sh environment file
+# It deals with specific treatments:
+# - virtually add a section to configuration file
+# - process shell keywords (if, then...)
+class EnvFileConverter(object):
+ def __init__(self, fp, section_name, reserved = None, outputFile=None):
+ if reserved is None:
+ reserved = []
+ self.fp = fp
+ self.sechead = '[' + section_name + ']\n'
+ self.reserved = reserved
+ self.outputFile = outputFile
+ self.allParsedVariableNames = []
+ # exclude line that begin with:
+ self.exclude = [ 'if', 'then', 'else', 'fi', '#', 'echo', 'exit' ]
+ self.exclude.append('$gconfTool') # QUICK FIX :TODO: provide method to extend this variable
+ # discard the following keywords if at the beginning of line:
+ self.discard = [ 'export' ]
+ # the following keywords imply a special processing if at the beginning of line:
+ self.special = [ 'unset' ]
+
+ def readline(self):
+ if self.sechead:
+ try:
+ if self.outputFile is not None:
+ self.outputFile.write(self.sechead)
+ return self.sechead
+ finally:
+ self.sechead = None
+ else:
+ line = self.fp.readline()
+ # trim whitespaces
+ line = line.strip(' \t\n\r')
+ # line of interest? (not beginning by a keyword of self.exclude)
+ for k in self.exclude:
+ if line.startswith(k):
+ return '\n'
+ # look for substrinsg beginning with sharp charcter ('#')
+ line = re.sub(r'#.*$', r'', line)
+ # line to be pre-processed? (beginning by a keyword of self.special)
+ for k in self.special:
+ if k == "unset" and line.startswith(k):
+ line = line[len(k):]
+ line = line.strip(' \t\n\r')
+ line = UNSET_KEYWORD + ": " + line
+ # line to be pre-processed? (beginning by a keyword of self.discard)
+ for k in self.discard:
+ if line.startswith(k):
+ line = line[len(k):]
+ line = line.strip(' \t\n\r')
+ # process reserved keywords
+ for k in self.reserved:
+ if line.startswith(k) and "=" in line:
+ variable, value = line.split('=')
+ value = self._purgeValue(value, k)
+ line = ADD_TO_PREFIX + k + ": " + value
+ # Update list of variable names
+ # :TODO: define excludeBlock variable (similar to exclude) and provide method to extend it
+ if "cleandup()" in line:
+ print "WARNING: parseConfigFile.py: skip cleandup and look for '# PRODUCT environment'"
+ while True:
+ line = self.fp.readline()
+ if "# PRODUCT environment" in line:
+ print "WARNING: parseConfigFile.py: '# PRODUCT environment' found"
+ break
+ while "clean " in line[0:6]: #skip clean calls with ending ";" crash
+ line = self.fp.readline()
+ # Extract variable=value
+ if "=" in line:
+ try:
+ variable, value = line.split('=')
+ except: #avoid error for complicated sh line xx=`...=...`, but warning
+ print "WARNING: parseConfigFile.py: line with multiples '=' character are hazardous: '"+line+"'"
+ variable, value = line.split('=',1)
+ pass
+
+ # Self-extending variables that are not in reserved keywords
+ # Example: FOO=something:${FOO}
+ # In this case, remove the ${FOO} in value
+ if variable in value:
+ value = self._purgeValue(value, variable)
+ line = "%s=%s"%(variable,value)
+
+ self.allParsedVariableNames.append(variable)
+ # End of extraction
+
+ if not line:
+ return line
+
+ #
+ # replace "${FOO}" and "$FOO" and ${FOO} and $FOO by %(FOO)s if FOO is
+ # defined in current file (i.e. it is not an external environment variable)
+ for k in self.allParsedVariableNames:
+ key = r'\$\{?'+k+'\}?'
+ pattern = re.compile(key, re.VERBOSE)
+ line = pattern.sub(r'%('+k+')s', line)
+ # Remove quotes (if line does not contain whitespaces)
+ try:
+ variable, value = line.split('=', 1)
+ except ValueError:
+ variable, value = line.split(':', 1)
+ if not ' ' in value.strip():
+ pattern = re.compile(r'\"', re.VERBOSE)
+ line = pattern.sub(r'', line)
+ #
+
+ # Replace `shell_command` by its result
+ def myrep(obj):
+ obj = re.sub('`', r'', obj.group(0)) # remove quotes
+ obj = obj.split()
+ res = subprocess.Popen(obj, stdout=subprocess.PIPE).communicate()[0]
+ res = res.strip(' \t\n\r') # trim whitespaces
+ return res
+ #
+ line = re.sub('`[^`]+`', myrep, line)
+ #
+ if self.outputFile is not None:
+ self.outputFile.write(line+'\n')
+ return line
+
+ def _purgeValue(self, value, name):
+ # Replace foo:${PATTERN}:bar or foo:$PATTERN:bar by foo:bar
+ key = r'\$\{?'+name+'\}?'
+ pattern = re.compile(key, re.VERBOSE)
+ value = pattern.sub(r'', value)
+
+ # trim colons
+ value = _trimColons(value)
+
+ return value
+ #
+
+# Convert .sh environment file to configuration file format
+def convertEnvFileToConfigFile(envFilename, configFilename, reserved=None):
+ if reserved is None:
+ reserved = []
+ logConfigParser.debug('convert env file %s to %s'%(envFilename, configFilename))
+ fileContents = open(envFilename, 'r').read()
+
+ pattern = re.compile('\n[\n]+', re.VERBOSE) # multiple '\n'
+ fileContents = pattern.sub(r'\n', fileContents) # replace by a single '\n'
+
+ finput = StringIO(unicode(fileContents))
+ foutput = open(configFilename, 'w')
+
+ config = MultiOptSafeConfigParser()
+ config.optionxform = str # case sensitive
+ config.readfp(EnvFileConverter(finput, 'SALOME Configuration', reserved, outputFile=foutput))
+
+ foutput.close()
+
+ logConfigParser.info('Configuration file generated: %s'%configFilename)
+#
--- /dev/null
+# Copyright (C) 2012-2015 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(UseQt4Ext)
+
+# --- resources ---
+
+# resource files / to be processed by lrelease
+SET(_ts_RESOURCES
+ LightApp_images.ts
+ LightApp_msg_en.ts
+ LightApp_msg_fr.ts
+)
+
+# --- rules ---
+
+QT4_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>master</translation>
+ </message>
+ <message>
+ <source>ABOUT_LICENSE</source>
+ <translation>License description</translation>
+ </message>
+ <message>
+ <source>ABOUT_VERSION</source>
+ <translation>Version master</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>master</translation>
+ </message>
+ <message>
+ <source>ABOUT_LICENSE</source>
+ <translation>Description de la licence</translation>
+ </message>
+ <message>
+ <source>ABOUT_VERSION</source>
+ <translation>Version master</translation>
+ </message>
+ <message>
+ <source>ABOUT_TITLE</source>
+ <translation>SALOME</translation>
+ </message>
+</context>
+</TS>
--- /dev/null
+# Copyright (C) 2013-2015 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
+from parseConfigFile import convertEnvFileToConfigFile
+
+import tempfile
+import pickle
+import subprocess
+import platform
+
+from salomeContextUtils import SalomeContextException
+
+def usage():
+ #exeName = os.path.splitext(os.path.basename(__file__))[0]
+
+ msg = '''\
+Usage: salome [command] [options] [--config=<file,folder,...>]
+
+Commands:
+=========
+ start Starts a SALOME session (through virtual application)
+ shell Initializes SALOME environment, and executes scripts passed
+ as command arguments
+ connect Connects a Python console to the active SALOME session
+ killall Kill all SALOME running sessions for current user
+ info Display some information about SALOME
+ help Show this message
+ coffee Yes! SALOME can also make coffee!!
+
+If no command is given, default to start.
+
+Command options:
+================
+ Use salome <command> --help to show help on command ; available for start
+ and shell commands.
+
+--config=<file,folder,...>
+==========================
+ Initialize SALOME environment 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 environment then
+start SALOME using a single python command.
+
+"""
+class SalomeContext:
+ """
+ Initialize environment from a list of configuration files
+ identified by their names.
+ These files should be in appropriate (new .cfg) format.
+ However you can give old .sh environment files; in this case,
+ the SalomeContext class will try to automatically convert them
+ to .cfg format before setting the environment.
+ """
+ def __init__(self, configFileNames=0):
+ #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_LIBRARY_PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'MANPATH', 'PV_PLUGIN_PATH']
+ for filename in configFileNames:
+ basename, extension = os.path.splitext(filename)
+ if extension == ".cfg":
+ self.__setEnvironmentFromConfigFile(filename, reserved)
+ elif extension == ".sh":
+ #new convert procedures, temporary could be use not to be automatically deleted
+ #temp = tempfile.NamedTemporaryFile(suffix='.cfg', delete=False)
+ temp = tempfile.NamedTemporaryFile(suffix='.cfg')
+ try:
+ convertEnvFileToConfigFile(filename, temp.name, reserved)
+ self.__setEnvironmentFromConfigFile(temp.name, reserved)
+ temp.close()
+ except (ConfigParser.ParsingError, ValueError) as e:
+ self.getLogger().error("Invalid token found when parsing file: %s\n"%(filename))
+ temp.close()
+ sys.exit(1)
+ else:
+ self.getLogger().warning("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 environment 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)
+ msg = proc.communicate()
+ return msg, 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):
+ 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().warning("Environment variable already existing (and not overwritten): %s=%s", name, value)
+ return
+
+ if env:
+ self.getLogger().warning("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',
+ 'shell' : '_runSession',
+ 'connect' : '_runConsole',
+ 'killall': '_killAll',
+ 'info': '_showInfo',
+ 'help': '_usage',
+ 'coffee' : '_makeCoffee'
+ }
+
+ 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):
+ try:
+ import os
+ absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH')
+ import sys
+ path = os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome"))
+ if not path in sys.path:
+ sys.path[:0] = [path]
+ 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().warning("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 __setEnvironmentFromConfigFile(self, filename, reserved=None):
+ if reserved is None:
+ reserved = []
+ try:
+ unsetVars, configVars, reservedDict = parseConfigFile(filename, reserved)
+ except SalomeContextException, e:
+ msg = "%s"%e
+ file_dir = os.path.dirname(filename)
+ file_base = os.path.basename(filename)
+ base_no_ext, ext = os.path.splitext(file_base)
+ sh_file = os.path.join(file_dir, base_no_ext+'.sh')
+ if ext == ".cfg" and os.path.isfile(sh_file):
+ msg += "Found similar %s file; trying to parse this one instead..."%(base_no_ext+'.sh')
+ temp = tempfile.NamedTemporaryFile(suffix='.cfg')
+ try:
+ convertEnvFileToConfigFile(sh_file, temp.name, reserved)
+ self.__setEnvironmentFromConfigFile(temp.name, reserved)
+ msg += "OK\n"
+ self.getLogger().warning(msg)
+ temp.close()
+ return
+ except (ConfigParser.ParsingError, ValueError) as e:
+ msg += "Invalid token found when parsing file: %s\n"%(sh_file)
+ self.getLogger().error(msg)
+ temp.close()
+ sys.exit(1)
+ else:
+ self.getLogger().error(msg)
+ sys.exit(1)
+
+ # unset variables
+ for var in unsetVars:
+ self.unsetVariable(var)
+
+ # set environment
+ 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)
+ 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)
+
+ import runSalome
+ runSalome.runSalome()
+ #
+
+ 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'] + args
+ import setenv
+ setenv.main(True)
+
+ cmd = ["python", "-c", "import runConsole\nrunConsole.connect()" ]
+ proc = subprocess.Popen(cmd, shell=False, close_fds=True)
+ return proc.communicate()
+ #
+
+ def _killAll(self, args=None):
+ if args is None:
+ args = []
+ try:
+ import PortManager # mandatory
+ from multiprocessing import Process
+ from killSalomeWithPort import killMyPort
+ ports = PortManager.getBusyPorts()
+
+ if ports:
+ import tempfile
+ for port in ports:
+ with tempfile.NamedTemporaryFile():
+ p = Process(target = killMyPort, args=(port,))
+ p.start()
+ p.join()
+ except ImportError:
+ from killSalome import killAllPorts
+ killAllPorts()
+ pass
+
+ #
+
+ def _showInfo(self, args=None):
+ print "Running with python", platform.python_version()
+ self._runAppli(["--version"])
+ #
+
+ def _usage(self, unused=None):
+ usage()
+ #
+
+ def _makeCoffee(self, args=None):
+ print " ("
+ print " ) ("
+ print " ___...(-------)-....___"
+ print " .-\"\" ) ( \"\"-."
+ print " .-\'``\'|-._ ) _.-|"
+ print " / .--.| `\"\"---...........---\"\"` |"
+ print " / / | |"
+ print " | | | |"
+ print " \\ \\ | |"
+ print " `\\ `\\ | |"
+ print " `\\ `| |"
+ print " _/ /\\ /"
+ print " (__/ \\ /"
+ print " _..---\"\"` \\ /`\"\"---.._"
+ print " .-\' \\ / \'-."
+ print " : `-.__ __.-\' :"
+ print " : ) \"\"---...---\"\" ( :"
+ print " \'._ `\"--...___...--\"` _.\'"
+ print " \\\"\"--..__ __..--\"\"/"
+ print " \'._ \"\"\"----.....______.....----\"\"\" _.\'"
+ print " `\"\"--..,,_____ _____,,..--\"\"`"
+ 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-2015 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
+
+ shFiles = glob.glob(os.path.join(root,'*.sh'))
+ for f in shFiles:
+ no_ext = os.path.splitext(f)[0]
+ if not os.path.isfile(no_ext+".cfg"):
+ allFiles.append(f)
+
+ 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 getConfigFileNames(args, checkExistence=False):
+ # special case: configuration files are provided by user
+ # Search for command-line argument(s) --config=file1,file2,..., filen
+ # Search for command-line argument(s) --config=dir1,dir2,..., dirn
+ configOptionPrefix = "--config="
+ configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
+
+ if len(configArgs) == 0:
+ return __getConfigFileNamesDefault(), args, []
+
+ args = [ x for x in args if not x.startswith(configOptionPrefix) ]
+ allLists = [ x.replace(configOptionPrefix, '') 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 __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)
+#
+
+# Return an array of ScriptAndArgs objects
+def getScriptsAndArgs(args=None, searchPathList=None):
+ if args is None:
+ 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, '')
+ scriptArgs[len(scriptArgs)-1].args = [os.path.expanduser(x) for x in elt.split(",")]
+ 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
+ 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 the 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-2015 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"