我的服务器很少,用户名和密码相同。如何传递包含服务器列表的变量?
[{'feed': 16, 'id': ['AB-16007891']}, {'feed': 12, 'id': ['HA-4625798']}, {'feed': 18, 'id': ['GR-4444545']}, {'feed': 11, 'id': ['BC-4447764']}, {'feed': 12, 'id': ['HA-46257854']}]
我尝试了注释代码,但是没有用(不起作用)
有一种方法:
[{'feed': 16, 'id': ['AB-16007891']}, {'feed': 12, 'id': ['HA-4625798','HA-46257854']}, {'feed': 18, 'id': ['GR-4444545']}, {'feed': 11, 'id': ['BC-4447764']}]
但是每次我都无法通过(键入)我的用户名和密码时。
所以我想将这些凭据存储在变量中,我需要传递它。
答案 0 :(得分:0)
您想要这样的东西吗?
from fabric import Connection
#how to use:
# just place this in a place from where you can import it and thats it
#you dont need to do more you just import the import that you have made
#and do something like:
#place this program with the name connect.py in your python libarie
#and run somewere else in a other program the things below here:
#import connect
#re = connect.connect()
#do your other stuff then here
def connect():
#it works that it returns the value of the connection
#so you can do what you want
return re = Connection(host="madhu@server1", connect_kwargs={"password": "*****"}).run('w')