if filePath is None:
filePath = os.path.realpath(os.path.dirname(__file__))
- homePath = os.path.realpath(os.getenv('HOME'))
+ homePath = os.path.realpath(os.path.expanduser("~"))
applipath = os.path.relpath(filePath, homePath)
return applipath
#
if __name__ == "__main__":
if sys.hexversion < 0x02060000: # Python older than 2.6.0
- applipath = relpath(os.path.realpath(os.path.dirname(__file__)),os.path.realpath(os.getenv('HOME')))
+ applipath = relpath(os.path.realpath(os.path.dirname(__file__)),os.path.realpath(os.path.expanduser("~")))
else:
applipath = get_appli_path()
print(applipath)
import getAppliPath
appli_local=os.path.realpath(os.path.dirname(__file__))
-APPLI=getAppliPath.relpath(appli_local,os.path.realpath(os.getenv('HOME')))
+APPLI=getAppliPath.relpath(appli_local,os.path.realpath(os.path.expanduser("~")))
usage="""%(prog)s [options]
import getAppliPath
appli_local=os.path.realpath(os.path.dirname(__file__))
-APPLI=getAppliPath.relpath(appli_local,os.path.realpath(os.getenv('HOME')))
+APPLI=getAppliPath.relpath(appli_local,os.path.realpath(os.path.expanduser("~")))
usage="""%(prog)s [options]
Typical use is:
#local machine, use cp
if appliPath[0]!='/':
#relative path
- appliPath=os.path.join(os.getenv("HOME"),appliPath)
+ appliPath=os.path.join(os.path.expanduser("~"),appliPath)
if appliPath == appli_local:
return
if hostname == "localhost" or hostname == get_hostname() and userName == getUserName():
#user local resource
if appliPath[0]!='/':
- appliPath=os.path.join(os.getenv("HOME"),appliPath)
+ appliPath=os.path.join(os.path.expanduser("~"),appliPath)
if appliPath == appli_local:
#main local resource: get catalogs in share/salome/resources
catalogs_list=glob.glob(os.path.join(appliPath,"share","salome","resources","*","*Catalog.xml"))
pass
pass
# delete uri files needed by ompi-server
- cmd = "rm -f " + os.environ['HOME'] + "/.urifile_*"
+ cmd = "rm -f " + os.path.expanduser("~") + "/.urifile_*"
os.system(cmd)
pass
else:
# old-style non-dot-prefixed pidict files
# are in the user's home directory
- dir = os.getenv("HOME")
+ dir = os.path.expanduser("~")
pass
pass
self.SCMD1+=["NameService=corbaname::" + machine + ":" + port]
self.SCMD1+=['-common']
self.SCMD2=[]
- home_dir=os.getenv('HOME')
+ home_dir=os.path.expanduser("~")
if home_dir is not None:
- self.SCMD2=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')]
+ self.SCMD2=['-personal',os.path.join(home_dir,'Salome', 'resources', 'CatalogModulePersonnel.xml')]
def setpath(self,modules_list,modules_root_dir):
list_modules = modules_list[:]
'(','--salome_session','theSession',')']
if 'moduleCatalog' in self.args['embedded']:
self.SCMD1+=['--with','ModuleCatalog','(','-common']
- home_dir=os.getenv('HOME')
+ home_dir=os.path.expanduser("~")
if home_dir is not None:
- self.SCMD2+=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')]
+ self.SCMD2+=['-personal',os.path.join(home_dir,'Salome','resources','CatalogModulePersonnel.xml')]
self.SCMD2+=[')']
if 'study' in self.args['embedded']:
self.SCMD2+=['--with','SALOMEDS','(',')']
'(','--salome_session','theSession',')']
if 'moduleCatalog' in self.args['embedded']:
self.SCMD1+=['--with','ModuleCatalog','(','-common']
- self.SCMD2+=['-personal',
- '${HOME}/Salome/resources/CatalogModulePersonnel.xml',')']
+ home_dir=os.path.expanduser("~")
+ if home_dir is not None:
+ self.SCMD2=['-personal',os.path.join(home_dir,'Salome','resources','CatalogModulePersonnel.xml')]
+ self.SCMD2+=[')']
if 'study' in self.args['embedded']:
self.SCMD2+=['--with','SALOMEDS','(',')']
if 'cppContainer' in self.args['embedded']:
std::replace(res.begin(), res.end(), '\\', '/');
return res;
}
+
+
+ //============================================================================
+ // function : BackSlashToSlash
+ // purpose : Convert back slash to slash
+ //============================================================================
+ std::string HomePath() {
+#ifdef WIN32
+ std::string homedir = getenv("USERPROFILE");
+#else
+ std::string homedir = getenv("HOME");
+#endif
+ return homedir;
+ }
}
BASICS_EXPORT bool IsEmptyDir( const std::string& path );
BASICS_EXPORT std::string BackSlashToSlash( const std::string& path );
+
+ // Returns getenv("HOME") for Unix or getenv("USERPROFILE") for WIN32
+ BASICS_EXPORT std::string HomePath();
}
#endif
//#define _DEBUG_
#include "Launcher_Job.hxx"
#include "Launcher.hxx"
+
+#include <Basics_DirUtils.hxx>
+
#include <boost/filesystem.hpp>
#ifdef WITH_LIBBATCH
// If result_directory is not defined, we use HOME environment
if (_result_directory == "")
-#ifndef WIN32
- _result_directory = getenv("HOME");
-#else
- _result_directory = getenv("USERPROFILE");
-#endif
+ _result_directory = Kernel_Utils::HomePath();
+
// _in_files
std::list<std::string> in_files(_in_files);
in_files.push_back(_job_file);
//
#include "ResourcesManager.hxx"
+
#include "SALOME_ResourcesCatalog_Handler.hxx"
#include <Basics_Utils.hxx>
+#include <Basics_DirUtils.hxx>
+
#include <fstream>
#include <iostream>
#include <sstream>
std::string default_file("");
if (getenv("APPLI") != 0)
{
- default_file += getenv("HOME");
+ default_file += Kernel_Utils::HomePath();
default_file += "/";
default_file += getenv("APPLI");
default_file += "/CatalogResources.xml";
resource.Batch = none;
#ifndef WIN32
struct stat statbuf;
- if (getenv("HOME") != NULL && getenv("APPLI") != NULL)
+ std::string aHomePath = Kernel_Utils::HomePath();
+ if (aHomePath != "" && getenv("APPLI") != NULL)
{
if (stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode))
{
}
else
{
- resource.AppliPath = string(getenv("HOME")) + "/" + getenv("APPLI");
+ resource.AppliPath = aHomePath + "/" + getenv("APPLI");
}
}
string tmpdir = "/tmp";