gpt4 book ai didi

ssh - 如何通过robotframework执行ssh命令

转载 作者:行者123 更新时间:2023-12-02 13:55:39 24 4
gpt4 key购买 nike

谁能告诉我我在下面的代码中犯了什么错误,我正在尝试使用机器人框架运行 shell 命令,并且我已经使用以下命令安装了 sshlibrary 模块 - pip install robotframework-sshlibrary .但我仍然收到导入 SSHLibrary 失败的错误。我的操作系统是 Ubuntu14.04。

部署机器人

*** Settings ***
Library SSHLibrary
Resource configuration.txt

*** Variables ***
${OBR_HOST} 10.110.72.192
${OBR_USERNAME} root
${OBR_PASSWORD} password

*** Test Cases ***

Deploy OBR machine code
${output}= Execute Command /root/deploy.sh
log to console ${\n}${output}

*** Keywords ***
open_connection_and_login
Open Connection ${OBR_HOST}
Login ${OBR_USERNAME} ${OBR_PASSWORD}

执行日志

root@92:~# pybot ssh-example.robot 
[ ERROR ] Error in file '/root/ssh-example.robot': Importing test library 'SSHLibrary' failed: ImportError: Importing Paramiko library failed. Make sure you have Paramiko installed.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/__init__.py", line 15, in <module>
from .library import SSHLibrary
File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/library.py", line 22, in <module>
from .client import SSHClient
File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/client.py", line 20, in <module>
from pythonclient import PythonSSHClient as SSHClient
File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/pythonclient.py", line 21, in <module>
'Importing Paramiko library failed. '
PYTHONPATH:
/usr/local/bin
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
==============================================================================
Ssh-Example
==============================================================================
Execute Deploy command | FAIL |
Parent suite setup failed:
No keyword with name 'Open Connection' found.
------------------------------------------------------------------------------
Ssh-Example | FAIL |
Suite setup failed:
No keyword with name 'Open Connection' found.

Also suite teardown failed:
No keyword with name 'Close All Connections' found.

1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
root@92:~# pip install robotframework-sshlibrary
Requirement already satisfied (use --upgrade to upgrade): robotframework-sshlibrary in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): robotframework in /usr/local/lib/python2.7/dist-packages (from robotframework-sshlibrary)
Requirement already satisfied (use --upgrade to upgrade): paramiko>=1.8.0 in /usr/local/lib/python2.7/dist-packages (from robotframework-sshlibrary)
Cleaning up...

最佳答案

在涉及 Robot Framework 之前,您的错误似乎发生在 SSHLibrary/pythonclient.py 中。尝试制作一个导入 Paramiko 的小 Python 脚本。有时 pippybot 使用不同版本的 Python。尝试比较 head -n1 $(which pip)head -n1 $(which pybot) 的输出来检查。

关于ssh - 如何通过robotframework执行ssh命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43165539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com