def upgrade_tyr_packages(): packages = [ 'sudo', 'apache2', 'libapache2-mod-wsgi', 'logrotate', 'python2.7', 'git', 'postgresql-server-dev-all' ] if env.distrib == 'ubuntu14.04': packages += ['libpython2.7-dev', 'postgresql-9.3-postgis-2.1'] elif env.distrib == 'debian7': packages += ['python2.7-dev', 'postgresql-9.1-postgis'] elif env.distrib == 'debian8': packages += ['python2.7-dev', 'g++', 'postgresql-9.4-postgis-2.1'] require.deb.packages(packages, update=True) package_filter_list = ['navitia-tyr*deb', 'navitia-common*deb'] _install_packages(package_filter_list) if not python.is_pip_installed(): python.install_pip() require.python.install_requirements('/usr/share/tyr/requirements.txt', use_sudo=True, exists_action='w') _upload_template('tyr/tyr_beat.jinja', env.tyr_beat_service_file, context={'env': env}, mode='755') _upload_template('tyr/tyr_worker.jinja', env.tyr_worker_service_file, context={'env': env}, mode='755')
def pip(version=None): """ Require `pip`_ to be installed. """ distribute() if not is_pip_installed(version): install_pip()
def upgrade_tyr_packages(): packages = [ 'logrotate', 'git', ] if env.distrib == 'ubuntu14.04': packages += ['libpython2.7-dev'] elif env.distrib == 'debian7': packages += ['python2.7-dev'] elif env.distrib == 'debian8': packages += ['python2.7-dev', 'g++'] require.deb.packages(packages, update=True) package_filter_list = ['navitia-tyr*deb', 'navitia-common*deb'] _install_packages(package_filter_list) if not python.is_pip_installed(): python.install_pip() #we want the version of the system for these packages run('''sed -e "/protobuf/d" -e "/psycopg2/d" /usr/share/tyr/requirements.txt > /tmp/tyr_requirements.txt''') run('git config --global url."https://".insteadOf git://') require.python.install_requirements('/tmp/tyr_requirements.txt', use_sudo=True, exists_action='w') if env.use_systemd: _upload_template('tyr/systemd_tyr_worker.jinja', env.service_name('tyr_worker'), user='******', mode='644', context={'env': env}) else: _upload_template('tyr/tyr_worker.jinja', env.service_name('tyr_worker'), user='******', mode='755', context={'env': env}) restart_tyr_worker() update_init(host='tyr')
def upgrade_ws_packages(): packages = [ 'apache2', 'libapache2-mod-wsgi', 'logrotate', 'redis-server', 'python2.7', 'git', 'gcc', 'python-dev', 'protobuf-compiler' ] if env.distrib in ('ubuntu14.04', 'debian8'): packages.append('libzmq3-dev') elif env.distrib == 'debian7': packages.append('libzmq-dev') require.deb.packages(packages) package_filter_list = ['navitia-jormungandr*deb', 'navitia-common*deb'] _install_packages(package_filter_list) if not python.is_pip_installed(): python.install_pip() #we want the version of the system for these packages run('''sed -e "/protobuf/d" -e "/psycopg2/d" /usr/share/jormungandr/requirements.txt > /tmp/jormungandr_requirements.txt''') run('git config --global url."https://".insteadOf git://') require.python.install_requirements('/tmp/jormungandr_requirements.txt', use_sudo=True, exists_action='w', upgrade=True)
def upgrade_ws_packages(): packages = [ 'apache2', 'libapache2-mod-wsgi', 'logrotate', 'redis-server', 'python2.7', 'git', 'gcc', 'python-dev', 'protobuf-compiler' ] if env.distrib in ('ubuntu14.04', 'debian8'): packages.append('libzmq3-dev') elif env.distrib == 'debian7': packages.append('libzmq-dev') require.deb.packages(packages) package_filter_list = ['navitia-jormungandr*deb', 'navitia-common*deb'] _install_packages(package_filter_list) if not python.is_pip_installed(): python.install_pip() require.python.install_requirements('/usr/share/jormungandr/requirements.txt', use_sudo=True, exists_action='w')
def pip(version=None, use_python='python'): """ Require `pip`_ to be installed. """ distribute(use_python=use_python) if not is_pip_installed(version, use_python=use_python): install_pip(use_python=use_python)
def upgrade_ws_packages(): packages = [ "apache2", "libapache2-mod-wsgi", "logrotate", "redis-server", "python2.7", "git", "gcc", "python-dev", "protobuf-compiler", ] if env.distrib in ("ubuntu14.04", "debian8"): packages.append("libzmq3-dev") packages.append("libgeos-3.4.2") elif env.distrib == "debian7": packages.append("libzmq-dev") require.deb.packages(packages) package_filter_list = ["navitia-jormungandr*deb", "navitia-common*deb"] _install_packages(package_filter_list) if not python.is_pip_installed(): python.install_pip() # we want the version of the system for these packages run( """sed -e "/protobuf/d" -e "/psycopg2/d" /usr/share/jormungandr/requirements.txt > /tmp/jormungandr_requirements.txt""" ) run('git config --global url."https://".insteadOf git://') require.python.install_requirements("/tmp/jormungandr_requirements.txt", use_sudo=True, exists_action="w")
def upgrade_ws_packages(): packages = [ 'apache2', 'libapache2-mod-wsgi', 'logrotate', 'redis-server', 'python2.7', 'git', 'gcc', 'python-dev', 'protobuf-compiler' ] if env.distrib in ('ubuntu14.04', 'debian8'): packages.append('libzmq3-dev') packages.append('libgeos-3.4.2') elif env.distrib == 'debian7': packages.append('libzmq-dev') require.deb.packages(packages) package_filter_list = ['navitia-jormungandr*deb', 'navitia-common*deb'] _install_packages(package_filter_list) if not python.is_pip_installed(): python.install_pip() # We want the version of the system for these packages run('''sed -e "/protobuf/d" -e "/psycopg2/d" /usr/share/jormungandr/requirements.txt > /tmp/jormungandr_requirements.txt''' ) #add newrelic as a dependency run('''echo 'newrelic==2.70.0.51' >> /tmp/jormungandr_requirements.txt''') run('git config --global url."https://".insteadOf git://') require.python.install_requirements('/tmp/jormungandr_requirements.txt', use_sudo=True, exists_action='w')
def upgrade_monitor_kraken_packages(): package_filter_list = ['navitia-monitor-kraken*deb'] _install_packages(package_filter_list) if not python.is_pip_installed(): python.install_pip() require.python.install_requirements('/usr/share/monitor_kraken/requirements.txt', use_sudo=True, exists_action='w')
def pip(version=MIN_PIP_VERSION, pip_cmd='pip', python_cmd='python'): """ Require `pip`_ to be installed. If pip is not installed, or if a version older than *version* is installed, the latest version will be installed. .. _pip: http://www.pip-installer.org/ """ setuptools(python_cmd=python_cmd) if not is_pip_installed(version, pip_cmd=pip_cmd): install_pip(python_cmd=python_cmd)
def test_is_pip_installed_pythonbrew(self, mock_run): from fabric.operations import _AttributeString from fabtools.python import is_pip_installed fake_result = _AttributeString( '\x1b[32mSwitched to Python-2.7.5' '\x1b[0mpip 1.4.1 from /home/vagrant/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg (python 2.7)' ) fake_result.failed = False fake_result.succeeded = True mock_run.return_value = fake_result res = is_pip_installed(version='1.3.1') self.assertTrue(res)
def deploy(): require("install_location") sudo("mkdir -p %(install_location)s" % env) if not is_pip_installed(): install_pip() install("virtualenv", use_sudo=True) put(join_local("pip-requirements.txt"), "/tmp/pip-requirements.txt") with _virtualenv(): install_requirements("/tmp/pip-requirements.txt", use_sudo=True) sudo("pip install -e git+https://github.com/oliverdrake/rpitempcontroller.git#egg=tempcontrol") put("tempcontroller-config.default", env.config_file, use_sudo=True, mirror_local_mode=True) with settings(python_bin_dir=os.path.join(_virtualenv_location(), "bin")): upload_template("init-script.in", env.init_script, mode=0754, use_jinja=True, context=env, use_sudo=True, backup=False) sudo("chown root:root %(init_script)s" % env)
def install(): """ Installs and configures vim """ # update apt index update_index(quiet=False) # install vim utils._deb.install('vim') # backup vim configuration folder if exists('.vim'): print(green('Backing up your vim configuration folder to .vim-bkp')) cmd = 'mv .vim .vim-bkp' run(cmd) # backup vim configuration file if exists('.vimrc'): print(green('Backing up your vim configuration file to .vimrc-bkp')) cmd = 'mv .vimrc .vimrc-bkp' run(cmd) # clone vim_config repository print(green('Cloning Vim_config repository.')) # install git if is not available git_install() git_clone('git://github.com/magnet-cl/Vim_config.git', '.vim') # install required packages by plugins print(green('Installing plugins dependencies.')) # ctags, better grep, python flake, latex, C/C++ omnicompletion plugins = ['exuberant-ctags', 'ack-grep', 'pyflakes', 'lacheck', 'clang', 'rhino'] for plugin in plugins: utils._deb.install(plugin) # install pip if is not available if not is_pip_installed(): install_pip() if not py_is_installed('flake8'): py_install('flake8', use_sudo=True) # python flake+pep8 # installation script print(green('Installing Vim_config.')) cmd = 'source .vim/install.sh' run(cmd)
def install_requirements(): """Installs all the requirements on the requirements file""" # TODO: sudo should not be required. we need to configure this to use a new user for each app. if not is_pip_installed(): install_pip() # use_sudo defaults to True # inside here we check if the virtualenv exists, no need for double check. create_virtualenv() create_application_folder() if env.clone: clone_repository() with virtualenv(env.virtualenv_path): with cd(env.app_root): fab_install_requirements("requirements.txt", use_sudo=True)
def upgrade_tyr_packages(): packages = [ 'logrotate', 'git', ] if env.distrib == 'ubuntu14.04': packages += ['libpython2.7-dev'] elif env.distrib == 'debian7': packages += ['python2.7-dev'] elif env.distrib == 'debian8': packages += ['python2.7-dev', 'g++'] require.deb.packages(packages, update=True) package_filter_list = ['navitia-tyr*deb', 'navitia-common*deb'] _install_packages(package_filter_list) if not python.is_pip_installed(): python.install_pip() require.python.install_requirements('/usr/share/tyr/requirements.txt', use_sudo=True, exists_action='w') _upload_template('tyr/tyr_worker.jinja', env.tyr_worker_service_file, user='******', mode='755', context={'env': env})