コード例 #1
0
ファイル: main.py プロジェクト: pombredanne/depot-pm
def install(package_file=None, verbose=False, dry_run=False):
    version(warning_only=True)

    try:
        configuration = Configuration.auto_discover(package_file)
    except yaml.YAMLError as e:
        if verbose:
            console.error('Cannot parse package file: {}'.format(e))
        task.exit(2)
        return  # suppress pycharm warning

    if configuration:
        if verbose:
            console.info('resolved package file: {}'.format(configuration.config_file_path))
    else:
        if verbose:
            console.error('Cannot find package file.')
        task.exit(1)
        return  # suppress pycharm warning

    # Go
    if dry_run and verbose:
        console.info('dry run: depot-pm won\'t perfom following commands.')

    for command in configuration.commands:
        if verbose:
            console.info('Execute command: {}'.format(command))
        if not dry_run:
            run(command, should_raise_when_fail=True)
        else:
            console.show(command)

    if verbose:
        console.success('done')
コード例 #2
0
ファイル: main.py プロジェクト: pombredanne/depot-pm
def setup(verbose=False, dry_run=False):
    version(warning_only=True)

    if os_info.is_osx:
        # Check for `brew`
        if not has_command('brew'):
            if verbose:
                console.info('Install homebrew as package manager')
            command = 'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"'
            if dry_run or verbose:
                console.show(command)
            if not dry_run:
                os.system(command)
        # Check the source of python and ruby
        python_version, _ = run('brew ls --versions python', capture_output=True)
        if not python_version:
            console.warn('You should use brew-installed python. (brew install python)')
        ruby_version, _ = run('brew ls --versions ruby', capture_output=True)
        if not ruby_version:
            console.warn('You should use brew-installed ruby. (brew install ruby)')

    elif os_info.is_linux:
        # TODO: Add yum/apt-get check
        pass