2017-05-04 1 views
0

python qt 응용 프로그램에 실행기 스크립트를 작성하고 싶습니다. 아이디어는 git pull, pip install -r 요구 사항을 실행하고 실제 응용 프로그램을 시작한 다음 종료하는 것입니다.git pull을 실행 한 다음 실제 응용 프로그램을 실행하는 Python launcher

나는 git/pip 구성 요소를 모두 수행하는 방법을 알고 있으며 응용 프로그램을 실행하는 몇 가지 방법을 알고 있지만 여기서는 응용 프로그램을 업데이트하고 사용자가 아무것도하지 않고 실행하는 최상의 방법을 알고 있습니다. .

응용 프로그램이 우리 사무실의 워크 스테이션에 설치되면, 모든 워크 스테이션은 파이썬이 설치된 윈도우를 실행합니다. 그들이 사용하는 응용 프로그램은 virtualenv에서 실행중인 자식과 함께 설치됩니다.

이전에 내가 한 것은 DB에서 체크 버전이었습니다. 버전이 올바르지 않으면 git/pip 프로세스를 실행 한 다음 사용자에게 메시지를 표시하고 응용 프로그램을 다시 시작하십시오. 차라리 응용 프로그램을 다시 시작하겠습니다.

TIA

답변

1

내가 (fabric/fabtools)와 같은 프로젝트 자동화 설정 도구를 사용하는 것이 좋습니다 : 당신은 당신이 로컬 또는에서 이러한 거즈를 실행할지 여부를 지정하지 않은, 귀하의 질문에 그들에게 pip install fabric fabtools

설치 원격 서버, 어떤 방법, 두 경우 모두 노호 찾을 :이 스크립트를 caontaining 디렉토리로 이동 터미널에서 "fabfile.py"에이 스크립트를 작성 후

from fabric.api import local, cd, run, env, roles 
from fabric.context_managers import prefix 


env.project_name = "project name" 
env.repo = "your_repo.git" 

REMOTEHOST = "Ip or domaine" 

REMOTEUSER = "user" 
REMOTEPASSWORD = "password" 

env.roledefs.update({ 
    "remote": [REMOTEHOST] 
}) 

def remote(): 
    """Defines the Development Role 
    """ 
    env.user = REMOTEUSER 
    env.password = REMOTEPASSWORD 
    env.forward_agent = True # Your local machine has access, and the remote not, so you forward you identity to the 
           # remote, and then the remote gets access 

def install_requirements(environment="local"): 
    """Install the packages required by our each environment 
    """ 
    if environment == "local": 
     with cd("/your project/"): 
      with prefix("source activate {0}".format("YOUR VIRTUALENV NAME")): 
       run("pip install -r requirements/local.txt") 
    elif environment == "remote": 
     with cd("your project"): 
      with prefix("source activate {0}".format("YOUR VIRTUALENV NAME")): 
       run("pip install -r requirements/remote.txt") 

def bootstrap_local(): 
    """Do your job locally 
    """ 
    env.warn_only = True 
    with cd("your directory"): 
     with prefix("source activate {0}".format("YOUR VIRTUALENV NAME")): 
      local("git checkout {0}".format("YOUR BRANCH")) 
      local("git pull origin {0}".format("YOUR BRANCH")) 
    install_requirements(environment="local") 
    local("the command line of the Application you wanna launch") 

@roles('remote') 
def bootstrap_remote(): 
    """do your job in the Remote server 
    """ 
    env.warn_only = True 
    remote() 
    with cd("your directory"): 
     with prefix("source activate {0}".format("YOUR VIRTUALENV NAME")): 
      run("git checkout {0}".format("YOUR BRANCH")) 
      run("git pull origin {0}".format("YOUR BRANCH")) 
    install_requirements(environment="remote") 
    run("the command line of the Application you wanna launch") 

및 :

  • 실행 fab bootstrap_local이 작업 로컬
  • 을 실행하거나 작업에게 내가이 존재 몰랐다 원격
+1

덕분에 남자를 실행 fab bootstrap_remote를 실행합니다. – Ominus

+1

여기 아주 간단한 예를 들었습니다. 아주 간단하고 매우 효율적으로 fabtools로 만들 수있는 아주 멋진 것들이 많이 있습니다! 예를 들면 : 관리자 설치, 구성, postgrest, git 작업 ... 모두 사용할 준비가되었습니다 ;-) –

관련 문제