Skip to content

Commit e041c03

Browse files
committed
give clearer feedback
1 parent 6d3aa67 commit e041c03

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

script/create_session

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ def main():
1818
"""Creates a new tmux session if it does not yet exist"""
1919
rospy.init_node('create_catmux_session', anonymous=True)
2020
session_name = rospy.get_param('~session_name', 'catmux')
21-
if safe_call(['tmux', 'has-session', '-t', session_name]):
21+
try:
22+
subprocess.check_call(['tmux', 'has-session', '-t', session_name])
2223
rospy.logwarn('Session with name "%s" already exists. Not overwriting session.',
2324
session_name)
2425
sys.exit(0)
26+
except subprocess.CalledProcessError:
27+
# When has-session returns non-zero exit code, the session already exists or there is
28+
# probably something severely wrong. TODO: This could be done better probably
29+
pass
2530

2631
if not safe_call(['tmux', 'new-session', '-s', session_name, '-d']):
2732
sys.exit(1)
2833

34+
rospy.loginfo('Created session "{}"'.format(session_name))
35+
2936
if __name__ == "__main__":
3037
main()

0 commit comments

Comments
 (0)