示例#1
0
def verify_git_dep():
    git_version_min = 'git version 1.8.5'
    obj = run_bash("git version", capture_stdout=True, check=False)
    git_version = obj.stdout.strip() if obj.stdout else None
    git_status = obj.returncode
    if git_status == 127:
        raise EnvironmentError(
            'The command git has not been found. Exiting...')

    if git_version < git_version_min:
        messenger.warn(
            f"Pearl might not work properly since git is too old: {git_version} < {git_version_min}"
        )
        return False

    return True
示例#2
0
def verify_bash_dep():
    bash_version_min = "4.1"
    obj = run_bash("echo $BASH_VERSION", capture_stdout=True, check=False)
    bash_version = obj.stdout.strip() if obj.stdout else None
    bash_status = obj.returncode
    if bash_status == 127:
        raise EnvironmentError(
            'The command bash has not been found. Exiting...')
    if bash_version is None:
        messenger.warn(
            "Warn: The BASH_VERSION environment variable is not defined")
        return False
    elif bash_version < bash_version_min:
        messenger.warn(
            f"Warn: Pearl might not work properly since bash is too old: {bash_version} < {bash_version_min}"
        )
        return False
    return True
示例#3
0
    def _get_config_filename(config_filename: Path = None,
                             env_initialized: bool = True) -> Path:
        if config_filename is None:
            xdg_config_home = os.environ.get('XDG_CONFIG_HOME',
                                             f"{os.environ['HOME']}/.config")
            config_home = Path(f'{xdg_config_home}/pearl')
            config_filename = config_home / 'pearl.conf'

        if env_initialized:
            if config_filename.exists() and not config_filename.is_file():
                msg = f'Error: The configuration in {config_filename} is not a file.'
                messenger.warn(msg)
                raise ValueError(msg)
            elif not config_filename.exists():
                msg = 'Pearl configuration file does not exist. Run "pearl init" first.'
                messenger.warn(msg)
                raise ValueError(msg)
        return config_filename
示例#4
0
    def _get_home(home: Path = None, env_initialized: bool = True) -> Path:
        if home is None:
            xdg_data_home = os.environ.get(
                'XDG_DATA_HOME', f"{os.environ['HOME']}/.local/share")
            default_home = f'{xdg_data_home}/pearl'
            home = Path(default_home)

        messenger.debug(f"Found Pearl home: {home}")

        if env_initialized:
            if home.exists() and not home.is_dir():
                msg = f'Error: The value in environment variable PEARL_HOME is not a directory: {home}.'
                messenger.warn(msg)
                raise ValueError(msg)
            elif not home.exists():
                msg = 'Pearl environment has not been initialized. Run "pearl init" first.'
                messenger.warn(msg)
                raise ValueError(msg)

        return home