本文整理汇总了Python中connection.Connection.get_robot_name方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.get_robot_name方法的具体用法?Python Connection.get_robot_name怎么用?Python Connection.get_robot_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connection.Connection
的用法示例。
在下文中一共展示了Connection.get_robot_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: log_handler
# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_robot_name [as 别名]
def log_handler(ns):
"""Display the naoqi tail logs to the terminal with colors."""
verb = verbose_print(ns.verbose)
conn = Connection(verb)
p = '/var/log/naoqi/tail-naoqi.log'
if ns.cp:
try:
lp = config.read_field('log_path')
if not lp:
lp = '~'
log_path = os.path.expanduser(lp)
conn.remote_get(p, log_path)
print('secure copied logs to ' +
col.blue(os.path.join(log_path, 'tail-naoqi.log')))
except RuntimeError:
print(col.red('error') + ': tail-naoqi.log not found on ' +
col.magenta(conn.get_robot_name()))
else:
transport = conn.ssh.get_transport()
channel = transport.open_session()
remote_command = 'tail -f ' + p + ' & { read ; kill %1; }'
channel.exec_command(remote_command)
def print_log(log):
log = re.sub(r'(\[E\].*)\n', r'\033[0;31m\1\033[0m\n', log) # error red
log = re.sub(r'(\[W\].*)\n', r'\033[0;33m\1\033[0m\n', log) # warning yellow
sys.stdout.write(log)
while True:
try:
rl, wl, xl = select.select([channel], [], [], 0.0)
if len(rl) > 0: # Must be stdout
print_log(channel.recv(1024))
except:
try:
print('close the SSH Client')
conn.ssh.close()
except Exception as e:
print('exception when closing SSH Client: {}'.format(e))
finally:
break
示例2: rest_handler
# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_robot_name [as 别名]
def rest_handler(ns):
"""Put the robot to rest."""
verb = verbose_print(ns.verbose)
conn = Connection(verb, ssh=False)
print('Put {} to rest'.format(conn.get_robot_name()))
conn.rest()
示例3: wake_handler
# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_robot_name [as 别名]
def wake_handler(ns):
"""Wake up the robot."""
verb = verbose_print(ns.verbose)
conn = Connection(verb, ssh=False)
print('Waking up {}'.format(conn.get_robot_name()))
conn.wake_up()