How to use the spython.logger.bot.warning 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 / parsers / docker.py View on Github external
==========
           line: the line from the recipe file to parse for ARG
   
        """
        line = self._setup("ARG", line)

        # Args are treated like envars, so we add them to install
        environ = self.parse_env([x for x in line if "=" in x])
        self.recipe[self.active_layer].install += environ

        # Try to extract arguments from the line
        for arg in line:

            # An undefined arg cannot be used
            if "=" not in arg:
                bot.warning(
                    "ARG is not supported for Singularity, and must be defined with "
                    "a default to be parsed. Skipping %s" % arg
                )
                continue

            arg, value = arg.split("=", 1)
            arg = arg.strip()
            value = value.strip()
            bot.debug("Updating ARG %s to %s" % (arg, value))
            self.args[arg] = value
github singularityhub / singularity-cli / spython / main / parse / parsers / singularity.py View on Github external
# Still in current section!
            else:
                new_member = lines.pop(0).strip()
                if new_member not in ["", None]:
                    members.append(new_member)

        # Add the list to the config
        if members and section is not None:

            # Get the correct parsing function
            parser = self._get_mapping(section)

            # Parse it, if appropriate
            if not parser:
                bot.warning("%s is an unrecognized section, skipping." % section)
            else:
                if section == "files":
                    parser(members, layer)
                else:
                    parser(members)
github singularityhub / singularity-cli / spython / instance / cmd / logs.py View on Github external
get_userhome(),
        ".singularity",
        "instances",
        "logs",
        hostname,
        get_username(),
        "%s.%s" % (self.name, ext),
    )

    if os.path.exists(logpath):
        with open(logpath, "r") as filey:
            logs = filey.read()
        if print_logs is True:
            print(logs)
    else:
        bot.warning("No log files have been produced.")
    return logs
github singularityhub / singularity-cli / spython / main / parse / parsers / docker.py View on Github external
or https. We make sure that any local references are changed to
           actual file locations before adding to the files list.
     
           Parameters
           ==========
           source: the source
           dest: the destiation
        """

        # Warn the user Singularity doesn't support expansion
        if "*" in source:
            bot.warning("Singularity doesn't support expansion, * found in %s" % source)

        # Warning if file/folder (src) doesn't exist
        if not os.path.exists(source) and layer is None:
            bot.warning("%s doesn't exist, ensure exists for build" % source)

        # The pair is added to the files as a list
        if not layer:
            self.recipe[self.active_layer].files.append([source, dest])

        # Unless the file is to be copied from a particular layer
        else:
            if layer not in self.recipe[self.active_layer].layer_files:
                self.recipe[self.active_layer].layer_files[layer] = []
            self.recipe[self.active_layer].layer_files[layer].append([source, dest])
github singularityhub / singularity-cli / spython / main / parse / parsers / singularity.py View on Github external
def _setup(self, lines):
        """setup required adding content from the host to the rootfs,
           so we try to capture with with ADD.
        """
        bot.warning("SETUP is error prone, please check output.")

        for line in lines:

            # For all lines, replace rootfs with actual root /
            line = re.sub("[$]{?SINGULARITY_ROOTFS}?", "", "$SINGULARITY_ROOTFS")

            # If we have nothing left, don't continue
            if line in ["", None]:
                continue

            # If the line starts with copy or move, assume is file from host
            if re.search("(^cp|^mv)", line):
                line = re.sub("(^cp|^mv)", "", line)
                self.files.append(line)

            # If it's a general command, add to install routine
github singularityhub / singularity-cli / spython / main / parse / parsers / singularity.py View on Github external
Parameters
           ==========
           lines: the line from the recipe file to parse for CMD

        """
        lines = [x for x in lines if x not in ["", None]]

        # Default runscript is first index
        runscript = lines[0]

        # Multiple line runscript needs multiple lines written to script
        if len(lines) > 1:

            bot.warning("More than one line detected for runscript!")
            bot.warning("These will be echoed into a single script to call.")
            self._write_script("/entrypoint.sh", lines)
            runscript = "/bin/bash /entrypoint.sh"

        self.recipe[self.active_layer].cmd = runscript
github singularityhub / singularity-cli / spython / main / parse / parsers / singularity.py View on Github external
call it directly. If not, write the entrypoint into a script. 

           Parameters
           ==========
           lines: the line from the recipe file to parse for CMD

        """
        lines = [x for x in lines if x not in ["", None]]

        # Default runscript is first index
        runscript = lines[0]

        # Multiple line runscript needs multiple lines written to script
        if len(lines) > 1:

            bot.warning("More than one line detected for runscript!")
            bot.warning("These will be echoed into a single script to call.")
            self._write_script("/entrypoint.sh", lines)
            runscript = "/bin/bash /entrypoint.sh"

        self.recipe[self.active_layer].cmd = runscript