Exemplo n.º 1
0
    def test_venv_home(self):
        """test venv home function"""
        home1 = virtualenv_home()
        self.assertEqual(home1, 'TESTVALUE')
        del os.environ['VIRTUALENV_HOME']

        home2 = virtualenv_home()
        self.assertEqual(home2, 'TESTVALUE/venv')
Exemplo n.º 2
0
    def test_venv_home(self):
        """test venv home function"""
        home1 = virtualenv_home()
        self.assertEqual(home1, 'TESTVALUE')
        del os.environ['VIRTUALENV_HOME']

        home2 = virtualenv_home()
        self.assertEqual(home2, 'TESTVALUE/venv')
Exemplo n.º 3
0
def pip_install(version, update_setuptools=False):
    """pip install the version of cirrus requested"""
    pip_req = 'cirrus-cli=={0}'.format(version)
    venv_path = virtualenv_home()
    venv_name = os.path.basename(venv_path)
    LOGGER.info("running pip upgrade...")

    if is_anaconda():
        if update_setuptools:
            local(
                'source {0}/bin/activate {1} && pip install --upgrade setuptools'.format(
                    venv_path, venv_path
                )
            )
        local(
            'source {0}/bin/activate {1} && pip install --upgrade {2}'.format(
                venv_path, venv_path, pip_req
            )
        )
    else:
        if update_setuptools:
            local(
                ' . ./{0}/bin/activate && pip install --upgrade setuptools'.format(
                    venv_name
                )
            )

        local(
            ' . ./{0}/bin/activate && pip install --upgrade {1}'.format(
                venv_name, pip_req
            )
        )
Exemplo n.º 4
0
def main():
    hello_msg = (
        "\nHello from cirrus: {0}\n".format(__version__),
        "CIRRUS_HOME is {0}\n".format(env.cirrus_home()),
        "VIRTUALENV_HOME is {0}\n".format(env.virtualenv_home()),
        "Cirrus Python is {0}\n".format(sys.executable),
    )
    print(hello_msg)
Exemplo n.º 5
0
def main():
    hello_msg = (
        "\nHello from cirrus: {0}\n".format(__version__),
        "CIRRUS_HOME is {0}\n".format(env.cirrus_home()),
        "VIRTUALENV_HOME is {0}\n".format(env.virtualenv_home()),
        "Cirrus Python is {0}\n".format(sys.executable),
    )
    print(hello_msg)
Exemplo n.º 6
0
def main():
    """
    _main_

    response to the cirrus <verb> command
    Extracts the available verbs that are installed as
    entry points by setup.py as cirrus_commands

    """
    home = env.virtualenv_home()
    commands = []
    for script in pkg_resources.iter_entry_points(group="cirrus_commands"):
        comm = str(script).split(" = ", 1)[0]
        commands.append(comm)
    commands.sort()

    # switch to the current GIT_PREFIX working dir
    old_dir = os.getcwd()
    os.chdir(os.path.abspath(os.environ.get('GIT_PREFIX', '.')))

    try:
        args = sys.argv[1:]
        if len(args) == 0 or args[0] == '-h':
            # missing command or help
            print(format_help(commands))
            exit_code = 0
        else:
            command_path = "{0}/bin/{1}".format(home, args[0])
            if not os.path.exists(command_path):
                msg = "Unknown command: {}".format(args[0])
                print(msg)
                print(format_help(commands))
                exit_code = 127
            else:
                exit_code = run_command([
                    command_path,
                ] + args[1:])
    except Exception as ex:
        msg = "Exception Details:\n{}".format(ex)
        print(msg)
        raise
    finally:
        # always return to previous dir
        os.chdir(old_dir)
    return exit_code
Exemplo n.º 7
0
def main():
    """
    _main_

    response to the cirrus <verb> command
    Extracts the available verbs that are installed as
    entry points by setup.py as cirrus_commands

    """
    home = env.virtualenv_home()
    commands = []
    for script in pkg_resources.iter_entry_points(group="cirrus_commands"):
        comm = str(script).split(" = ", 1)[0]
        commands.append(comm)
    commands.sort()

    # switch to the current GIT_PREFIX working dir
    old_dir = os.getcwd()
    os.chdir(os.path.abspath(os.environ.get('GIT_PREFIX', '.')))

    try:
        args = sys.argv[1:]
        if len(args) == 0 or args[0] == '-h':
            # missing command or help
            print(format_help(commands))
            exit_code = 0
        else:
            command_path = "{0}/bin/{1}".format(home, args[0])
            if not os.path.exists(command_path):
                msg = "Unknown command: {}".format(args[0])
                print(msg)
                print(format_help(commands))
                exit_code = 127
            else:
                exit_code = run_command([command_path, ] + args[1:])
    except Exception as ex:
        msg = "Exception Details:\n{}".format(ex)
        print(msg)
        raise
    finally:
        # always return to previous dir
        os.chdir(old_dir)
    return exit_code
Exemplo n.º 8
0
def pip_install(version, update_setuptools=False):
    """pip install the version of cirrus requested"""
    pip_req = 'cirrus-cli=={0}'.format(version)
    venv_path = virtualenv_home()
    venv_name = os.path.basename(venv_path)
    LOGGER.info("running pip upgrade...")

    if is_anaconda():
        if update_setuptools:
            local(
                'source {0}/bin/activate {1} && pip install --upgrade setuptools'
                .format(venv_path, venv_path))
        local(
            'source {0}/bin/activate {1} && pip install --upgrade {2}'.format(
                venv_path, venv_path, pip_req))
    else:
        if update_setuptools:
            local(' . ./{0}/bin/activate && pip install --upgrade setuptools'.
                  format(venv_name))

        local(' . ./{0}/bin/activate && pip install --upgrade {1}'.format(
            venv_name, pip_req))