From 731f3a1181e22a8bffdc997defb2ba7f3bd0b180 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 15 Apr 2020 16:21:01 +0300 Subject: [PATCH] bos #18341: HOME environment variable --- bin/runHOMARD.py | 3 ++- doc/files/yacs_script.py | 11 ++--------- doc/files/yacs_script_test.py | 11 ++--------- src/HOMARD_I/HOMARD_Gen_i.cxx | 3 ++- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/bin/runHOMARD.py b/bin/runHOMARD.py index d78edfe2..d2109611 100755 --- a/bin/runHOMARD.py +++ b/bin/runHOMARD.py @@ -180,7 +180,8 @@ class Server: class CatalogServer(Server): SCMD1=['SALOME_ModuleCatalog_Server','-common'] - SCMD2=['-personal','${HOME}/Salome/resources/CatalogModulePersonnel.xml'] + home_dir=os.path.expanduser("~") + SCMD2=['-personal',os.path.join(home_dir,'Salome', 'resources', 'CatalogModulePersonnel.xml')] def setpath(self,liste_modules): cata_path=[] diff --git a/doc/files/yacs_script.py b/doc/files/yacs_script.py index 81d752e6..b6bdd2c9 100755 --- a/doc/files/yacs_script.py +++ b/doc/files/yacs_script.py @@ -373,13 +373,7 @@ Controle les arguments et stockage de quelques informations # # 1.2. Le repertoire de calcul # - if "HOME" in os.environ : - HOME = os.environ ["HOME"] - else : - HOME = "/local/home/salome" -# - if ( self.rep_calc[:1] == "~" ) : - self.rep_calc = os.path.join(HOME, self.rep_calc[2:]) + self.rep_calc = os.path.expanduser(self.rep_calc) if not os.path.isdir(self.rep_calc) : self.message_info += "Repertoire " + self.rep_calc erreur = -4 @@ -392,8 +386,7 @@ Controle les arguments et stockage de quelques informations # fic = self.mesh_file # - if ( fic[:1] == "~" ) : - fic = os.path.join(HOME, fic[2:]) + fic = os.path.expanduser(fic) if not os.path.isfile(fic) : aux = os.path.join(self.rep_calc, fic) if not os.path.isfile(aux) : diff --git a/doc/files/yacs_script_test.py b/doc/files/yacs_script_test.py index 0e06a645..f4cd0cc1 100755 --- a/doc/files/yacs_script_test.py +++ b/doc/files/yacs_script_test.py @@ -190,13 +190,7 @@ Controle les arguments et stockage de quelques informations # # 1.2. Le repertoire de calcul # - if "HOME" in os.environ : - HOME = os.environ ["HOME"] - else : - HOME = "/local/home/salome" -# - if ( self.rep_calc[:1] == "~" ) : - self.rep_calc = os.path.join(HOME, self.rep_calc[2:]) + self.rep_calc = os.path.expanduser(self.rep_calc) if not os.path.isdir(self.rep_calc) : self.message_info += "Repertoire " + self.rep_calc erreur = -4 @@ -209,8 +203,7 @@ Controle les arguments et stockage de quelques informations # fic = self.mesh_file # - if ( fic[:1] == "~" ) : - fic = os.path.join(HOME, fic[2:]) + fic = os.path.expanduser(fic) if not os.path.isfile(fic) : aux = os.path.join(self.rep_calc, fic) if not os.path.isfile(aux) : diff --git a/src/HOMARD_I/HOMARD_Gen_i.cxx b/src/HOMARD_I/HOMARD_Gen_i.cxx index 51202e18..dde42a69 100644 --- a/src/HOMARD_I/HOMARD_Gen_i.cxx +++ b/src/HOMARD_I/HOMARD_Gen_i.cxx @@ -36,6 +36,7 @@ #include "utilities.h" #include "Basics_Utils.hxx" +#include "Basics_DirUtils.hxx" #include "Utils_SINGLETON.hxx" #include "Utils_CorbaException.hxx" #include "SALOMEDS_Tool.hxx" @@ -5260,7 +5261,7 @@ void HOMARD_Gen_i::SetPreferences( ) if ( ok ) { std::string PrefFile ; - PrefFile = getenv("HOME") ; + PrefFile = Kernel_Utils::HomePath() ; PrefFile += "/.config/salome/SalomeApprc." + salome_version ; MESSAGE ( "PrefFile = "<