2016-04-11 11 views
-1

私はファブリックを使用してリモートホストに接続しています。そこにいるとき、私が作ったスクリプトを呼び出しようとしています。しかし、私は私のFabfile.py内部からスクリプトを呼び出すときに、それは私が(そうではない、私のリモートホスト)からfabfileを起動するマシンから、私が与えたパスがあると仮定しPythonファブリック呼び出しスクリプト "リモートパス"

私が持っている私の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のフォルダからファイルを開こうとします。引数に「遠隔のパス」を与える方法はありますか?ファイルをダウンロードしないでください。 呼び出す前にoperation.putでスクリプトservclasse.pyをアップロードする必要がありますか?


編集:私のservclasseで詳細 私はこれを持っている:

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

を.contrib.files.append'関数を空のファイル 'run( 'cat my.file')'に追加しますが、それを動作させることはできません。これは解決策ですか? – pwnsauce

+0

あなたの問題に関連する外部スクリプト( 'servclasse.py')の部分を投稿してください。 – fernandezcuesta

答えて

0

機能open()が問題でした。 私はので、私は、誰かが1日、このトピックを読む場合にはそれをここにドロップしますそれを行う方法を考え出した:私は `生地を使用しようとしました

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 
関連する問題