Exemple #1
0
def chkcom(command):
    if command == "haproxy":
        if not sh.brew("list", command):
            if sh.which('brew'):
                output = sh.brew("install", command)
                return (output.exit_code)
            else:
                return (
                    "# ERROR: cannot find command %s and brew isn't installed, aborting"
                )
    elif command == "ghost":
        if not sh.which('ghost'):
            output = sh.sudo("gem", "install", command)
            return (output.exit_code)
    def execute(self):
        try:
            sh.brew("cask", "list", self.package)
        except sh.ErrorReturnCode_1:
            try:
                sh.brew("cask", "install", self.package)
            except sh.ErrorReturnCode as err:
                err_message = "\n\t" + err.stderr.replace("\n", "\n\t")
                logging.error(
                    "Error with `brew cask install %s`: %s",
                    self.package,
                    err_message
                )
                return False

        return True
Exemple #3
0
    def execute(self):
        try:
            sh.brew("cask", "list", self.package)
        except sh.ErrorReturnCode_1:
            try:
                sh.brew("cask", "install", self.package)
            except sh.ErrorReturnCode as err:
                err_message = "\n\t" + err.stderr.replace("\n", "\n\t")
                logging.error(
                    "Error with `brew cask install %s`: %s",
                    self.package,
                    err_message
                )
                return False

        return True
Exemple #4
0
def install_homebrew():
    """ Installs or upgrades homebrew on mac.

    If homebrew is not installed, this command will install it, otherwise
    it will update homebrew to the latest version. Additionally, it will
    offer to upgrade all homebrew packages. Upgrading all packages can take
    a long time, so the user is given the choice to skip the upgrade.
    """
    print("Checking homebrew install")
    if sh.which("brew"):
        spinner = Halo(
            text="Updating homebrew", spinner="dots", placement="right"
        )
        spinner.start()
        sh.brew("update")
        spinner.succeed()
        print(
            "Before using homebrew to install packages, we can upgrade "
            "any outdated packages."
        )
        response = user_input("Run brew upgrade? [y|N] ")
        if response[0].lower() == "y":
            spinner = Halo(
                text="Upgrade brew packages", spinner="dots", placement="right"
            )
            spinner.start()
            sh.brew("upgrade")
            spinner.succeed()
        else:
            print("Skipped brew package upgrades")
    else:
        # TODO (phillip): Currently, this homebrew installation does not work on a fresh
        # computer. It works from the command line, but not when run from the script. I
        # need to figure out what is going on. It could be because user input is needed.
        spinner = Halo(
            text="Installing homebrew", spinner="dots", placement="right"
        )
        spinner.start()
        try:
            script = sh.curl("-fsSL", BREW_GITHUB).stdout
            sh.ruby("-e", script)
            spinner.succeed()
        except sh.ErrorReturnCode:
            logging.error("Unable to install homebrew. Aborting...")
            spinner.fail()
            exit(1)
Exemple #5
0
def install_homebrew():
    """ Installs or upgrades homebrew on mac.

    If homebrew is not installed, this command will install it, otherwise
    it will update homebrew to the latest version. Additionally, it will
    offer to upgrade all homebrew packages. Upgrading all packages can take
    a long time, so the user is given the choice to skip the upgrade.
    """
    print("Checking homebrew install")
    if sh.which("brew"):
        spinner = Halo(text="Updating homebrew",
                       spinner="dots",
                       placement="right")
        spinner.start()
        sh.brew("update")
        spinner.succeed()
        print("Before using homebrew to install packages, we can upgrade "
              "any outdated packages.")
        response = user_input("Run brew upgrade? [y|N] ")
        if response[0].lower() == "y":
            spinner = Halo(text="Upgrade brew packages",
                           spinner="dots",
                           placement="right")
            spinner.start()
            sh.brew("upgrade")
            spinner.succeed()
        else:
            print("Skipped brew package upgrades")
    else:
        # TODO (phillip): Currently, this homebrew installation does not work on a fresh
        # computer. It works from the command line, but not when run from the script. I
        # need to figure out what is going on. It could be because user input is needed.
        spinner = Halo(text="Installing homebrew",
                       spinner="dots",
                       placement="right")
        spinner.start()
        try:
            script = sh.curl("-fsSL", BREW_GITHUB).stdout
            sh.ruby("-e", script)
            spinner.succeed()
        except sh.ErrorReturnCode:
            logging.error("Unable to install homebrew. Aborting...")
            spinner.fail()
            exit(1)
Exemple #6
0
#!/usr/bin/env python
from __future__ import print_function

import os

try:
    import sh
except ImportError:
    os.system("pip install sh")

from sh import which
if not which("npm"):
    from sh import brew
    brew("install", "npm")

#
from sh import npm, apm

class InstallationError(Exception):
    pass


COMPATIBILITY_MODE = os.environ.get("APM:INSTALL:COMPAT", False)
DEV_MODE = os.environ.get("APM:INSTALL:DEV_MODE", True)

def install_atom_pkgs(*pkgs):
    for pkg in pkgs:
        try:
            print(apm("install", pkg,compatible=COMPATIBILITY_MODE, production=DEV_MODE))
            print("Installed {}".format(pkg))
        except Exception as e:
Exemple #7
0
def package_install(package_name):

    if _platform == "linux" or _platform == "linux2":
        return sh.yum("install", "-y", package_name)
    elif _platform == "darwin":
        return sh.brew("install", package_name)