How to use the spython.logger.bot.info function in spython

To help you get started, we’ve selected a few spython 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 singularityhub / singularity-cli / spython / main / parse / writers / base.py View on Github external
==========
           output_file: the file to save to, not required (estimates default)
           force: if True, if file exists, over-write existing file

        '''
        if output_file is None:
            output_file = self._get_conversion_outfile()

        # Cut out early if file exists and we aren't overwriting
        if os.path.exists(output_file) and not force:
            bot.exit('%s exists, and force is False.' % output_file)

        # Do the conversion if function is provided by subclass
        if hasattr(self, 'convert'):
            converted = self.convert()
            bot.info('Saving to %s' % output_file)
            write_file(output_file, converted)
github singularityhub / singularity-cli / spython / main / pull.py View on Github external
cmd.append(image)

    if not quiet:
        bot.info(" ".join(cmd))

    with ScopedEnvVar("SINGULARITY_PULLFOLDER", pull_folder):
        # Option 1: Streaming we just run to show user
        if not stream:
            self._run_command(cmd, capture=capture, quiet=quiet)

        # Option 3: A custom name we can predict (not commit/hash) and can also show
        else:
            return final_image, stream_command(cmd, sudo=False)

    if os.path.exists(final_image) and not quiet:
        bot.info(final_image)
    return final_image
github singularityhub / singularity-cli / spython / main / base / sutils.py View on Github external
'''load an image, either an actual path on the filesystem or a uri.

       Parameters
       ==========
       image: the image path or uri to load (e.g., docker://ubuntu 

    '''
    from spython.image import Image
    from spython.instance import Instance

    self.simage = Image(image)

    if image is not None:
        if image.startswith('instance://'):
            self.simage = Instance(image)
        bot.info(self.simage)
github singularityhub / singularity-cli / spython / main / instances.py View on Github external
name=i["daemon_name"],
                    image=i["container_image"],
                    start=False,
                )

                listing.append(new_instance)
            instances = listing

    # Couldn't get UID

    elif output["return_code"] == 255:
        bot.error("Couldn't get UID")

    # Return code of 0
    else:
        bot.info("No instances found.")

    # If we are given a name, return just one
    if name is not None and instances not in [None, []]:
        if len(instances) == 1:
            instances = instances[0]

    return instances
github singularityhub / singularity-cli / spython / main / pull.py View on Github external
# https://github.com/sylabs/singularity/issues/2788
        if "version 3" in self.version():
            name = final_image
            pull_folder = None  # Don't use pull_folder
    else:
        final_image = name

    cmd = cmd + ["--name", name]

    if force:
        cmd = cmd + ["--force"]

    cmd.append(image)

    if not quiet:
        bot.info(" ".join(cmd))

    with ScopedEnvVar("SINGULARITY_PULLFOLDER", pull_folder):
        # Option 1: Streaming we just run to show user
        if not stream:
            self._run_command(cmd, capture=capture, quiet=quiet)

        # Option 3: A custom name we can predict (not commit/hash) and can also show
        else:
            return final_image, stream_command(cmd, sudo=False)

    if os.path.exists(final_image) and not quiet:
        bot.info(final_image)
    return final_image
github singularityhub / singularity-cli / spython / utils / terminal.py View on Github external
cmd = [software, "--version"]
    found = False

    try:
        version = run_command(cmd, quiet=True)
    except:  # FileNotFoundError
        return found

    if version is not None:
        if version["return_code"] == 0:
            found = True

        if not quiet:
            version = version["message"]
            bot.info("Found %s version %s" % (software.upper(), version))

    return found
github singularityhub / singularity-cli / spython / instance / cmd / iutils.py View on Github external
name=i["daemon_name"],
                    image=i["container_image"],
                    start=False,
                )

                listing.append(new_instance)
            instances = listing

    # Couldn't get UID

    elif output["return_code"] == 255:
        bot.error("Couldn't get UID")

    # Return code of 0
    else:
        bot.info("No instances found.")

    # If we are given a name, return just one
    if name is not None and len(instances) == 1:
        instances = instances[0]

    return instances