2017-05-19 5 views
0

직물의 rsync_project 기능을 사용하여 원격 시스템에 연결하고 파일을 전송하는 작은 코드를 실행 중입니다. env.password에 서버의 비밀번호를 할당했습니다.코드에서 암호가 지정되어 있어도 패브릭이 암호를 묻는 중임

그러나 코드를 실행하면 암호를 묻는 메시지가 나타납니다. 암호를 입력하면 파일이 전송됩니다. 그러나 나는 메시지를 받고 싶지 않습니다. 어쩌면 내가 env.password가 무엇인지 오해

from fabric import environment 
from fabric.contrib.project import rsync_project 
env.hosts = ['172.16.154.134'] 
env.password = '[email protected]' 
def sync(remote_dir, local_dir): 
    rsync_project(remote_dir, local_dir) 

:

여기 내 코드입니다. 그렇다면 암호를 묻는 프롬프트를 제거하는 다른 방법을 알려주십시오.

감사합니다.

+0

관련 GitHub의 문제가 : https://github.com/fabric/fabric/issues/817 – Sinkingpoint

+0

@Sinkingpoint 링크 그것은 작동하지 (404)를 던졌습니다 . –

+0

이 질문에 대해 살펴 보겠습니다. http://stackoverflow.com/q/3737003/5476782 – Kruser

답변

1

이것은 일반적인 오해입니다. 코드에서 env를 설정하면 execute이라는 함수를 호출해야합니다.

from fabric.state import env 
from fabric.decorators import task 
from fabric.api import execute 
from fabric.contrib.project import rsync_project 

env.hosts = ['172.16.154.134'] 
env.password = '[email protected]' 

def internal_sync(remote_dir, local_dir): 
    rsync_project(remote_dir, local_dir) 

# use task to define the external endpoint for the fab command line 
@task 
def sync(remote_dir, local_dir): 
    """Does an rsync from remote_dir => local_dir""" 
    # above docstring for `fab --list` 
    # call `internal_sync` using the env 
    # parameters we set in code 
    execute(internal_sync, remote_dir, local_dir) 

그리고 명령 줄에서

:

fab sync:/path/to/remote,/path/to/local