How to use the bloom.util.maybe_continue function in bloom

To help you get started, we’ve selected a few bloom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ros-infrastructure / bloom / doc / publish_docs.py View on Github external
print("Generating github pages documentation for version '{0}'...".format(ver))

execute_command('make clean', cwd='doc')
execute_command('python setup.py build_sphinx')
execute_command('sphinxtogithub doc/build/html --verbose')
orig_cwd = os.getcwd()

clone = GitClone()
with clone as clone_dir:
    execute_command('git clean -fdx')
    with inbranch('gh-pages'):
        doc_dir = os.path.join('doc', ver)
        if os.path.exists(doc_dir):
            warning("Documentation for version '" + ver + "' already exists.")
            if not maybe_continue('y'):
                sys.exit(-1)
            execute_command('git rm -rf ' + doc_dir)
        shutil.copytree(os.path.join(orig_cwd, 'doc', 'build', 'html'),
                        doc_dir)
        p = re.compile('\d*[.]\d*[.]\d*')
        with open('doc/index.html', 'r') as f:
            redirect = f.read()
        redirect = p.sub(ver, redirect)
        with open('doc/index.html', 'w+') as f:
            f.write(redirect)
        execute_command('git add ' + os.path.join('doc', ver))
        execute_command('git add doc/index.html')
        if has_changes():
            execute_command('git commit -m "Uploading documentation for '
                            'version {0}"'.format(ver))
clone.commit()
github ros-infrastructure / bloom / bloom / generators / debian / generator.py View on Github external
"same as the version being currently released '{1}'."
              .format(package.version, changelogs[0][0]))
        bad_changelog = True
    # Make sure that the current version is the latest in the changelog
    for changelog in changelogs:
        if parse_version(package.version) < parse_version(changelog[0]):
            error("")
            error("There is at least one changelog entry, '{0}', which has a "
                  "newer version than the version of package '{1}' being released, '{2}'."
                  .format(changelog[0], package.name, package.version))
            bad_changelog = True
    if bad_changelog:
        error("This is almost certainly by mistake, you should really take a "
              "look at the changelogs for the package you are releasing.")
        error("")
        if not maybe_continue('n', 'Continue anyways'):
            sys.exit("User quit.")
    data['changelogs'] = changelogs
    # Use debhelper version 7 for oneric, otherwise 9
    data['debhelper_version'] = 7 if os_version in ['oneiric'] else 9
    # Summarize dependencies
    summarize_dependency_mapping(data, depends, build_depends, resolved_deps)
    # Copyright
    licenses = []
    separator = '\n' + '=' * 80 + '\n\n'
    for l in package.licenses:
        if hasattr(l, 'file') and l.file is not None:
            license_file = os.path.join(os.path.dirname(package.filename), l.file)
            if not os.path.exists(license_file):
                error("License file '{}' is not found.".
                      format(license_file), exit=True)
            license_text = open(license_file, 'r').read()
github ros-infrastructure / bloom / bloom / commands / git / config.py View on Github external
def check_git_init():
    if get_root() is None:
        error("Not in a valid git repository", exit=True)
    cmd = 'git show-ref --heads'
    result = execute_command(cmd, autofail=False,
                             silent_error=True)
    if result != 0:
        info("Freshly initialized git repository detected.")
        info("An initial empty commit is going to be made.")
        if not maybe_continue():
            error("Answered no to continue, exiting.", exit=True)
        # Make an initial empty commit
        execute_command('git commit --allow-empty -m "Initial commit"', silent=True)
github ros-infrastructure / bloom / bloom / generators / rpm / generator.py View on Github external
def post_patch(self, destination, color='bluef'):
        if destination in self.rpm_branches:
            return
        # Tag after patches have been applied
        with inbranch(destination):
            # Tag
            tag_name = self.tag_names[destination]
            if tag_exists(tag_name):
                if self.interactive:
                    warning("Tag exists: " + tag_name)
                    warning("Do you wish to overwrite it?")
                    if not maybe_continue('y'):
                        error("Answered no to continue, aborting.", exit=True)
                else:
                    warning("Overwriting tag: " + tag_name)
            else:
                info("Creating tag: " + tag_name)
            execute_command('git tag -f ' + tag_name)
        # Report of success
        name = destination.split('/')[-1]
        package = self.packages[name]
        distro = destination.split('/')[-2]
        info(ansi(color) + "####" + ansi('reset'), use_prefix=False)
        info(
            ansi(color) + "#### " + ansi('greenf') + "Successfully" +
            ansi(color) + " generated '" + ansi('boldon') + self.os_name +
            ' ' + distro + ansi('boldoff') + "' RPM for package"
            " '" + ansi('boldon') + package.name + ansi('boldoff') + "'" +
github ros-infrastructure / bloom / bloom / github.py View on Github external
return Github(username, auth=auth_header_from_oauth_token(token), token=token)
    if not os.path.isdir(os.path.dirname(oauth_config_path)):
        os.makedirs(os.path.dirname(oauth_config_path))
    if quiet:
        return None
    # Ok, now we have to ask for the user name and pass word
    info("")
    warning("Looks like bloom doesn't have an oauth token for you yet.")
    warning("Therefore bloom will require your GitHub username and password just this once.")
    warning("With your GitHub username and password bloom will create an oauth token on your behalf.")
    warning("The token will be stored in `~/.config/bloom`.")
    warning("You can delete the token from that file to have a new token generated.")
    warning("Guard this token like a password, because it allows someone/something to act on your behalf.")
    warning("If you need to unauthorize it, remove it from the 'Applications' menu in your GitHub account page.")
    info("")
    if not maybe_continue('y', "Would you like to create an OAuth token now"):
        return None
    token = None
    while token is None:
        try:
            username = getpass.getuser()
            username = safe_input("GitHub username [{0}]: ".format(username)) or username
            password = getpass.getpass("GitHub password (never stored): ")
        except (KeyboardInterrupt, EOFError):
            return None
        if not password:
            error("No password was given, aborting.")
            return None
        gh = Github(username, auth=auth_header_from_basic_auth(username, password))
        try:
            token = gh.create_new_bloom_authorization(update_auth=True)
            with open(oauth_config_path, 'w') as f:
github ros-infrastructure / bloom / bloom / commands / git / generate.py View on Github external
def run_generator(generator, arguments):
    try:
        gen = generator
        try_execute('generator handle arguments', '',
                    gen.handle_arguments, arguments)
        try_execute('generator summarize', '',
                    gen.summarize)
        if arguments.interactive:
            if not maybe_continue('y'):
                error("Answered no to continue, aborting.", exit=True)
        try_execute('generator pre_modify', '',
                    gen.pre_modify)
        for branch_args in generator.get_branching_arguments():
            parsed_branch_args = parse_branch_args(branch_args,
                                                   arguments.interactive)
            destination, source, interactive = parsed_branch_args
            # Summarize branch command
            msg = summarize_branch_cmd(destination, source, interactive)

            # Run pre - branch - post
            # Pre branch
            try_execute('generator pre_branch', msg,
                        gen.pre_branch, destination, source)
            # Branch
            try_execute('git-bloom-branch', msg,
github ros-infrastructure / bloom / bloom / generators / rpm / generator.py View on Github external
def place_template_files(self, build_type, rpm_dir='rpm'):
        # Create/Clean the rpm folder
        if os.path.exists(rpm_dir):
            if self.interactive:
                warning("rpm directory exists: " + rpm_dir)
                warning("Do you wish to overwrite it?")
                if not maybe_continue('y'):
                    error("Answered no to continue, aborting.", exit=True)
            else:
                warning("Overwriting rpm directory: " + rpm_dir)
            execute_command('git rm -rf ' + rpm_dir)
            execute_command('git commit -m "Clearing previous rpm folder"')
            if os.path.exists(rpm_dir):
                shutil.rmtree(rpm_dir)
        # Use generic place template files command
        place_template_files('.', build_type, gbp=True)
        # Commit results
        execute_command('git add ' + rpm_dir)
        execute_command('git commit -m "Placing rpm template files"')
github ros-infrastructure / bloom / bloom / commands / git / config.py View on Github external
def update_track(track_dict):
    for key, value in DEFAULT_TEMPLATE.items():
        if key in ['actions']:
            if track_dict[key] != DEFAULT_TEMPLATE[key]:
                warning("Your track's '{0}' configuration is not the same as the default."
                        .format(key))
                default = 'n'
                if key == 'actions':
                    default = 'y'
                    warning("Unless you have manually modified your 'actions' "
                            "(the commands which get run for a release), "
                            "you should update to the new default.")
                warning("Should it be updated to the default setting?")
                if maybe_continue(default):
                    track_dict[key] = DEFAULT_TEMPLATE[key]
        elif key not in track_dict:
            value = value.default if isinstance(value, PromptEntry) else value
            track_dict[key] = value
    return track_dict
github ros-infrastructure / bloom / bloom / github.py View on Github external
token = gh.create_new_bloom_authorization(update_auth=True)
            with open(oauth_config_path, 'w') as f:
                config.update({'oauth_token': token, 'github_user': username})
                f.write(json.dumps(config))
            info("The token '{token}' was created and stored in the bloom config file: '{oauth_config_path}'"
                 .format(**locals()))
        except GitHubAuthException as exc:
            error("{0}".format(exc))
            mfa_prompt(oauth_config_path, username)
        except GithubException as exc:
            error("{0}".format(exc))
            info("")
            if hasattr(exc, 'resp') and '{0}'.format(exc.resp.status) in ['401']:
                mfa_prompt(oauth_config_path, username)
            warning("This sometimes fails when the username or password are incorrect, try again?")
            if not maybe_continue():
                return None
    _gh = gh
    return gh