# Connect to one instance
import runConsole
- port = all_instances[len(all_instances)/2].get_port()
+ port = all_instances[len(all_instances)//2].get_port()
print("Connect to instance running on port", port)
self.__connectToInstance(port)
# Connect to another instance
import runConsole
- port = all_instances[len(all_instances)/4].get_port()
+ port = all_instances[len(all_instances)//4].get_port()
print("Connect to instance running on port", port)
self.__connectToInstance(port)
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
{
/*! \brief Name of the file in which the %Study is saved.
*/
- typedef string URLPath;
+ typedef wstring URLPath;
/*! \brief Main identifier of an object in %SALOME application
*/
*/
typedef string SalomeReference;
+//! List of file names
+ typedef sequence<string> ListOfFileNames;
//! List of modification dates of a study
typedef sequence<string> ListOfDates ;
//! An unbounded sequence of strings
*/
SComponent NewComponent(in string ComponentDataType) raises(LockProtection);
+
/*! \brief Definition of the instance to the %SComponent
Defines the instance to the %SComponent.
\param anObject The %SObject which will be identified
\param theGUID GUID has the following format "00000000-0000-0000-0000-000000000000"
*/
-
- void SetGUID(in SObject anObject, in string theGUID) raises(LockProtection);
+ void SetGUID(in SObject anObject, in string theGUID) raises(LockProtection);
/*!
Searches for a definite %SObject with a definite GUID and returns True if it finds it.
This is equivalent to the methods setName() & getName()
*/
- readonly attribute string Name; // equivalent to getName()
+ attribute wstring Name; // equivalent to getName()
+
+/*! \brief Indicate the file where the %study has been saved
+*/
//! Sequence containing %SObjects
typedef sequence<SObject> ListOfSObject;
/*! \brief Indicate the file where the %study has been saved
*/
- attribute string URL;
+ attribute wstring URL;
/*! \brief List of %SObjects
return guid;
}
+ const wchar_t* decode(const char* encoded)
+ {
+ setlocale(LC_ALL, "");
+ size_t length = strlen(encoded) + sizeof(char);
+ wchar_t* decoded = new wchar_t[length];
+ memset( decoded, '\0', length);
+ mbstowcs(decoded, encoded, length);
+ return decoded;
+ }
+
+ const wchar_t* decode_s(std::string encoded)
+ {
+ return decode(encoded.c_str());
+ }
+
+ const char* encode(const wchar_t* decoded)
+ {
+ setlocale(LC_ALL, "");
+ size_t length = std::wcslen(decoded) + sizeof(wchar_t);
+ char* encoded = new char[length];
+ memset( encoded, '\0', length);
+ wcstombs(encoded, decoded, length);
+ return encoded;
+ }
+
+ std::string encode_s(const wchar_t* decoded)
+ {
+ return std::string(encode(decoded));
+ }
+
#ifndef WIN32
void print_traceback()
{
ObjectdID //!< Global usage object identifier ID
};
+ const wchar_t* decode(const char* encoded);
+ const wchar_t* decode_s(std::string encoded);
+ const char* encode(const wchar_t* decoded);
+ std::string encode_s(const wchar_t* decoded);
+
//! Get predefined GUID
BASICS_EXPORT std::string GetGUID( GUIDtype );
#ifndef WIN32
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()
pass
import types
- if theStudyPath and type(theStudyPath) == types.StringType:
+ if theStudyPath and isinstance(theStudyPath, (str, bytes)):
+ if isinstance(theStudyPath, bytes):
+ theStudyPath = str(theStudyPath, 'UTF8')
openStudy(theStudyPath)
myStudyName = myStudy._get_Name()
#include CORBA_SERVER_HEADER(SALOMEDS)
#include "SALOMEDS_AttributeName_i.hxx"
#include "SALOME_KernelServices.hxx"
+#include "Basics_Utils.hxx"
#include "utilities.h"
#include "HDFOI.hxx"
DumpStudy();
// Save as
- myStudy->SaveAs("/home/edeville/Study1.hdf", false, false);
+ myStudy->SaveAs(Kernel_Utils::decode("/home/edeville/Study1.hdf"), false, false);
// Get Persistent Reference of the study test
name = myStudy->GetPersistentReference();
{
if(CORBA::is_nil(_corba_impl))
return false;
-
- if (!_corba_impl->Open(theStudyUrl.c_str()))
+ std::wstring wtheStudyUrl = std::wstring(theStudyUrl.begin(), theStudyUrl.end());
+
+ if (!_corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() ) )
return false;
return true;
if(CORBA::is_nil(_corba_impl))
return false;
- return _corba_impl->SaveAs((char*)theUrl.c_str(), theMultiFile, theASCII);
+ return _corba_impl->SaveAs(Kernel_Utils::decode_s(theUrl), theMultiFile, theASCII);
}
SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
SALOMEDS::Locker lock;
aName = _local_impl->Name();
}
- else aName = _corba_impl->Name();
+ else aName = Kernel_Utils::encode_s(_corba_impl->Name());
return aName;
}
+void SALOMEDS_Study::Name(const std::string& theName)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ _local_impl->Name(theName);
+ }
+ else _corba_impl->Name(Kernel_Utils::decode_s(theName));
+}
+
bool SALOMEDS_Study::IsSaved()
{
bool isSaved;
SALOMEDS::Locker lock;
aURL = _local_impl->URL();
}
- else aURL = _corba_impl->URL();
+ else
+ aURL = Kernel_Utils::encode_s(_corba_impl->URL());
return aURL;
}
SALOMEDS::Locker lock;
_local_impl->URL(url);
}
- else _corba_impl->URL((char*)url.c_str());
+ else _corba_impl->URL(Kernel_Utils::decode_s(url));
}
std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
virtual _PTR(SComponentIterator) NewComponentIterator();
virtual _PTR(StudyBuilder) NewBuilder();
virtual std::string Name();
+ virtual void Name(const std::string& name);
virtual bool IsSaved();
virtual void IsSaved(bool save);
virtual bool IsModified();
* Purpose : Open a Study from it's persistent reference
*/
//============================================================================
-bool SALOMEDS_Study_i::Open(const char* aUrl)
+bool SALOMEDS_Study_i::Open(const wchar_t* aWUrl)
throw(SALOME::SALOME_Exception)
{
if (!_closed)
Unexpect aCatch(SalomeException);
MESSAGE("Begin of SALOMEDS_Study_i::Open");
-
+
+ std::string aUrl = Kernel_Utils::encode_s(aWUrl);
bool res = _impl->Open(std::string(aUrl));
// update desktop title with new study name
* Purpose : Save a study to the persistent reference aUrl
*/
//============================================================================
-CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
+CORBA::Boolean SALOMEDS_Study_i::SaveAs(const wchar_t* aWUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
{
SALOMEDS::Locker lock;
if (_closed)
throw SALOMEDS::Study::StudyInvalidReference();
+
+ std::string aUrl = Kernel_Utils::encode_s(aWUrl);
return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile, theASCII);
}
* Purpose : get study name
*/
//============================================================================
-char* SALOMEDS_Study_i::Name()
+wchar_t* SALOMEDS_Study_i::Name()
{
SALOMEDS::Locker lock;
// Name is specified as IDL attribute: user exception cannot be raised
- return CORBA::string_dup(_impl->Name().c_str());
+ return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->Name()));
+}
+
+//============================================================================
+/*! Function : Name
+ * Purpose : set study name
+ */
+//============================================================================
+void SALOMEDS_Study_i::Name(const wchar_t* wname)
+{
+ SALOMEDS::Locker lock;
+ // Name is specified as IDL attribute: user exception cannot be raised
+ _impl->Name(Kernel_Utils::encode_s(wname));
}
//============================================================================
* Purpose : get URL of the study (persistent reference of the study)
*/
//============================================================================
-char* SALOMEDS_Study_i::URL()
+wchar_t* SALOMEDS_Study_i::URL()
{
- SALOMEDS::Locker lock;
+ SALOMEDS::Locker lock;
// URL is specified as IDL attribute: user exception cannot be raised
- return CORBA::string_dup(_impl->URL().c_str());
+ return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->URL()));
}
//============================================================================
* Purpose : set URL of the study (persistent reference of the study)
*/
//============================================================================
-void SALOMEDS_Study_i::URL(const char* url)
+void SALOMEDS_Study_i::URL(const wchar_t* wurl)
{
SALOMEDS::Locker lock;
// URL is specified as IDL attribute: user exception cannot be raised
- _impl->URL(std::string((char*)url));
+ _impl->URL(Kernel_Utils::encode_s(wurl));
// update desktop title with new study name
NameChanged();
\param char* arguments, the study URL
\return Study_ptr arguments
*/
- virtual bool Open(const char* aStudyUrl) throw (SALOME::SALOME_Exception);
+ virtual bool Open(const wchar_t* aStudyUrl) throw (SALOME::SALOME_Exception);
//! method to save a Study
virtual CORBA::Boolean Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII);
/*!
\param char* arguments, the new URL of the study
*/
- virtual CORBA::Boolean SaveAs(const char* aUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII);
+ virtual CORBA::Boolean SaveAs(const wchar_t* aUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII);
//! method to copy the object
/*!
/*!
\return char* arguments, the study name
*/
- virtual char* Name();
+ virtual wchar_t* Name();
+
+ //! method to set study name
+ /*!
+ \param name char* arguments, the study name
+ */
+ virtual void Name(const wchar_t* name);
//! method to get if study has been saved
/*!
/*!
\return char* arguments, the study URL
*/
- virtual char* URL();
+ virtual wchar_t* URL();
//! method to set URL of the study
/*!
\param url char* arguments, the study URL
*/
- virtual void URL(const char* url);
+ virtual void URL(const wchar_t* url);
static void IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute);
* Use code of SALOMEDS_AttributeComment.cxx
*/
+//#include "Basics_Utils.hxx"
+
void SALOMEDSTest::testAttributeComment()
{
//Create Study
return Kernel_Utils::GetBaseName( _name, false );
}
+//============================================================================
+/*! Function : Name
+ * Purpose : set study name
+ */
+//============================================================================
+void SALOMEDSImpl_Study::Name(const std::string& name)
+{
+ _errorCode = "";
+ _name = name;
+}
+
//============================================================================
/*! Function : IsSaved
* Purpose : get if study has been saved
//! method to get study name
virtual std::string Name();
+
+ //! method to set study name
+ virtual void Name(const std::string& name);
//! method to get if study has been saved
virtual bool IsSaved();
import TestSalomeSDSHelper0
import os,subprocess
fname=os.path.splitext(TestSalomeSDSHelper0.__file__)[0]+".py"
- proc=subprocess.Popen(["python",fname],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+ proc = subprocess.Popen(["python3", fname], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out,err=proc.communicate()
if proc.returncode!=0:
print(out)