Skip to content

Commit

Permalink
[jsk_robot_startup/email_topic] Not using yaml to set email config
Browse files Browse the repository at this point in the history
  • Loading branch information
tkmtnt7000 committed Sep 8, 2022
1 parent 1ff86c9 commit df91f52
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions jsk_robot_common/jsk_robot_startup/scripts/email_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
class EmailTopic(object):
"""
This node sends email based on received rostopic (jsk_robot_startup/Email).
Default values can be set by using `~email_info`
Default ~sender_address and ~receiver_address can be set from rosparam
Default values can be set by using `~email_info`(DEPRECATED)
The yaml file is like the following:
subject: hello
Expand All @@ -38,11 +39,18 @@ def __init__(self):
yaml_path = rospy.get_param(
'~email_info', "/var/lib/robot/email_info.yaml")
if os.path.exists(yaml_path):
rospy.logwarn("Using ~email_info as email config is deprecated.")
rospy.logwarn("Set ~sender_address and ~receiver_address directory as rosparam")
with open(yaml_path) as yaml_f:
self.email_info = yaml.load(yaml_f)
rospy.loginfo(
"{} is loaded as email config file.".format(yaml_path))
rospy.loginfo(self.email_info)
else:
self.email_info['sender_address'] = rospy.get_param(
"~sender_address", jsk_robot@example.com)
self.email_info['receiver_address'] = rospy.get_param(
"~receiver_address", jsk_robot@example.com)
rospy.loginfo(self.email_info)
self.subscriber = rospy.Subscriber(
'email', Email, self._cb, queue_size=1)

Expand Down

0 comments on commit df91f52

Please sign in to comment.