Skip to content

Commit

Permalink
[jsk_robot_startup/smach_to_mail] Use yaml file to set address
Browse files Browse the repository at this point in the history
  • Loading branch information
tkmtnt7000 authored and knorth55 committed Aug 23, 2022
1 parent 21d8ea8 commit eb8dad9
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions jsk_robot_common/jsk_robot_startup/scripts/smach_to_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import base64
import cv2
import datetime
import os
import pickle
import rospy
import sys
import yaml

from cv_bridge import CvBridge
from jsk_robot_startup.msg import Email
Expand All @@ -28,16 +30,27 @@ def __init__(self):
self.bridge = CvBridge()
self.smach_state_list = {} # for status list
self.smach_state_subject = {} # for status subject
if rospy.has_param("~sender_address"):
self.sender_address = rospy.get_param("~sender_address")
yaml_path = rospy.get_param(
'~email_info', "/var/lib/robot/email_info.yaml")
if os.path.exists(yaml_path):
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)
self.sender_address = self.email_info['sender_address']
self.receiver_address = self.email_info['receiver_address']
else:
rospy.logerr("Please set rosparam {}/sender_address".format(
rospy.get_name()))
if rospy.has_param("~receiver_address"):
self.receiver_address = rospy.get_param("~receiver_address")
else:
rospy.logerr("Please set rosparam {}/receiver_address".format(
if rospy.has_param("~sender_address"):
self.sender_address = rospy.get_param("~sender_address")
else:
rospy.logerr("Please set rosparam {}/sender_address".format(
rospy.get_name()))
if rospy.has_param("~receiver_address"):
self.receiver_address = rospy.get_param("~receiver_address")
else:
rospy.logerr("Please set rosparam {}/receiver_address".format(
rospy.get_name()))


def _status_cb(self, msg):
Expand Down

0 comments on commit eb8dad9

Please sign in to comment.