Skip to content

Commit

Permalink
use rosparam when loading config file, remove catch the exception, re…
Browse files Browse the repository at this point in the history
…move .gitignore
  • Loading branch information
mqcmd196 authored and knorth55 committed Aug 24, 2021
1 parent 15740a5 commit e66b840
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 0 additions & 1 deletion dialogflow_task_executive/.gitignore

This file was deleted.

7 changes: 6 additions & 1 deletion dialogflow_task_executive/launch/webhook_server.launch
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<launch>
<node name="dialogflow_https_server" pkg="dialogflow_task_executive" type="webhook_server.py" />
<arg name="webhook_config" default="$(find dialogflow_task_executive)/config/webhook.json" />
<node name="dialogflow_https_server" pkg="dialogflow_task_executive" type="webhook_server.py">
<rosparam subst_value="true">
webhook_config: $(arg webhook_config)
</rosparam>
</node>
</launch>
14 changes: 6 additions & 8 deletions dialogflow_task_executive/node_scripts/webhook_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from urllib.parse import urlparse, parse_qs
import ssl

import json
import os, json


class Server(object):
Expand All @@ -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']
Expand Down Expand Up @@ -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()

0 comments on commit e66b840

Please sign in to comment.