[pytango] 276/483: closer to databaseds
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:49 UTC 2017
This is an automated email from the git hooks/post-receive script.
sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.
commit 89dcbaba507241c9dede95077d2107b1b25b7cc9
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Wed Sep 11 05:15:14 2013 +0000
closer to databaseds
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@23583 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
src/boost/cpp/server/dserver.cpp | 7 ++++
src/boost/cpp/server/tango_util.cpp | 70 ++++++++++++++++++++++++++++++++
src/boost/python/__init__.py | 2 +-
src/boost/python/databaseds/database.py | 27 +++++++-----
src/boost/python/databaseds/db_access.py | 4 +-
5 files changed, 97 insertions(+), 13 deletions(-)
diff --git a/src/boost/cpp/server/dserver.cpp b/src/boost/cpp/server/dserver.cpp
index d8ed68a..324e8f3 100644
--- a/src/boost/cpp/server/dserver.cpp
+++ b/src/boost/cpp/server/dserver.cpp
@@ -139,6 +139,12 @@ namespace PyDServer
delete ret;
return py_ret;
}
+
+ void duplicate_d_var(Tango::DServer &self)
+ {
+ Tango::Device_var d = self._this();
+ self.set_d_var(Tango::Device::_duplicate(d));
+ }
}
BOOST_PYTHON_FUNCTION_OVERLOADS(add_obj_polling_overload, PyDServer::add_obj_polling, 2, 4)
@@ -198,6 +204,7 @@ void export_dserver()
.def("get_poll_th_pool_size", &Tango::DServer::get_poll_th_pool_size)
.def("get_opt_pool_usage", &Tango::DServer::get_opt_pool_usage)
.def("get_poll_th_conf", &Tango::DServer::get_poll_th_conf)
+ .def("duplicate_d_var", &PyDServer::duplicate_d_var)
;
}
diff --git a/src/boost/cpp/server/tango_util.cpp b/src/boost/cpp/server/tango_util.cpp
index 2513606..65940a6 100644
--- a/src/boost/cpp/server/tango_util.cpp
+++ b/src/boost/cpp/server/tango_util.cpp
@@ -188,6 +188,66 @@ namespace PyUtil
self.server_set_event_loop(event_loop);
}
}
+
+ void set_use_db(bool use_db)
+ {
+ Tango::Util::_UseDb = use_db;
+ }
+
+ std::string get_orb_ior(Tango::Util& self)
+ {
+ Tango::Device_var d = self.get_dserver_device()->_this();
+ return self.get_orb()->object_to_string(d);
+ }
+
+ void orb_run(Tango::Util& self)
+ {
+ self.get_orb()->run();
+ }
+
+ bool init_db_ds(Tango::Util& self, boost::python::object py_device, const std::string &db_name)
+ {
+ Tango::DeviceImpl* dbase = boost::python::extract<Tango::DeviceImpl*>(py_device);
+
+ //
+ // Export devices to the outside world as CORBA named servant and to TANGO
+ // database
+ //
+ Tango::DeviceImpl *dserver;
+ Tango::DevVarStringArray *export_parms = new Tango::DevVarStringArray();
+
+ dserver = self.get_dserver_device();
+ dbase = self.get_device_by_name(db_name);
+ //
+ // export database as named servant
+ //
+ export_parms->length(5);
+
+ // export dserver object to TANGO database
+
+ Tango::Device_var d = dserver->_this();
+ dserver->set_d_var(Tango::Device::_duplicate(d));
+
+ const char *dserver_str_ior = Tango::Util::instance()->get_orb()->object_to_string(d);
+ const char *str_ior = Tango::Util::instance()->get_orb()->object_to_string(dbase->get_d_var());
+
+ boost::python::tuple dserver_pars = boost::python::make_tuple(dserver->get_name(),
+ dserver_str_ior, self.get_host_name(),
+ self.get_pid_str(), self.get_version_str());
+ py_device("db_export_device")(dserver_pars);
+
+ // export database object to TANGO database
+
+ boost::python::tuple pars = boost::python::make_tuple(dbase->get_name(),
+ str_ior, self.get_host_name(),
+ self.get_pid_str(), self.get_version_str());
+ py_device("db_export_device")(pars);
+
+ delete [] str_ior;
+ delete [] dserver_str_ior;
+
+ return true;
+ }
}
void init_python()
@@ -202,6 +262,11 @@ BOOST_PYTHON_FUNCTION_OVERLOADS (server_init_overload, PyUtil::server_init, 1, 2
void export_util()
{
+ class_<Tango::Interceptors>("Interceptors")
+ .def("create_thread", &Tango::Interceptors::create_thread)
+ .def("delete_thread", &Tango::Interceptors::delete_thread)
+ ;
+
class_<Tango::Util, boost::noncopyable>("_Util", no_init)
.def("init", PyUtil::init,
return_value_policy<reference_existing_object>())
@@ -263,5 +328,10 @@ void export_util()
.def_readonly("_FileDb", &Tango::Util::_FileDb)
.def("init_python", init_python)
.staticmethod("init_python")
+ .def("set_use_db", &PyUtil::set_use_db)
+ .staticmethod("set_use_db")
+ .def("get_orb_ior", &PyUtil::get_orb_ior)
+ .def("orb_run", &PyUtil::orb_run)
+ .def("init_db_ds", &PyUtil::init_db_ds)
;
}
diff --git a/src/boost/python/__init__.py b/src/boost/python/__init__.py
index 08ccd5f..23fb2f7 100644
--- a/src/boost/python/__init__.py
+++ b/src/boost/python/__init__.py
@@ -156,7 +156,7 @@ from ._PyTango import (AccessControlType, ApiUtil, ArchiveEventInfo,
StdNamedDevFailedVector, StdStringVector, SubDevDiag, TimeVal,
UserDefaultAttrProp, WAttribute, WRITE, WrongData, WrongNameSyntax,
alarm_flags, asyn_req_type, cb_sub_model, constants,
- raise_asynch_exception)
+ raise_asynch_exception, Interceptors)
ArgType = CmdArgType
diff --git a/src/boost/python/databaseds/database.py b/src/boost/python/databaseds/database.py
index d579778..c60e008 100644
--- a/src/boost/python/databaseds/database.py
+++ b/src/boost/python/databaseds/database.py
@@ -119,7 +119,7 @@ class DataBase (PyTango.Device_4Impl):
#------------------------------------------------------------------
def init_device(self):
self.debug_stream("In " + self.get_name() + ".init_device()")
- self.get_device_properties(self.get_device_class())
+ #self.get_device_properties(self.get_device_class())
self.attr_StoredProcedureRelease_read = ''
self.attr_Timing_average_read = [0.0]
self.attr_Timing_minimum_read = [0.0]
@@ -155,7 +155,7 @@ class DataBase (PyTango.Device_4Impl):
def read_StoredProcedureRelease(self, attr):
self.debug_stream("In " + self.get_name() + ".read_StoredProcedureRelease()")
#----- PROTECTED REGION ID(DataBase.StoredProcedureRelease_read) ENABLED START -----#
- self.attr_StoredProcedureRelease_read = db.get_stored_procedure_release()
+ self.attr_StoredProcedureRelease_read = self.db.get_stored_procedure_release()
#----- PROTECTED REGION END -----# // DataBase.StoredProcedureRelease_read
attr.set_value(self.attr_StoredProcedureRelease_read)
@@ -220,8 +220,6 @@ class DataBase (PyTango.Device_4Impl):
attr.set_value(self.attr_Timing_info_read)
-
-
#------------------------------------------------------------------
# Read Attribute Hardware
#------------------------------------------------------------------
@@ -647,7 +645,7 @@ class DataBase (PyTango.Device_4Impl):
"DataBase::ExportDevice()")
dev_name, IOR, host, pid, version = argin[:5]
- if pid.lower() == 'null'):
+ if pid.lower() == 'null':
pid = "-1"
self.db.export_device(dev_name, IOR, host, pid, version)
@@ -670,7 +668,7 @@ class DataBase (PyTango.Device_4Impl):
self.debug_stream("In " + self.get_name() + ".DbExportEvent()")
#----- PROTECTED REGION ID(DataBase.DbExportEvent) ENABLED START -----#
- if len(argin) < 5:
+ if len(argin) < 5:
self.warn_stream("DataBase::db_export_event(): insufficient export info for event ")
th_exc(DB_IncorrectArguments,
"insufficient export info for event",
@@ -2320,17 +2318,26 @@ class DataBaseClass(PyTango.DeviceClass):
#==================================================================
def main():
try:
+ db_name = "sys/database/" + sys.argv[1]
+ PyTango.Util.set_use_db(False)
py = PyTango.Util(sys.argv)
py.add_class(DataBaseClass,DataBase,'DataBase')
U = PyTango.Util.instance()
+
+ U.set_serial_model(PyTango.SerialModel.NO_SYNC)
U.server_init()
- U.server_run()
+ dbase = U.get_device_by_name(db_name)
+ U.init_db_ds(dbase, db_name)
+ U.orb_run()
+ #U.server_run()
- except PyTango.DevFailed,e:
- print '-------> Received a DevFailed exception:',e
- except Exception,e:
+ except PyTango.DevFailed as df:
+ print '-------> Received a DevFailed exception:',df
+ import traceback;traceback.print_exc()
+ except Exception as e:
print '-------> An unforeseen exception occured....',e
+ import traceback;traceback.print_exc()
if __name__ == '__main__':
main()
diff --git a/src/boost/python/databaseds/db_access.py b/src/boost/python/databaseds/db_access.py
index 49b28a2..afe8521 100644
--- a/src/boost/python/databaseds/db_access.py
+++ b/src/boost/python/databaseds/db_access.py
@@ -11,7 +11,7 @@ from db_errors import *
def get_create_db_statements():
statements = []
- with open("create_db_tables.sql.in") as f:
+ with open("create_db_tables.sql") as f:
lines = f.readlines()
# strip comments
lines = ( line for line in lines if not line.startswith('#') )
@@ -21,7 +21,7 @@ def get_create_db_statements():
lines = lines.replace("ENGINE=MyISAM","")
statements += lines.split(";")
- with open("create_db.sql.in") as f:
+ with open("create_db.sql") as f:
lines = f.readlines()
# strip comments
lines = ( line for line in lines if not line.lower().startswith('#') )
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git
More information about the debian-science-commits
mailing list