def command(): """ Require the curl command-line tool. Example:: from fabric.api import run from burlap import require require.curl.command() run('curl --help') """ from burlap.require.deb import package as require_deb_package from burlap.require.rpm import package as require_rpm_package family = distrib_family() if family == 'debian': require_deb_package('curl') elif family == 'redhat': require_rpm_package('curl') else: raise UnsupportedFamily(supported=['debian', 'redhat'])
def command(): """ Require the git command-line tool. Example:: from fabric.api import run from burlap import require require.git.command() run('git --help') """ from burlap.require.deb import package as require_deb_package from burlap.require.pkg import package as require_pkg_package from burlap.require.rpm import package as require_rpm_package from burlap.require.portage import package as require_portage_package res = run('git --version', quiet=True) if res.failed: family = distrib_family() if family == 'debian': require_deb_package('git-core') elif family == 'redhat': require_rpm_package('git') elif family == 'sun': require_pkg_package('scmgit-base') elif family == 'gentoo': require_portage_package('dev-vcs/git') else: raise UnsupportedFamily(supported=['debian', 'redhat', 'sun', 'gentoo'])
def setuptools(version=MIN_SETUPTOOLS_VERSION, python_cmd='python'): """ Require `setuptools`_ to be installed. If setuptools is not installed, or if a version older than *version* is installed, the latest version will be installed. .. _setuptools: http://pythonhosted.org/setuptools/ """ from burlap.require.deb import package as require_deb_package from burlap.require.rpm import package as require_rpm_package if not is_setuptools_installed(python_cmd=python_cmd): family = distrib_family() if family == 'debian': require_deb_package('python-dev') elif family == 'redhat': require_rpm_package('python-devel') elif family == 'arch': pass # ArchLinux installs header with base package else: raise UnsupportedFamily(supported=['debian', 'redhat', 'arch']) install_setuptools(python_cmd=python_cmd)
def command(): """ Require the ``hg`` command-line tool. Example:: from fabric.api import run from burlap import require require.mercurial.command() run('hg --help') """ from burlap.require.deb import package as require_deb_package from burlap.require.rpm import package as require_rpm_package from burlap.require.portage import package as require_portage_package res = run('hg --version', quiet=True) if res.failed: family = distrib_family() if family == 'debian': require_deb_package('mercurial') elif family == 'gentoo': require_portage_package('mercurial') elif family == 'redhat': require_rpm_package('mercurial') else: raise UnsupportedFamily(supported=['debian', 'redhat', 'gentoo'])
def _server_redhat(version, password): from burlap.require.rpm import package as require_rpm_package require_rpm_package('mysql-server') run_as_root('chkconfig --levels 235 mysqld on') run_as_root('service mysqld start') _require_root_password(password)
def process(name, **kwargs): """ Require a supervisor process to be running. Keyword arguments will be used to build the program configuration file. Some useful arguments are: - ``command``: complete command including arguments (**required**) - ``directory``: absolute path to the working directory - ``user``: run the process as this user - ``stdout_logfile``: absolute path to the log file You should refer to the `supervisor documentation`_ for the complete list of allowed arguments. .. note:: the default values for the following arguments differs from the ``supervisor`` defaults: - ``autorestart``: defaults to ``true`` - ``redirect_stderr``: defaults to ``true`` Example:: from burlap import require require.supervisor.process('myapp', command='/path/to/venv/bin/myapp --config production.ini --someflag', directory='/path/to/working/dir', user='******', stdout_logfile='/path/to/logs/myapp.log', ) .. _supervisor documentation: http://supervisord.org/configuration.html#program-x-section-values """ from burlap.require import file as require_file from burlap.require.deb import package as require_deb_package from burlap.require.rpm import package as require_rpm_package from burlap.require.arch import package as require_arch_package from burlap.require.service import started as require_started family = distrib_family() if family == 'debian': require_deb_package('supervisor') require_started('supervisor') elif family == 'redhat': require_rpm_package('supervisord') require_started('supervisord') elif family == 'arch': require_arch_package('supervisor') require_started('supervisord') else: raise UnsupportedFamily(supported=['debian', 'redhat', 'arch']) # Set default parameters params = {} params.update(kwargs) params.setdefault('autorestart', 'true') params.setdefault('redirect_stderr', 'true') # Build config file from parameters lines = [] lines.append('[program:%(name)s]' % locals()) for key, value in sorted(params.items()): lines.append("%s=%s" % (key, value)) # Upload config file if family == 'debian': filename = '/etc/supervisor/conf.d/%(name)s.conf' % locals() elif family == 'redhat': filename = '/etc/supervisord.d/%(name)s.ini' % locals() elif family == 'arch': filename = '/etc/supervisor.d/%(name)s.ini' % locals() with watch(filename, callback=update_config, use_sudo=True): require_file(filename, contents='\n'.join(lines), use_sudo=True) # Start the process if needed if process_status(name) == 'STOPPED': start_process(name)