python类run()的实例源码

git.py 文件源码 项目:boss 作者: kabirbaidhya 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def pull(branch):
    ''' The git pull command. '''
    run('git pull origin %s' % branch)
    # TODO: Custom origin
git.py 文件源码 项目:boss 作者: kabirbaidhya 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def sync(branch):
    ''' Sync the current HEAD with the remote(origin)'s branch '''
    run('git reset --hard origin/%s' % branch)
    # TODO: Custom origin
git.py 文件源码 项目:boss 作者: kabirbaidhya 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def last_commit(remote=True, short=False):
    '''
    Get the last commit of the git repository.

    Note: This assumes the current working directory (on remote or local host)
    to be a git repository. So, make sure current directory is set before using this.
    '''

    cmd = 'git rev-parse{}HEAD'.format(' --short ' if short else ' ')

    with hide('everything'):
        result = run(cmd) if remote else local(cmd, capture=True)

        return result.strip()
git.py 文件源码 项目:boss 作者: kabirbaidhya 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def show_last_commit():
    ''' Display the last commit. '''
    run('git log -1')
runner.py 文件源码 项目:boss 作者: kabirbaidhya 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def run(command, remote=True):
    ''' Run a command using fabric. '''
    if remote:
        return _run(command)
    else:
        return _local(command)
fabfile.py 文件源码 项目:flask-vue-semantic-docker 作者: italomaia 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_fn():
    """
    Returns the correct function call for the environment.
    """
    return run if renv == 'prd' else local
fabfile.py 文件源码 项目:flask-vue-semantic-docker 作者: italomaia 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def on_service(name):
    """
    Define service where command should run
    """
    global service_name
    service_name = name
fabfile.py 文件源码 项目:mendelmd 作者: raonyguimaraes 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def make_doc():
    with lcd('../docs'):
        local('make html')
        local('cp -rf _build/html/* /var/www/mendelmd_static/docs/')

#def backup():
#    run(' mysqldump -u root -p mendelmd14 | gzip > db_backup/mendelmd151012.sql.gz ')
fabfile.py 文件源码 项目:mendelmd 作者: raonyguimaraes 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def create_sample_data():
    #backup all users
#    with cd('/projects/www/mendelmd14'):
#
#        run('mysqldump -u root -p mendelmd14 auth_user account_account profiles_profile | gzip > db_backup/users.sql.gz')
#        #get sample from individuals
#        run('mysqldump -u root -p --where="individual_id < 16" mendelmd14 individuals_variant | gzip > db_backup/individual_variants_sample.sql.gz')
#        run('mysqldump -u root -p --where="id < 16" mendelmd14 individuals_individual | gzip > db_backup/individuals_sample.sql.gz')


    get('/projects/www/mendelmd14/db_backup/users.sql.gz', '/home/raony/sites/mendelmd14/db_backup/')
    get('/projects/www/mendelmd14/db_backup/individual_variants_sample.sql.gz', '/home/raony/sites/mendelmd14/db_backup/')
    get('/projects/www/mendelmd14/db_backup/individuals_sample.sql.gz', '/home/raony/sites/mendelmd14/db_backup/')
fabfile.py 文件源码 项目:mendelmd 作者: raonyguimaraes 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def loaddata():
    #Load user and sample from individuals
    local('gunzip < db_backup/users.sql.gz | mysql -u root -p mendelmd')
    local('gunzip < db_backup/individual_variants_sample.sql.gz | mysql -u root -p mendelmd ')
    local('gunzip < db_backup/individuals_sample.sql.gz | mysql -u root -p mendelmd ')


#    run(' gunzip < db_backup/mendelmd151012.sql.gz | mysql -u root -p mendelmd14 ')
#    local("""python manage.py loaddata db_backup/all_without_individuals.json.gz""")
fabfile.py 文件源码 项目:mendelmd 作者: raonyguimaraes 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def deploy(message="changes (fabric)"):
    local('git add .; git commit -m "%s";git push' % (message))
    with cd('/projects/www/mendelmd'):
#        run('git reset --hard HEAD')
        run('git pull')
#        run('source virtualenvwrapper.sh && workon genome_research && python manage.py syncdb --noinput')

        run('sudo /etc/init.d/apache2 restart')
fabfile.py 文件源码 项目:dprr-django 作者: kingsdigitallab 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def unlock():
    """os x servers need to be unlocked"""
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)
    with cd(env.path):
        run('security unlock-keychain')
fabfile.py 文件源码 项目:dprr-django 作者: kingsdigitallab 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def create_virtualenv():
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)
    with quiet():
        env_vpath = os.path.join(env.envs_path, 'dprr-' + env.srvr)
        if run('ls {}'.format(env_vpath)).succeeded:
            print(
                green('virtual environment at [{}] exists'.format(env_vpath)))
            return

    print(yellow('setting up virtual environment in [{}]'.format(env_vpath)))
    run('virtualenv {}'.format(env_vpath))
fabfile.py 文件源码 项目:dprr-django 作者: kingsdigitallab 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def clone_repo():
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)
    with quiet():
        if run('ls {}'.format(os.path.join(env.path, '.git'))).succeeded:
            print(green(('repository at'
                         ' [{}] exists').format(env.path)))
            return

    print(yellow('cloning repository to [{}]'.format(env.path)))
    run('git clone --recursive {} {}'.format(REPOSITORY, env.path))
fabfile.py 文件源码 项目:dprr-django 作者: kingsdigitallab 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def makemigrations(app=None):
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    if env.srvr in ['dev', 'stg', 'liv']:
        print(yellow('Do not run makemigrations on the servers'))
        return

    with cd(env.path), prefix(env.within_virtualenv):
        run('./manage.py makemigrations {}'.format(app if app else ''))
fabfile.py 文件源码 项目:dprr-django 作者: kingsdigitallab 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def update_index():
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    with cd(env.path), prefix(env.within_virtualenv):
        run('./manage.py build_solr_schema > schema.xml')
        run('mv schema.xml ../../solr/collection1/conf/')
        sudo('service tomcat7-{} restart'.format(env.srvr))
        run('./manage.py update_index')
fabfile.py 文件源码 项目:dprr-django 作者: kingsdigitallab 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def clear_cache():
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    with cd(env.path), prefix(env.within_virtualenv):
        run('./manage.py clear_cache')
fabfile.py 文件源码 项目:dprr-django 作者: kingsdigitallab 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def collect_static(process=False):
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    if env.srvr in ['local', 'vagrant']:
        print(yellow('Do not run collect_static on local servers'))
        return

    with cd(env.path), prefix(env.within_virtualenv):
        run('./manage.py collectstatic {process} --noinput'.format(
            process=('--no-post-process' if not process else '')))
fabfile.py 文件源码 项目:dprr-django 作者: kingsdigitallab 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def install_requirements():
    require('srvr', 'path', 'within_virtualenv', provided_by=env.servers)

    reqs = 'requirements-{}.txt'.format(env.srvr)

    try:
        assert os.path.exists(reqs)
    except AssertionError:
        reqs = 'requirements.txt'

    with cd(env.path), prefix(env.within_virtualenv):
        run('pip install -U -r {}'.format(reqs))


问题


面经


文章

微信
公众号

扫码关注公众号