void ToolPy::setToolType(Py::String arg) { std::string typeStr(arg.as_std_string()); if(typeStr=="Drill") getToolPtr()->Type = Tool::DRILL; else if(typeStr=="CenterDrill") getToolPtr()->Type = Tool::CENTERDRILL; else if(typeStr=="CounterSink") getToolPtr()->Type = Tool::COUNTERSINK; else if(typeStr=="CounterBore") getToolPtr()->Type = Tool::COUNTERBORE; else if(typeStr=="Reamer") getToolPtr()->Type = Tool::REAMER; else if(typeStr=="Tap") getToolPtr()->Type = Tool::TAP; else if(typeStr=="EndMill") getToolPtr()->Type = Tool::ENDMILL; else if(typeStr=="SlotCutter") getToolPtr()->Type = Tool::SLOTCUTTER; else if(typeStr=="BallEndMill") getToolPtr()->Type = Tool::BALLENDMILL; else if(typeStr=="ChamferMill") getToolPtr()->Type = Tool::CHAMFERMILL; else if(typeStr=="CornerRound") getToolPtr()->Type = Tool::CORNERROUND; else if(typeStr=="Engraver") getToolPtr()->Type = Tool::ENGRAVER; else getToolPtr()->Type = Tool::UNDEFINED; }
// // this method is called to retrieve the password // for the certificate // // @param password // bool pysvn_context::contextSslClientCertPwPrompt ( std::string &_password, const std::string &_realm, bool &_may_save ) { PythonDisallowThreads callback_permission( m_permission ); // make sure we can call the users object if( !m_pyfn_SslClientCertPwPrompt.isCallable() ) { m_error_message = "callback_ssl_client_cert_password_prompt required"; return false; } Py::Callable callback( m_pyfn_SslClientCertPwPrompt ); Py::Tuple args( 2 ); args[0] = Py::String( _realm ); args[1] = Py::Int( (long)_may_save ); // bool, username, password Py::Tuple results; Py::Int retcode; Py::String username; Py::String password; Py::Int may_save_out; try { results = callback.apply( args ); retcode = results[0]; password = results[1]; may_save_out = results[2]; // true returned if( long( retcode ) != 0 ) { // copy out the answers _password = password.as_std_string(); _may_save = long( may_save_out ) != 0; return true; } } catch( Py::Exception &e ) { PyErr_Print(); e.clear(); m_error_message = "unhandled exception in callback_ssl_client_cert_password_prompt"; return false; } return false; }
PyObject* Application::sAddWorkbenchHandler(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/) { PyObject* pcObject; std::string item; if (!PyArg_ParseTuple(args, "O", &pcObject)) // convert args: Python->C return NULL; // NULL triggers exception try { // get the class object 'Workbench' from the main module that is expected // to be base class for all workbench classes Py::Module module("__main__"); Py::Object baseclass(module.getAttr(std::string("Workbench"))); // check whether it is an instance or class object Py::Object object(pcObject); Py::String name; if (PyObject_IsSubclass(object.ptr(), baseclass.ptr()) == 1) { // create an instance of this class name = object.getAttr(std::string("__name__")); Py::Tuple args; Py::Callable creation(object); object = creation.apply(args); } else if (PyObject_IsInstance(object.ptr(), baseclass.ptr()) == 1) { // extract the class name of the instance PyErr_Clear(); // PyObject_IsSubclass set an exception Py::Object classobj = object.getAttr(std::string("__class__")); name = classobj.getAttr(std::string("__name__")); } else { PyErr_SetString(PyExc_TypeError, "arg must be a subclass or an instance of " "a subclass of 'Workbench'"); return NULL; } // Search for some methods and members without invoking them Py::Callable(object.getAttr(std::string("Initialize"))); Py::Callable(object.getAttr(std::string("GetClassName"))); item = name.as_std_string(); PyObject* wb = PyDict_GetItemString(Instance->_pcWorkbenchDictionary,item.c_str()); if (wb) { PyErr_Format(PyExc_KeyError, "'%s' already exists.", item.c_str()); return NULL; } PyDict_SetItemString(Instance->_pcWorkbenchDictionary,item.c_str(),object.ptr()); Instance->signalAddWorkbench(item.c_str()); } catch (const Py::Exception&) { return NULL; } Py_INCREF(Py_None); return Py_None; }
void WaypointPy::setType(Py::String arg) { std::string typeStr(arg.as_std_string()); if(typeStr=="PTP") getWaypointPtr()->Type = Waypoint::PTP; else if(typeStr=="LIN") getWaypointPtr()->Type = Waypoint::LINE; else if(typeStr=="CIRC") getWaypointPtr()->Type = Waypoint::CIRC; else if(typeStr=="WAIT") getWaypointPtr()->Type = Waypoint::WAIT; else throw Base::Exception("Unknown waypoint type! Only: PTP,LIN,CIRC,WAIT are allowed."); }
void ToolPy::setMaterial(Py::String arg) { std::string matStr(arg.as_std_string()); if(matStr=="HighSpeedSteel") getToolPtr()->Material = Tool::HIGHSPEEDSTEEL; else if(matStr=="Carbide") getToolPtr()->Material = Tool::CARBIDE; else if(matStr=="HighCarbonToolSteel") getToolPtr()->Material = Tool::HIGHCARBONTOOLSTEEL; else if(matStr=="CastAlloy") getToolPtr()->Material = Tool::CASTALLOY; else if(matStr=="Ceramics") getToolPtr()->Material = Tool::CERAMICS; else if(matStr=="Diamond") getToolPtr()->Material = Tool::DIAMOND; else if(matStr=="Sialon") getToolPtr()->Material = Tool::SIALON; else getToolPtr()->Material = Tool::MATUNDEFINED; }
void WaypointPy::setName(Py::String arg) { getWaypointPtr()->Name = arg.as_std_string(); }
void ToolPy::setName(Py::String arg) { std::string name = arg.as_std_string(); getToolPtr()->Name = name; }