From e66b84047baa08191487752dd52a2ee6e1b59d5d Mon Sep 17 00:00:00 2001 From: Yoshiki Obinata Date: Thu, 3 Jun 2021 16:31:57 +0900 Subject: [PATCH] use rosparam when loading config file, remove catch the exception, remove .gitignore --- dialogflow_task_executive/.gitignore | 1 - .../launch/webhook_server.launch | 7 ++++++- .../node_scripts/webhook_server.py | 14 ++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) delete mode 100644 dialogflow_task_executive/.gitignore diff --git a/dialogflow_task_executive/.gitignore b/dialogflow_task_executive/.gitignore deleted file mode 100644 index 405d9fa8f..000000000 --- a/dialogflow_task_executive/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/config/webhook.json \ No newline at end of file diff --git a/dialogflow_task_executive/launch/webhook_server.launch b/dialogflow_task_executive/launch/webhook_server.launch index 4e434d21f..a0876a2c7 100644 --- a/dialogflow_task_executive/launch/webhook_server.launch +++ b/dialogflow_task_executive/launch/webhook_server.launch @@ -1,3 +1,8 @@ - + + + + webhook_config: $(arg webhook_config) + + diff --git a/dialogflow_task_executive/node_scripts/webhook_server.py b/dialogflow_task_executive/node_scripts/webhook_server.py index 8bb303c34..4eaa23bf8 100644 --- a/dialogflow_task_executive/node_scripts/webhook_server.py +++ b/dialogflow_task_executive/node_scripts/webhook_server.py @@ -9,7 +9,7 @@ from urllib.parse import urlparse, parse_qs import ssl -import json +import os, json class Server(object): @@ -22,7 +22,8 @@ def __init__(self): You need to set the path to certfile for ssl connection. You shouldn't use self-signed certificate. """ rospack = rospkg.RosPack() - conffile = rospack.get_path('dialogflow_task_executive') + "/config/webhook.json" + conffile = rospy.get_param('~webhook_config', os.path.join(rospack.get_path('dialogflow_task_executive'), 'config/webhook.json')) + with open(conffile) as f: json_dict = json.load(f) self.host = json_dict['host'] @@ -117,9 +118,6 @@ def _bad_request(self): if __name__ == '__main__': - try: - server = Server() - rospy.loginfo('DialogFlow HTTPS Server starts - %s:%s' % (server.host, server.port)) - server.httpd.serve_forever() - except Exception as e: - rospy.logerr(e) + server = Server() + rospy.loginfo('DialogFlow HTTPS Server starts - %s:%s' % (server.host, server.port)) + server.httpd.serve_forever()