Python - Fabric - 获取文件

标签 python linux python-2.7 get fabric

我正在尝试使用 fabric 编写一个简单的 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

我当前的代码是:

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/')

如有任何帮助,我们将不胜感激!

最佳答案

fabric.api.get已经是一种方法。当您执行 from fabric.api import * 时,您正在导入 fabricget。您应该重命名您的 get 函数以避免冲突。

abc 函数中,您需要调用 get

def abc(p1,p2):
    get(p1, p2)

编辑: 通过 fabric 执行函数时,参数通过命令行传递 IE。 $ fab abc:string1,string2

关于Python - Fabric - 获取文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33401907/

相关文章:

python - 如何正确转换列表的输出值以将它们用作函数内的参数?

python - 如何删除scrapy函数中的项目名称?

java - 在目录内的所有文件中搜索字符串

c - 在 c 中调用 select 后超时是否改变?

python - Google App Engine - ConnectionError : ('Connection aborted.' , 错误 (13, 'Permission denied' ))

python - 在 glade 中使用文件选择器对话框

python - 通过全批量训练将字母图像训练到神经网络

linux - 如何在 Ubuntu 服务器上连续运行 go 应用程序

python - 字典变量的 MemoryError

python - 这种情况下如何让多个python程序进行通信呢?