24 from rapp_platform_ros_communications.srv
import (
30 deleteDataSrvResponse,
32 updateDataSrvResponse,
34 whatRappsCanRunSrvResponse,
35 authTokenByServiceSrv,
36 authTokenByServiceSrvResponse,
39 from rapp_platform_ros_communications.msg
import (
43 from std_msgs.msg
import (
56 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_user_fetch_data_topic")
58 rospy.logerror(
"rapp_mysql_wrapper_user_fetch_data_topic")
60 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_user_write_data_topic")
62 rospy.logerror(
"rapp_mysql_wrapper_user_write_data_topic")
64 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_user_delete_data_topic")
66 rospy.logerror(
"rapp_mysql_wrapper_user_delete_data_topic")
68 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_user_update_data_topic")
70 rospy.logerror(
"rapp_mysql_wrapper_user_update_data_topic")
73 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_model_fetch_data_topic")
75 rospy.logerror(
"rapp_mysql_wrapper_model_fetch_data_topic")
77 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_model_write_data_topic")
79 rospy.logerror(
"rapp_mysql_wrapper_model_write_data_topic")
81 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_model_delete_data_topic")
83 rospy.logerror(
"rapp_mysql_wrapper_model_delete_data_topic")
85 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_model_update_data_topic")
87 rospy.logerror(
"rapp_mysql_wrapper_model_update_data_topic")
90 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_rapp_fetch_data_topic")
92 rospy.logerror(
"rapp_mysql_wrapper_rapp_fetch_data_topic")
94 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_rapp_write_data_topic")
96 rospy.logerror(
"rapp_mysql_wrapper_rapp_write_data_topic")
98 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_rapp_delete_data_topic")
100 rospy.logerror(
"rapp_mysql_wrapper_rapp_delete_data_topic")
102 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_rapp_update_data_topic")
104 rospy.logerror(
"rapp_mysql_wrapper_rapp_update_data_topic")
107 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_robot_fetch_data_topic")
109 rospy.logerror(
"rapp_mysql_wrapper_robot_fetch_data_topic")
111 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_robot_write_data_topic")
113 rospy.logerror(
"rapp_mysql_wrapper_robot_write_data_topic")
115 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_robot_delete_data_topic")
117 rospy.logerror(
"rapp_mysql_wrapper_robot_delete_data_topic")
119 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_robot_update_data_topic")
121 rospy.logerror(
"rapp_mysql_wrapper_robot_update_data_topic")
124 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_apps_robots_fetch_data_topic")
126 rospy.logerror(
"rapp_mysql_wrapper_apps_robots_fetch_data_topic")
128 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_apps_robots_write_data_topic")
130 rospy.logerror(
"rapp_mysql_wrapper_apps_robots_write_data_topic")
132 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_apps_robots_delete_data_topic")
134 rospy.logerror(
"rapp_mysql_wrapper_apps_robots_delete_data_topic")
136 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_apps_robots_update_data_topic")
138 rospy.logerror(
"rapp_mysql_wrapper_apps_robots_update_data_topic")
141 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_users_ontology_instances_fetch_data_topic")
143 rospy.logerror(
"rapp_mysql_wrapper_users_ontology_instances_fetch_data_topic")
145 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_users_ontology_instances_write_data_topic")
147 rospy.logerror(
"rapp_mysql_wrapper_users_ontology_instances_write_data_topic")
149 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_users_ontology_instances_delete_data_topic")
151 rospy.logerror(
"rapp_mysql_wrapper_users_ontology_instances_delete_data_topic")
153 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_users_ontology_instances_update_data_topic")
155 rospy.logerror(
"rapp_mysql_wrapper_users_ontology_instances_update_data_topic")
158 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_view_users_robots_apps_topic")
160 rospy.logerror(
"rapp_mysql_wrapper_view_users_robots_apps_topic")
163 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_what_rapps_can_run_topic")
165 rospy.logerror(
"rapp_mysql_wrapper_what_rapps_can_run Not found error")
168 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_auth_token_by_service_topic")
170 rospy.logerror(
"rapp_mysql_wrapper_auth_token_by_service_topic Not found error")
176 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_fetch_data_topic")
178 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_fetch_data_topic")
180 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_write_data_topic")
182 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_write_data_topic")
184 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_delete_data_topic")
186 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_delete_data_topic")
188 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_update_data_topic")
190 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_update_data_topic")
194 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_service_fetch_data_topic")
196 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_service_fetch_data_topic")
198 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_service_write_data_topic")
200 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_service_write_data_topic")
202 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_service_delete_data_topic")
204 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_service_delete_data_topic")
206 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_service_update_data_topic")
208 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_service_update_data_topic")
212 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_service_arguments_fetch_data_topic")
214 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_service_arguments_fetch_data_topic")
216 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_service_arguments_write_data_topic")
218 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_service_arguments_write_data_topic")
220 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_service_arguments_delete_data_topic")
222 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_service_arguments_delete_data_topic")
224 self.
serv_topic = rospy.get_param(
"rapp_mysql_wrapper_cloud_agent_service_arguments_update_data_topic")
226 rospy.logerror(
"rapp_mysql_wrapper_cloud_agent_service_arguments_update_data_topic")
236 res = writeDataSrvResponse()
237 db_username,db_password=self.
getLogin()
238 con = mdb.connect(
'localhost', db_username, db_password,
'RappStore');
241 if (len(returncols)>1):
242 returncols=
"("+returncols+
")"
245 for i
in range(len(req.req_data)):
251 query=
"Insert into "+tblName+
" "+ returncols+
" values "+values
252 cur.execute(
"LOCK TABLES "+tblName+
" WRITE")
254 cur.execute(
"UNLOCK TABLES")
256 res.success.data=
True
257 res.trace.append(
"Success")
259 res.trace.append((
"Database Error %d: %s" % (e.args[0],e.args[1])))
260 res.success.data=
False
261 res.error=
"Error %d: %s" % (e.args[0],e.args[1])
262 except IndexError, e:
263 res.trace.append(
"IndexError: " +str(e))
264 res.success.data=
False
265 res.error=
"IndexError: " +str(e)
267 res.success.data=
False
268 res.trace.append(
"IOError: " +str(e))
269 res.error=
"IOError: " +str(e)
278 res = deleteDataSrvResponse()
279 db_username,db_password=self.
getLogin()
280 con = mdb.connect(
'localhost', db_username, db_password,
'RappStore');
283 query=
"Delete from "+tblName+where
284 cur.execute(
"LOCK TABLES "+tblName+
" WRITE")
286 cur.execute(
"UNLOCK TABLES")
288 res.success.data=
True
289 res.trace.append(
"Success")
291 res.trace.append((
"Database Error %d: %s" % (e.args[0],e.args[1])))
292 res.success.data=
False
293 res.error=
"Error %d: %s" % (e.args[0],e.args[1])
294 except IndexError, e:
295 res.trace.append(
"IndexError: " +str(e))
296 res.success.data=
False
297 res.error=
"IndexError: " +str(e)
299 res.success.data=
False
300 res.trace.append(
"IOError: " +str(e))
301 res.error=
"IOError: " +str(e)
310 res = updateDataSrvResponse()
311 db_username,db_password=self.
getLogin()
312 con = mdb.connect(
'localhost', db_username, db_password,
'RappStore');
316 query=
"Update "+tblName+
" SET "+returncols+where
318 cur.execute(
"LOCK TABLES "+tblName+
" WRITE")
320 cur.execute(
"UNLOCK TABLES")
322 res.success.data=
True
323 res.trace.append(
"Success")
325 res.trace.append((
"Database Error %d: %s" % (e.args[0],e.args[1])))
326 res.success.data=
False
327 res.error=
"Error %d: %s" % (e.args[0],e.args[1])
328 except IndexError, e:
329 res.trace.append(
"IndexError: " +str(e))
330 res.success.data=
False
331 res.error=
"IndexError: " +str(e)
333 res.success.data=
False
334 res.trace.append(
"IOError: " +str(e))
335 res.error=
"IOError: " +str(e)
344 res = fetchDataSrvResponse()
345 db_username,db_password=self.
getLogin()
346 con = mdb.connect(
'localhost', db_username, db_password,
'RappStore');
350 query=
"SELECT "+returncols+
" FROM "+tblName+where
352 result_set = cur.fetchall()
353 for i
in range(len(result_set)):
354 line=StringArrayMsg()
355 for j
in range(len(result_set[i])):
356 temp_s=String(result_set[i][j])
357 line.s.append((str(result_set[i][j])))
358 res.res_data.append(line)
361 if (returncols==
"*"):
364 res.res_cols=req.req_cols
366 res.success.data=
True
367 res.trace.append(
"Success")
369 res.trace.append((
"Database Error %d: %s" % (e.args[0],e.args[1])))
370 res.success.data=
False
371 res.error=
"Error %d: %s" % (e.args[0],e.args[1])
372 except IndexError, e:
373 res.trace.append(
"IndexError: " +str(e))
374 res.success.data=
False
375 res.error=
"IndexError: " +str(e)
377 res.success.data=
False
378 res.trace.append(
"IOError: " +str(e))
379 res.error=
"IOError: " +str(e)
388 res = whatRappsCanRunSrvResponse()
389 db_username,db_password=self.
getLogin()
390 con = mdb.connect(
'localhost', db_username, db_password,
'RappStore');
392 query=
"SELECT rapp_id from tblRappsModelsVersion where model_id='"+req.model_id+
"' and minimum_coreagent_version<='"+req.core_agent_version+
"'";
394 result_set = cur.fetchall()
395 for i
in range(len(result_set)):
396 line=StringArrayMsg()
397 for j
in range(len(result_set[i])):
398 temp_s=String(result_set[i][j])
399 line.s.append((str(result_set[i][j])))
400 res.res_data.append(line)
402 res.success.data=
True
403 res.trace.append(
"Success")
405 res.trace.append((
"Database Error %d: %s" % (e.args[0],e.args[1])))
406 res.success.data=
False
407 res.error=
"Error %d: %s" % (e.args[0],e.args[1])
408 except IndexError, e:
409 res.trace.append(
"IndexError: " +str(e))
410 res.success.data=
False
411 res.error=
"IndexError: " +str(e)
413 res.success.data=
False
414 res.trace.append(
"IOError: " +str(e))
415 res.error=
"IOError: " +str(e)
420 res = authTokenByServiceSrvResponse()
421 res.authentication_success=
False
422 db_username,db_password=self.
getLogin()
423 con = mdb.connect(
'localhost', db_username, db_password,
'RappStore');
425 cur.execute(
"select service_name from application_token_services where token_id=(select id from application_token where token=%s) and service_name=%s",(req.token,req.service_name))
426 result_set = cur.fetchall()
428 if(result_set
and len(result_set[0])>0):
429 if(result_set[0][0]==req.service_name):
430 res.authentication_success=
True
432 cur.execute(
"select service_name from application_token_services where token_id=(select id from application_token where token=%s) and service_name='*'",(req.token))
433 result_set = cur.fetchall()
434 if(result_set
and len(result_set[0])>0 ):
435 if(result_set[0][0]==
'*'):
436 res.authentication_success=
True
440 res.trace.append((
"Database Error %d: %s" % (e.args[0],e.args[1])))
442 res.error=
"Error %d: %s" % (e.args[0],e.args[1])
449 res.trace.append(
"IOError: " +str(e))
450 res.error=
"IOError: " +str(e)
464 for i
in range(len(cols)):
466 returncols=returncols+cols[i]
468 returncols=returncols+
","+cols[i]
479 for i
in range(len(cols)):
481 returnquery=returnquery+cols[i].s[0]+
"=\""+cols[i].s[1]+
"\""
483 returnquery=returnquery+
" AND "+cols[i].s[0]+
"=\""+cols[i].s[1]+
"\""
484 returnquery=
" WHERE "+returnquery
490 db_username,db_password=self.
getLogin()
492 con = mdb.connect(
'localhost', db_username, db_password,
'RappStore');
494 cur.execute(
"Show columns from "+tblName)
495 result_set = cur.fetchall()
497 for row
in result_set:
498 Columns=Columns+[String(str(row[0]))]
501 print "Error %d: %s" % (e.args[0],e.args[1])
506 fh = open(
"/etc/db_credentials",
"r")
507 db_username=fh.readline()
508 db_username=db_username.split( )[0]
509 db_password=fh.readline()
510 db_password=db_password.split()[0]
511 return db_username,db_password
517 db_username,db_password=self.
getLogin()
518 con = mdb.connect(
'localhost', db_username, db_password,
'RappStore')
520 cur.execute(
"SELECT VERSION()")
522 print "Database version : %s " % ver
525 print "Error %d: %s" % (e.args[0],e.args[1])
531 res = fetchDataSrvResponse()
539 res = writeDataSrvResponse()
547 res = deleteDataSrvResponse()
555 res = updateDataSrvResponse()
563 res = fetchDataSrvResponse()
571 res = writeDataSrvResponse()
579 res = deleteDataSrvResponse()
587 res = updateDataSrvResponse()
595 res = fetchDataSrvResponse()
603 res = writeDataSrvResponse()
611 res = deleteDataSrvResponse()
619 res = updateDataSrvResponse()
627 res = fetchDataSrvResponse()
635 res = writeDataSrvResponse()
643 res = deleteDataSrvResponse()
651 res = updateDataSrvResponse()
659 res = fetchDataSrvResponse()
667 res = writeDataSrvResponse()
675 res = deleteDataSrvResponse()
683 res = updateDataSrvResponse()
691 res = fetchDataSrvResponse()
692 res=self.
fetchData(req,
"tblUsersOntologyInstances")
699 res = writeDataSrvResponse()
700 res=self.
writeData(req,
"tblUsersOntologyInstances")
707 res = deleteSrvResponse()
708 res=self.
deleteData(req,
"tblUsersOntologyInstances")
715 res = updateDataSrvResponse()
716 res=self.
updateData(req,
"tblUsersOntologyInstances")
723 res = fetchDataSrvResponse()
724 res=self.
fetchData(req,
"usersrobotsapps")
731 res = whatRappsCanRunSrvResponse()
739 res = authTokenByServiceSrvResponse()
749 res = fetchDataSrvResponse()
757 res = writeDataSrvResponse()
765 res = deleteDataSrvResponse()
773 res = updateDataSrvResponse()
781 res = fetchDataSrvResponse()
782 res=self.
fetchData(req,
"cloud_agent_service")
789 res = writeDataSrvResponse()
790 res=self.
writeData(req,
"cloud_agent_service")
797 res = deleteDataSrvResponse()
798 res=self.
deleteData(req,
"cloud_agent_service")
805 res = updateDataSrvResponse()
806 res=self.
updateData(req,
"cloud_agent_service")
813 res = fetchDataSrvResponse()
814 res=self.
fetchData(req,
"cloud_agent_service_arguments")
821 res = writeDataSrvResponse()
822 res=self.
writeData(req,
"cloud_agent_service_arguments")
829 res = deleteDataSrvResponse()
830 res=self.
deleteData(req,
"cloud_agent_service_arguments")
837 res = updateDataSrvResponse()
838 res=self.
updateData(req,
"cloud_agent_service_arguments")
def tblCloudAgentServiceUpdateDataHandler
The tbl cloud_agent_service update data service callback.
def tblUserFetchDataHandler
The tbl user fetch data service callback.
def tblRappWriteDataHandler
The tbl rapp write data service callback.
def authTokenByServiceDataHandler
The authTokenByService service callback.
def tblCloudAgentUpdateDataHandler
The tbl cloud_agent update data service callback.
def tblRobotWriteDataHandler
The tbl robot write data service callback.
The mysql wrapper ros node.
def tblRappUpdateDataHandler
The tbl rapp update data service callback.
def tblRobotFetchDataHandler
The tbl robot fetch data service callback.
def writeData
Implements the general write data to table function.
def getTableColumnNames
Gets the columns of the table.
def tblUsersOntologyInstancesUpdateDataHandler
The tbl usersOntologyInstances update data service callback.
def updateData
Implements the general update data from table function.
def tblCloudAgentServiceArgumentsFetchDataHandler
The tbl cloud_agent_service_arguments fetch data service callback.
def tblAppsRobotsWriteDataHandler
The tbl appsRobots write data service callback.
def checkConnection
Checks connectivity to the DB.
def tblCloudAgentServiceArgumentsUpdateDataHandler
The tbl cloud_agent_service_arguments update data service callback.
def tblAppsRobotsUpdateDataHandler
The tbl appsRobots update data service callback.
def tblCloudAgentServiceDeleteDataHandler
The tbl cloud_agent_service delete data service callback.
def tblCloudAgentServiceArgumentsDeleteDataHandler
The tbl cloud_agent_service_arguments delete data service callback.
def tblAppsRobotsDeleteDataHandler
The tbl appsRobots delete data service callback.
def tblUsersOntologyInstancesDeleteDataHandler
The tbl usersOntologyInstances delete data service callback.
def fetchData
Implements the general fetch data from table function.
def tblRobotDeleteDataHandler
The tbl robot delete data service callback.
def constructAndQuery
Construcs the where= ..and where=...
def tblUsersOntologyInstancesWriteDataHandler
The tbl usersOntologyInstances write data service callback.
def tblAppsRobotsFetchDataHandler
The tbl appsRobots fetch data service callback.
def tblCloudAgentDeleteDataHandler
The tbl cloud_agent delete data service callback.
def tblCloudAgentFetchDataHandler
The tbl cloud_agent fetch data service callback.
def tblUsersOntologyInstancesFetchDataHandler
The tbl usersOntologyInstances fetch data service callback.
def tblRappFetchDataHandler
The tbl rapp fetch data service callback.
def tblCloudAgentServiceArgumentsWriteDataHandler
The tbl cloud_agent_service_arguments write data service callback.
def __init__
Default contructor.
def tblModelFetchDataHandler
The tbl model fetch data service callback.
def tblModelWriteDataHandler
The tbl model write data service callback.
def tblCloudAgentWriteDataHandler
The tbl cloud_agent write data service callback.
def constructCommaColumns
Places commas between columns and constructs a string.
def getLogin
Loads login details from file.
def tblCloudAgentServiceWriteDataHandler
The tbl cloud_agent_service write data service callback.
def whatRappsCanRunDataHandler
The what rappRappCanRun service callback.
def tblCloudAgentServiceFetchDataHandler
The tbl cloud_agent_service fetch data service callback.
def whatRappsCanRun
Implements the whatRappsCanRun service.
def tblUserDeleteDataHandler
The tbl user delete data service callback.
def tblRobotUpdateDataHandler
The tbl robot update data service callback.
def tblRappDeleteDataHandler
The tbl rapp delete data service callback.
def tblModelUpdateDataHandler
The tbl model update data service callback.
def tblUserUpdateDataHandler
The tbl user update data service callback.
def deleteData
Implements the general delete data from table function.
def viewUsersRobotsAppsFetchDataHandler
The view usersRobotsApps fetch data service callback.
def tblModelDeleteDataHandler
The tbl model delete data service callback.
def tblUserWriteDataHandler
The tbl user write data service callback.