Ejemplo n.º 1
0
def to_boolean(value):
    if not value:
        return False
    if isinstance(value, six.string_types):
        value = hooks.to_boolean(None, None, value)
    else:
        value = bool(value)
    return value
Ejemplo n.º 2
0
def to_boolean(value):
    if not value:
        return False
    if isinstance(value, six.string_types):
        value = hooks.to_boolean(None, None, value)
    else:
        value = bool(value)
    return value
Ejemplo n.º 3
0
def git_support(configurator):
    """ check if GIT support is disabled/enabled
    """
    git_support = True
    disabled = configurator.variables.get('package.git.disabled', u'False')
    if hooks.to_boolean(None, None, disabled):
        echo('GIT support disabled!')
        git_support = False
    return git_support
Ejemplo n.º 4
0
def post_preserved_as_paper(configurator, question, answer):
    if not answer:
        return ''

    answer = to_boolean(configurator, question, str(answer))
    if answer == PRESERVED_AS_PAPER_DEFAULT:
        return ''

    return answer
Ejemplo n.º 5
0
def post_preserved_as_paper(configurator, question, answer):
    if not answer:
        return ''

    answer = to_boolean(configurator, question, str(answer))
    if answer == PRESERVED_AS_PAPER_DEFAULT:
        return ''

    return answer
Ejemplo n.º 6
0
def git_support(configurator):
    """ check if GIT support is disabled/enabled
    """
    git_support = True
    disabled = configurator.variables.get('package.git.disabled', u'False')
    if hooks.to_boolean(None, None, disabled):
        echo('GIT support disabled!')
        git_support = False
    return git_support
Ejemplo n.º 7
0
def git_init(configurator):
    if not git_support(configurator):
        return
    git_init_flag = configurator.variables.get("package.git.init", u"False")
    if not hooks.to_boolean(None, None, str(git_init_flag)):
        echo("git init is disabled!")
        return
    params = ["git", "init"]
    echo(u"RUN: {0}".format(" ".join(params)), "info")
    try:
        result = subprocess.check_output(params, cwd=configurator.target_directory)
    except subprocess.CalledProcessError as e:
        echo(e.output, "warning")
    else:
        if result:
            echo(result, "info")
    return True
Ejemplo n.º 8
0
def git_commit(configurator, msg):
    if not git_support(configurator):
        return
    non_interactive = configurator.bobconfig.get("non_interactive")
    working_dir = (
        configurator.variables.get("package.root_folder")
        or configurator.target_directory
    )
    params1 = ["git", "add", "."]
    params2 = ["git", "commit", "-m", u'"{0}"'.format(msg)]
    git_autocommit = None
    run_git_commit = True
    autocommit_flag = configurator.variables.get("package.git.autocommit", u"False")
    if hooks.to_boolean(None, None, autocommit_flag):
        git_autocommit = True
    if not non_interactive and not git_autocommit:
        echo(
            u"Should we run?:\n{0}\n{1}\nin: {2}".format(
                " ".join(params1), " ".join(params2), working_dir
            ),
            "info",
        )
        run_git_commit = (input("[y]/n: ") or "y").lower() == "y"

    if not run_git_commit and not git_autocommit:
        echo("Skip git commit!", "warning")
        return

    echo(u"RUN: {0}".format(" ".join(params1)), "info")
    try:
        result1 = subprocess.check_output(params1, cwd=working_dir)
    except subprocess.CalledProcessError as e:
        echo(e.output, "warning")
    else:
        if result1:
            echo(result1, "info")

    echo(u"RUN: {0}".format(" ".join(params2)), "info")
    try:
        result2 = subprocess.check_output(params2, cwd=working_dir)
    except subprocess.CalledProcessError as e:
        echo(e.output, "warning")
    else:
        echo(result2, "info")
Ejemplo n.º 9
0
def git_init(configurator):
    if not git_support(configurator):
        return
    git_init_flag = configurator.variables.get('package.git.init', u'False')
    if not hooks.to_boolean(None, None, str(git_init_flag)):
        echo('git init is disabled!')
        return
    params = [
        'git',
        'init',
    ]
    echo(u'RUN: {0}'.format(' '.join(params)), 'info')
    try:
        result = subprocess.check_output(
            params,
            cwd=configurator.target_directory,
        )
    except subprocess.CalledProcessError as e:
        echo(e.output, 'warning')
    else:
        if result:
            echo(result, 'info')
Ejemplo n.º 10
0
def git_init(configurator):
    if not git_support(configurator):
        return
    git_init_flag = configurator.variables.get('package.git.init', u'False')
    if not hooks.to_boolean(None, None, str(git_init_flag)):
        echo('git init is disabled!')
        return
    params = [
        'git',
        'init',
    ]
    echo(u'RUN: {0}'.format(' '.join(params)), 'info')
    try:
        result = subprocess.check_output(
            params,
            cwd=configurator.target_directory,
        )
    except subprocess.CalledProcessError as e:
        echo(e.output, 'warning')
    else:
        if result:
            echo(result, 'info')
    return True
Ejemplo n.º 11
0
def git_support_enabled(configurator, question):
    disabled = configurator.variables.get('package.git.disabled', u'False')
    if hooks.to_boolean(None, None, disabled):
        echo(u'GIT support disabled!')
        raise SkipQuestion(u'GIT support is disabled, skip question!.')
Ejemplo n.º 12
0
def git_commit(configurator, msg):
    if not git_support(configurator):
        return
    non_interactive = configurator.bobconfig.get('non_interactive')
    working_dir = configurator.variables.get(
        'package.root_folder') or configurator.target_directory
    params1 = [
        'git',
        'add',
        '.',
    ]
    params2 = [
        'git',
        'commit',
        '-m',
        u'"{0}"'.format(msg),
    ]
    git_autocommit = None
    run_git_commit = True
    autocommit_flag = configurator.variables.get(
        'package.git.autocommit',
        u'False',
    )
    if hooks.to_boolean(None, None, autocommit_flag):
        git_autocommit = True
    if not non_interactive and not git_autocommit:
        echo(
            u'Should we run?:\n{0}\n{1}\nin: {2}'.format(
                ' '.join(params1),
                ' '.join(params2),
                working_dir,
            ),
            'info',
        )
        run_git_commit = (input('[y]/n: ') or 'y').lower() == 'y'

    if not run_git_commit and not git_autocommit:
        echo('Skip git commit!', 'warning')
        return

    echo(u'RUN: {0}'.format(' '.join(params1)), 'info')
    try:
        result1 = subprocess.check_output(
            params1,
            cwd=working_dir,
        )
    except subprocess.CalledProcessError as e:
        echo(e.output, 'warning')
    else:
        if result1:
            echo(result1, 'info')

    echo(u'RUN: {0}'.format(' '.join(params2)), 'info')
    try:
        result2 = subprocess.check_output(
            params2,
            cwd=working_dir,
        )
    except subprocess.CalledProcessError as e:
        echo(e.output, 'warning')
    else:
        echo(result2, 'info')
Ejemplo n.º 13
0
def git_support_enabled(configurator, question):
    disabled = configurator.variables.get("package.git.disabled", u"False")
    if hooks.to_boolean(None, None, disabled):
        echo(u"GIT support disabled!!!")
        raise SkipQuestion(u"GIT support is disabled, skip question!")
Ejemplo n.º 14
0
def git_support_enabled(configurator, question):
    disabled = configurator.variables.get('package.git.disabled', u'False')
    if hooks.to_boolean(None, None, disabled):
        echo(u'GIT support disabled!!!')
        raise SkipQuestion(u'GIT support is disabled, skip question!')
Ejemplo n.º 15
0
def git_commit(configurator, msg):
    if not git_support(configurator):
        return
    non_interactive = configurator.bobconfig.get('non_interactive')
    working_dir = configurator.variables.get(
        'package.root_folder') or configurator.target_directory
    params1 = [
        'git',
        'add',
        '.',
    ]
    params2 = [
        'git',
        'commit',
        '-m',
        u'"{0}"'.format(msg),
    ]
    git_autocommit = None
    run_git_commit = True
    autocommit_flag = configurator.variables.get(
        'package.git.autocommit', u'False',
    )
    if hooks.to_boolean(None, None, autocommit_flag):
        git_autocommit = True
    if not non_interactive and not git_autocommit:
        echo(
            u'Should we run?:\n{0}\n{1}\nin: {2}'.format(
                ' '.join(params1),
                ' '.join(params2),
                working_dir,
            ),
            'info',
        )
        run_git_commit = (input('[y]/n: ') or 'y').lower() == 'y'

    if not run_git_commit and not git_autocommit:
        echo('Skip git commit!', 'warning')
        return

    echo(u'RUN: {0}'.format(' '.join(params1)), 'info')
    try:
        result1 = subprocess.check_output(
            params1,
            cwd=working_dir,
        )
    except subprocess.CalledProcessError as e:
        echo(e.output, 'warning')
    else:
        if result1:
            echo(result1, 'info')

    echo(u'RUN: {0}'.format(' '.join(params2)), 'info')
    try:
        result2 = subprocess.check_output(
            params2,
            cwd=working_dir,
        )
    except subprocess.CalledProcessError as e:
        echo(e.output, 'warning')
    else:
        echo(result2, 'info')