python类host()的实例源码

__init__.py 文件源码 项目:fabsetup 作者: theno 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def pyenv():
    '''Install or update the pyenv python environment.

    Checkout or update the pyenv repo at ~/.pyenv and enable the pyenv.
    Pyenv wird also als Github-Repo "installiert" unter ~/.pyenv

    More info:
     * https://github.com/yyuu/pyenv
     * https://github.com/yyuu/pyenv/wiki/Common-build-problems#requirements
    Tutorial:
     * http://amaral-lab.org/resources/guides/pyenv-tutorial
    '''
    install_packages([
        'make',
        'build-essential',
        'libssl-dev',
        'zlib1g-dev',
        'libbz2-dev',
        'libreadline-dev',
        'libsqlite3-dev',
        'wget',
        'curl',
        'llvm',
        'libncurses5-dev',
        'libncursesw5-dev',
    ])
    if exists('~/.pyenv'):
        run('cd ~/.pyenv  &&  git pull')
        run('~/.pyenv/bin/pyenv update')
    else:
        run('curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/'
            'master/bin/pyenv-installer | bash')

    # add pyenv to $PATH and set up pyenv init
    bash_snippet = '~/.bashrc_pyenv'
    install_file(path=bash_snippet)
    prefix = flo('if [ -f {bash_snippet} ]; ')
    enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi')
    if env.host == 'localhost':
        # FIXME: next function currently only works for localhost
        uncomment_or_update_or_append_line(filename='~/.bashrc', prefix=prefix,
                                           new_line=enabler)
    else:
        print(cyan('\nappend to ~/.bashrc:\n\n    ') + enabler)
__init__.py 文件源码 项目:fabsetup 作者: theno 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def powerline_shell():
    '''Install and set up powerline-shell prompt.

    More infos:
     * https://github.com/banga/powerline-shell
     * https://github.com/ohnonot/powerline-shell
     * https://askubuntu.com/questions/283908/how-can-i-install-and-use-powerline-plugin
    '''
    assert env.host == 'localhost', 'This task cannot run on a remote host'

    # set up fonts for powerline

    checkup_git_repo('https://github.com/powerline/fonts.git',
            name='powerline-fonts')
    run('cd ~/repos/powerline-fonts && ./install.sh')
#    run('fc-cache -vf ~/.local/share/fonts')
    prefix = 'URxvt*font: '
    from config import fontlist
    line = prefix + fontlist
    update_or_append_line(filename='~/.Xresources', prefix=prefix,
            new_line=line)
    if env.host_string == 'localhost':
        run('xrdb  ~/.Xresources')

    # set up powerline-shell

    checkup_git_repo('https://github.com/banga/powerline-shell.git')
#    checkup_git_repo('https://github.com/ohnonot/powerline-shell.git')
    install_file(path='~/repos/powerline-shell/config.py')
    run('cd ~/repos/powerline-shell && ./install.py')

    question = 'Use normal question mark (u003F) for untracked files instead '\
        'of fancy "black question mark ornament" (u2753, which may not work)?'
    if query_yes_no(question, default='yes'):
        filename = '~/repos/powerline-shell/powerline-shell.py'
        update_or_append_line(filename, keep_backup=False,
                              prefix="        'untracked': u'\u2753',",
                              new_line="        'untracked': u'\u003F',")
        run(flo('chmod u+x  {filename}'))

    bash_snippet = '~/.bashrc_powerline_shell'
    install_file(path=bash_snippet)
    prefix = flo('if [ -f {bash_snippet} ]; ')
    enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi')
    uncomment_or_update_or_append_line(filename='~/.bashrc', prefix=prefix,
                                       new_line=enabler)


问题


面经


文章

微信
公众号

扫码关注公众号