azn*_*onn 1 python linux get fabric python-2.7
我正在尝试使用结构编写一个简单的 python 代码,以使用 get() 函数将文件从一台主机传输到另一台主机,尽管我不断收到错误消息:
MacBook-Pro-3:PythonsScripts$ fab get:'/tmp/test','/tmp/test'
[hostname] Executing task 'get'
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/fabric/main.py", line 743, in main
*args, **kwargs
File "/Library/Python/2.7/site-packages/fabric/tasks.py", line 387, in execute
multiprocessing
File "/Library/Python/2.7/site-packages/fabric/tasks.py", line 277, in _execute
return task.run(*args, **kwargs)
File "/Library/Python/2.7/site-packages/fabric/tasks.py", line 174, in run
return self.wrapped(*args, **kwargs)
File "/Users/e0126914/Desktop/PYTHON/PythonsScripts/fabfile.py", line 128, in get
get('/tmp/test','/tmp/test') ***This line repeats many times then last error below***
RuntimeError: maximum recursion depth exceeded
Run Code Online (Sandbox Code Playgroud)
我目前的代码是:
from fabric.api import *
from getpass import getpass
from fabric.decorators import runs_once
env.hosts = ['hostname']
env.port = '22'
env.user = 'parallels'
env.password="password"
def abc(remote_path, local_path):
abc('/tmp/test','/tmp/')
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!
fabric.api.get已经是一种方法。当你执行from fabric.api import *你导入fabric的get。您应该重命名您的get函数以避免冲突。
从abc函数内部,您需要调用get
def abc(p1,p2):
get(p1, p2)
Run Code Online (Sandbox Code Playgroud)
编辑:当通过结构执行函数时,参数通过命令行传递,即。 $ fab abc:string1,string2