import os import sys import paramiko pw = os.environ["DEPLOY_PASSWORD"] c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("20.191.152.26", username="wakka", password=pw, timeout=30) cmd = r"""sudo docker exec guest-chat bundle exec rails runner " bot = AgentBot.find(1) puts 'bot_id=' + bot.id.to_s puts 'outgoing=' + bot.outgoing_url.to_s if bot.respond_to?(:access_token) puts 'access_token=' + bot.access_token.token.to_s rescue puts 'no token method' end at = AccessToken.find_by(owner_type: 'AgentBot', owner_id: bot.id) rescue nil if at puts 'AccessToken=' + at.token.to_s else at2 = bot.try(:access_token) puts 'try_access_token=' + (at2&.token || 'nil').to_s end " """ _, o, e = c.exec_command(cmd, timeout=90) sys.stdout.buffer.write(o.read()) sys.stdout.buffer.write(e.read()) c.close()