are supported.
If <arg> does not represent a boolean, an exception is raised.
"""
- import types
- if type( arg ) == bool :
+ if isinstance(arg, bool) :
return arg
- elif type( arg ) == bytes :
+ elif isinstance(arg, (str, bytes)):
v = str( arg ).lower()
if v in [ "yes", "y", "true" ]: return True
elif v in [ "no", "n", "false" ]: return False
<em>See \ref example1 for an example of this method usage in batchmode of %SALOME application.</em>
*/
- Study Open (in URL aStudyUrl) raises (SALOME::SALOME_Exception);
+ Study Open (in wstring aStudyUrl) raises (SALOME::SALOME_Exception);
/*! \brief Closing the study
void HDFfile::OpenOnDisk(hdf_access_mode access_mode)
{
- _access_mode = access_mode;
+ _access_mode = access_mode;
+ std::string msgerr;
- switch (_access_mode)
- {
- case HDF_RDWR :
- if (access(_name,F_OK))
+ switch (_access_mode)
{
- if ((_id = HDFfileCreate(_name)) < 0)
- throw HDFexception("Can't open HDF file");
+ case HDF_RDWR:
+ if (access(_name, F_OK))
+ {
+ if ((_id = HDFfileCreate(_name)) < 0) {
+ msgerr = "Can't create HDF in RW mode file" + std::string(_name);
+ throw HDFexception(msgerr.c_str());
+ }
+ }
+ else if ((_id = HDFfileOpen(_name, _access_mode)) < 0) {
+ msgerr = "Can't open HDF in RW mode file " + std::string(_name);
+ throw HDFexception(msgerr.c_str());
+ }
+ break;
+
+ case HDF_RDONLY:
+ if ((_id = HDFfileOpen(_name, _access_mode)) < 0) {
+ msgerr = "Can't open HDF in RO mode file " + std::string(_name);
+ throw HDFexception(msgerr.c_str());
+ }
+ break;
+
+ default:
+ msgerr = "Can't open HDF file " + std::string(_name) + " : bad acces option";
+ throw HDFexception(msgerr.c_str());
}
- else
- if ((_id = HDFfileOpen(_name,_access_mode)) < 0)
- throw HDFexception("Can't open HDF file");
- break;
-
- case HDF_RDONLY :
- if ((_id = HDFfileOpen(_name,_access_mode)) < 0)
- throw HDFexception("Can't open HDF file");
- break;
-
- default :
- throw HDFexception("Can't open HDF file : bad acces option");
- }
}
void HDFfile::CloseOnDisk()
myStudy = None
myStudyId = getActiveStudy()
if myStudyId == None :
- import types
- if theStudyPath and (type(theStudyPath) == bytes or type(theStudyPath) == str):
+ if theStudyPath and isinstance(theStudyPath, (str, bytes)):
+ if isinstance(theStudyPath, bytes):
+ theStudyPath = str(theStudyPath, 'UTF8')
myStudyId = openStudy(theStudyPath)
else:
myStudyId = createNewStudy()
//SRN: Pure CORBA Open as it does more initialization than the local one
SALOMEDSClient_Study* aStudy = NULL;
- SALOMEDS::Study_var aStudy_impl = _corba_impl->Open((char*)theStudyUrl.c_str());
+ std::wstring wtheStudyUrl = std::wstring(theStudyUrl.begin(), theStudyUrl.end());
+ SALOMEDS::Study_var aStudy_impl = _corba_impl->Open((wchar_t*)theStudyUrl.c_str());
if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy);
aStudy = new SALOMEDS_Study(aStudy_impl.in());
* Purpose : Open a Study from it's persistent reference
*/
//============================================================================
-SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl)
+SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const wchar_t* aWUrl)
throw(SALOME::SALOME_Exception)
{
SALOMEDS::Locker lock;
Unexpect aCatch(SalomeException);
- MESSAGE("Begin of SALOMEDS_StudyManager_i::Open");
+
+ // Converts UTF8 url to encoded version
+ setlocale(LC_ALL, "");
+ char aUrl[256];
+ int ret;
+ memset( aUrl, 0, 256);
+ ret = wcstombs(aUrl, aWUrl, 255);
+ if (ret==256) aUrl[255]='\0';
+ MESSAGE("Begin of SALOMEDS_StudyManager_i::Open " << aUrl);
+
#ifndef ALLOW_MULTI_STUDIES
std::vector<SALOMEDSImpl_Study*> anOpened = _impl->GetOpenStudies();
SALOMEDSImpl_Study* aStudyImpl = _impl->Open(std::string(aUrl));
- if ( !aStudyImpl )
- THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
+ if ( !aStudyImpl ) {
+ std::string errmsg = "Impossible to Open study from file " + std::string(aUrl);
+ THROW_SALOME_CORBA_EXCEPTION(errmsg.c_str(), SALOME::BAD_PARAM)
+ }
MESSAGE("Open : Creating the CORBA servant holding it... ");
\param char* arguments, the study URL
\return Study_ptr arguments
*/
- virtual SALOMEDS::Study_ptr Open(const char* aStudyUrl) throw (SALOME::SALOME_Exception);
+ virtual SALOMEDS::Study_ptr Open(const wchar_t* aStudyUrl) throw (SALOME::SALOME_Exception);
//! method to close a Study