Python 面料调用脚本 "remote path"

Python fabric calling script "remote path"

我正在使用结构连接到远程主机,当我在那里时,我尝试调用我制作的脚本(它解析我在参数中提供的文件)。但是当我从 Fabfile.py 内部调用脚本时,它假定我提供的路径来自我启动 fabfile 的机器(所以不是我的远程主机)

在我的 fabfile.py 我有:

Import import servclasse
env.host='host1'
def listconf():
  #here I browes to the correct folder
  s=servclasse.Server("my.file") #this is where I want it to open the host1:my.file file and instanciate a classe from what it parsed

如果我这样做,它会尝试从 servclass.py 所在的文件夹中打开文件。有没有办法在参数中给出 "remote path" ?我宁愿不下载文件。 我应该在调用之前上传带有 operation.put 的脚本 servclasse.py 吗?


编辑:更多信息 在我的 servclasse 我有这个:

def __init__(self, path):
    self.config = ConfigParser.ConfigParser(allow_no_value=True)
    self.config.readfp(open(path))

函数 open() 是问题所在。 我想出了怎么做,所以我会把它放在这里,以防有一天有人读到这个主题:

def listconf():
 #first I browes to the correct folder then
    contents = StringIO.StringIO()
    get("MyFile",contents)
    contents.seek(0)
    s=Server(contents)

并在 servclass.py

def __init__(self, objfile):
    self.config = ConfigParser.ConfigParser(allow_no_value=True)
    self.config.readfp(objfile)
    #and i do my stuffs